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 slow \
20 tests.sh \
21 valid.ext
23 include ../config.mk
25 COBJS = ${COMPATS:.c=.o}
26 REG_COMPATS = ${COBJS:%=../%}
28 PUNY_SRCS = puny-test.c ../puny.c ../utf8.c ../utils.c ../log.c
29 PUNY_OBJS = ${PUNY_SRCS:.c=.o} ${REG_COMPATS}
31 IRI_SRCS = iri_test.c ../iri.c ../utf8.c
32 IRI_OBJS = ${IRI_SRCS:.c=.o} ${REG_COMPATS}
34 .PHONY: all data clean dist
36 all: data puny-test iri_test fcgi-test
37 ./regress ${TESTS}
39 data: testdata cert.pem testca.pem valid.crt invalid.cert.pem
41 puny-test: ${PUNY_OBJS}
42 ${CC} ${PUNY_OBJS} -o puny-test ${LIBS} ${LDFLAGS}
44 iri_test: ${IRI_OBJS}
45 ${CC} ${IRI_OBJS} -o $@ ${LIBS} ${LDFLAGS}
47 fill-file: fill-file.o
48 ${CC} fill-file.o -o $@ ${LIBS} ${LDFLAGS}
50 fcgi-test: fcgi-test.o
51 ${CC} fcgi-test.o ${REG_COMPATS} -o fcgi-test ${LIBS} ${LDFLAGS}
53 key.pem: cert.pem
55 # XXX: key size is NOT GOOD. This is only for testing. Smaller keys
56 # are quicker to generate. DON'T DO THIS AT HOME.
57 cert.pem:
58 openssl req -x509 -newkey rsa:2048 \
59 -keyout key.pem \
60 -out cert.pem \
61 -days 365 -nodes \
62 -subj "/CN=localhost"
63 ln -s cert.pem localhost.cert.pem
64 ln -s key.pem localhost.key.pem
65 @echo
67 testca.pem:
68 openssl genrsa -out testca.key 2048
69 openssl req -x509 -new -sha256 \
70 -key testca.key \
71 -days 365 -nodes \
72 -out testca.pem \
73 -subj "/CN=testca"
74 @echo
76 valid.crt: testca.pem
77 openssl genrsa -out valid.key 2048
78 openssl req -new -key valid.key \
79 -out valid.csr \
80 -subj "/CN=valid"
81 @echo
82 openssl x509 -req -in valid.csr \
83 -CA testca.pem \
84 -CAkey testca.key \
85 -CAcreateserial \
86 -out valid.crt \
87 -days 365 \
88 -sha256 -extfile valid.ext
90 invalid.cert.pem: cert.pem
91 cp cert.pem invalid.cert.pem
92 cp key.pem invalid.key.pem
94 clean:
95 rm -f *.o iri_test cert.pem key.pem
96 rm -f localhost.cert.pem localhost.key.pem
97 rm -f testca.* valid.csr valid.key valid.crt invalid.*pem
98 rm -rf testdata fill-file puny-test fcgi-test
99 rm -f gmid.pid fcgi.sock
101 testdata: fill-file
102 mkdir testdata
103 ./fill-file testdata/bigfile
104 printf "# hello world\n" > testdata/index.gmi
105 cp hello slow err invalid serve-bigfile env testdata/
106 cp max-length-reply testdata
107 mkdir testdata/dir
108 date > 'testdata/dir/current date'
109 cp hello testdata/dir
110 cp testdata/index.gmi testdata/dir/foo.gmi
111 touch testdata/test.m3u8 testdata/foo.1
113 dist: ${DISTFILES}
114 mkdir -p ${DESTDIR}/
115 ${INSTALL} -m 0644 ${DISTFILES} ${DESTDIR}/
116 cd ${DESTDIR}/ && chmod +x env err hello invalid \
117 max-length-reply regress slow