3 # Build a coverage-enabled darkhttpd, run unit tests and calculate coverage.
10 if [ ! -e test.py ]; then
11 echo "can't find test.py, aborting" >&2
14 if [ \( ! -x a.out \) -o \( ../darkhttpd.c -nt a.out \) ]; then
15 echo "===> building a.out, darkhttpd.gcno"
16 $CC -g -O2 -fprofile-arcs -ftest-coverage ../darkhttpd.c || exit 1
22 rm -f darkhttpd.gcda darkhttpd.log
24 echo "===> test_make_safe_uri"
25 $CC -g -O2 test_make_safe_uri.c -o test_make_safe_uri || exit 1
26 if ./test_make_safe_uri | egrep '^FAIL:'; then
27 echo test_make_safe_uri failed >&2
31 echo "===> run usage statement"
34 echo "===> run tests against a basic instance (generates darkhttpd.gcda)"
35 ./a.out $DIR --port $PORT --log darkhttpd.log >/dev/null &
37 kill -0 $PID || exit 1
42 echo "===> run --forward tests"
43 ./a.out $DIR --port $PORT \
44 --forward example.com http://www.example.com \
45 --forward secure.example.com https://www.example.com/secure >/dev/null &
47 kill -0 $PID || exit 1
48 python test_forward.py
52 echo "===> run --forward-all tests"
53 ./a.out $DIR --port $PORT \
54 --forward example.com http://www.example.com \
55 --forward-all http://catchall.example.com >/dev/null &
57 kill -0 $PID || exit 1
58 python test_forward_all.py
62 echo "===> run --no-server-id tests"
63 ./a.out $DIR --port $PORT --no-server-id >/dev/null &
65 kill -0 $PID || exit 1
66 python test_server_id.py
70 echo "===> run mimemap tests"
71 echo "test/type1 a1" > $DIR/mimemap
72 echo "test/this-gets-replaced ap2" >> $DIR/mimemap
73 echo "# this is a comment" >> $DIR/mimemap
74 printf "test/type3\\tapp3\n" >> $DIR/mimemap
75 echo "test/type2 ap2" >> $DIR/mimemap
76 ./a.out $DIR --port $PORT --mimetypes $DIR/mimemap >/dev/null &
78 kill -0 $PID || exit 1
79 python test_mimemap.py
83 echo "===> generating darkhttpd.c.gcov report"
86 rm -f darkhttpd.gcda darkhttpd.gcno darkhttpd.log a.out