darkhttpd/devel/cover

90 lines
2.2 KiB
Plaintext
Raw Normal View History

2011-01-17 15:59:41 +03:00
#!/bin/sh
#
# Build a coverage-enabled darkhttpd, run unit tests and calculate coverage.
2011-01-17 15:59:41 +03:00
#
cd $(dirname $0)
2011-01-17 15:59:41 +03:00
DIR=tmp.httpd.tests
PORT=12346
CC=gcc
2011-01-17 15:59:41 +03:00
if [ ! -e test.py ]; then
echo "can't find test.py, aborting" >&2
exit 1
fi
2011-05-03 14:11:09 +04:00
if [ \( ! -x a.out \) -o \( ../darkhttpd.c -nt a.out \) ]; then
2013-06-10 14:41:46 +04:00
echo "===> building a.out, darkhttpd.gcno"
2015-01-01 12:35:37 +03:00
$CC -g -O2 -fprofile-arcs -ftest-coverage -DDEBUG -DAPBUF_INIT=1 ../darkhttpd.c || exit 1
2011-01-17 15:59:41 +03:00
fi
if [ -e $DIR ]; then
rm -rf $DIR || exit 1
fi
mkdir $DIR || exit 1
2015-01-01 12:32:52 +03:00
mkdir $DIR/forbidden || exit 1
chmod 0 $DIR/forbidden || exit 1
2011-04-16 13:15:32 +04:00
rm -f darkhttpd.gcda darkhttpd.log
2013-06-10 14:41:46 +04:00
echo "===> test_make_safe_uri"
$CC -g -O2 test_make_safe_uri.c -o test_make_safe_uri || exit 1
if ./test_make_safe_uri | egrep '^FAIL:'; then
echo test_make_safe_uri failed >&2
exit 1
fi
2013-06-10 14:41:46 +04:00
echo "===> run usage statement"
2011-05-03 14:14:10 +04:00
./a.out >/dev/null
2013-04-28 18:31:54 +04:00
2013-06-10 14:41:46 +04:00
echo "===> run tests against a basic instance (generates darkhttpd.gcda)"
2015-01-01 12:32:52 +03:00
./a.out $DIR --port $PORT --log cover.out.log >cover.out.stdout 2>cover.out.stderr &
2011-01-17 15:59:41 +03:00
PID=$!
kill -0 $PID || exit 1
python test.py
kill $PID
2013-06-10 14:41:46 +04:00
wait $PID
2013-04-28 18:31:54 +04:00
echo "===> run --forward tests"
2013-04-28 18:31:54 +04:00
./a.out $DIR --port $PORT \
--forward example.com http://www.example.com \
--forward secure.example.com https://www.example.com/secure >/dev/null &
2013-04-28 18:31:54 +04:00
PID=$!
kill -0 $PID || exit 1
python test_forward.py
kill $PID
2013-06-10 14:41:46 +04:00
wait $PID
2013-04-28 18:31:54 +04:00
echo "===> run --forward-all tests"
./a.out $DIR --port $PORT \
--forward example.com http://www.example.com \
--forward-all http://catchall.example.com >/dev/null &
PID=$!
kill -0 $PID || exit 1
python test_forward_all.py
kill $PID
wait $PID
echo "===> run --no-server-id tests"
./a.out $DIR --port $PORT --no-server-id >/dev/null &
PID=$!
kill -0 $PID || exit 1
python test_server_id.py
kill $PID
2013-06-10 14:41:46 +04:00
wait $PID
echo "===> run mimemap tests"
echo "test/type1 a1" > $DIR/mimemap
echo "test/this-gets-replaced ap2" >> $DIR/mimemap
echo "# this is a comment" >> $DIR/mimemap
2015-01-01 12:16:47 +03:00
printf "test/type3\\tapp3\r\n" >> $DIR/mimemap
2013-06-10 14:41:46 +04:00
echo "test/type2 ap2" >> $DIR/mimemap
./a.out $DIR --port $PORT --mimetypes $DIR/mimemap >/dev/null &
PID=$!
kill -0 $PID || exit 1
python test_mimemap.py
kill $PID
wait $PID
2013-06-10 14:41:46 +04:00
echo "===> generating darkhttpd.c.gcov report"
2011-01-17 15:59:41 +03:00
gcov darkhttpd
rm -rf $DIR
2015-01-01 12:32:52 +03:00
rm -f darkhttpd.gcda darkhttpd.gcno a.out
echo done