Blob


1 # tests to run as a port of the regression suite. Leave empty to run
2 # all.
3 TESTS=
5 DISTFILES = Makefile \
6 env \
7 err \
8 example.mime.types \
9 fcgi-test.c \
10 fill-file.c \
11 hello \
12 invalid \
13 iri_test.c \
14 lib.sh \
15 max-length-reply \
16 puny-test.c \
17 regress \
18 serve-bigfile \
19 sha \
20 slow \
21 tests.sh \
22 valid.ext
24 include ../Makefile.local
26 COMPAT= ${COBJS:%=../%}
28 .PHONY: all data clean dist
30 all: data puny-test iri_test fcgi-test
31 ./regress ${TESTS}
33 data: testdata cert.pem testca.pem valid.crt invalid.cert.pem
35 puny-test: puny-test.o ../puny.o ../utf8.o ../utils.o ../log.o ${COMPAT}
36 ${CC} puny-test.o ../puny.o ../utf8.o ../utils.o ../log.o ${COMPAT} \
37 -o puny-test ${LDFLAGS}
39 iri_test: iri_test.o ../iri.o ../utf8.o ${COMPAT}
40 ${CC} iri_test.o ../iri.o ../utf8.o ${COMPAT} -o $@ ${LDFLAGS}
42 fill-file: fill-file.o
43 ${CC} fill-file.o -o $@ ${LDFLAGS}
45 fcgi-test: fcgi-test.o
46 ${CC} fcgi-test.o ${COMPAT} -o fcgi-test ${LDFLAGS}
48 key.pem: cert.pem
50 # XXX: key size is NOT GOOD. This is only for testing. Smaller keys
51 # are quicker to generate. DON'T DO THIS AT HOME.
52 cert.pem:
53 openssl req -x509 -newkey rsa:2048 \
54 -keyout key.pem \
55 -out cert.pem \
56 -days 365 -nodes \
57 -subj "/CN=localhost"
58 ln -s cert.pem localhost.cert.pem
59 ln -s key.pem localhost.key.pem
60 @echo
62 testca.pem:
63 openssl genrsa -out testca.key 2048
64 openssl req -x509 -new -sha256 \
65 -key testca.key \
66 -days 365 -nodes \
67 -out testca.pem \
68 -subj "/CN=testca"
69 @echo
71 valid.crt: testca.pem
72 openssl genrsa -out valid.key 2048
73 openssl req -new -key valid.key \
74 -out valid.csr \
75 -subj "/CN=valid"
76 @echo
77 openssl x509 -req -in valid.csr \
78 -CA testca.pem \
79 -CAkey testca.key \
80 -CAcreateserial \
81 -out valid.crt \
82 -days 365 \
83 -sha256 -extfile valid.ext
85 invalid.cert.pem: cert.pem
86 cp cert.pem invalid.cert.pem
87 cp key.pem invalid.key.pem
89 clean:
90 rm -f *.o iri_test cert.pem key.pem
91 rm -f localhost.cert.pem localhost.key.pem
92 rm -f testca.* valid.csr valid.key valid.crt invalid.*pem
93 rm -rf testdata fill-file puny-test fcgi-test
94 rm -f gmid.pid
96 testdata: fill-file
97 mkdir testdata
98 ./fill-file testdata/bigfile
99 ./sha testdata/bigfile testdata/bigfile.sha
100 printf "# hello world\n" > testdata/index.gmi
101 ./sha testdata/index.gmi testdata/index.gmi.sha
102 cp hello slow err invalid serve-bigfile env testdata/
103 cp max-length-reply testdata
104 mkdir testdata/dir
105 date > 'testdata/dir/current date'
106 cp hello testdata/dir
107 cp testdata/index.gmi testdata/dir/foo.gmi
108 touch testdata/test.m3u8 testdata/foo.1
110 dist: ${DISTFILES}
111 mkdir -p ${DESTDIR}/
112 ${INSTALL} -m 0644 ${DISTFILES} ${DESTDIR}/
113 cd ${DESTDIR}/ && chmod +x env err hello invalid \
114 max-length-reply regress sha slow