Blob


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