Add test for --mimetypes

This commit is contained in:
Emil Mikulic
2013-06-10 20:41:46 +10:00
parent e6680c4f2f
commit 7dc06f3096
2 changed files with 64 additions and 6 deletions

View File

@ -11,25 +11,27 @@ if [ ! -e test.py ]; then
exit 1
fi
if [ \( ! -x a.out \) -o \( ../darkhttpd.c -nt a.out \) ]; then
echo "===> building a.out, darkhttpd.gcno"
gcc -g -fprofile-arcs -ftest-coverage ../darkhttpd.c || exit 1
# generates a.out, darkhttpd.gcno
fi
if [ -e $DIR ]; then
rm -rf $DIR || exit 1
fi
mkdir $DIR || exit 1
rm -f darkhttpd.gcda darkhttpd.log
# display usage statement
echo "===> run usage statement"
./a.out >/dev/null
# run tests against a basic instance (generates darkhttpd.gcda)
echo "===> run tests against a basic instance (generates darkhttpd.gcda)"
./a.out $DIR --port $PORT --log darkhttpd.log >/dev/null &
PID=$!
kill -0 $PID || exit 1
python test.py
kill $PID
wait $PID
# run forward tests
echo "===> run forwarding tests"
./a.out $DIR --port $PORT \
--forward example.com http://www.example.com \
--forward secure.example.com https://www.example.com/secure >/dev/null &
@ -37,15 +39,30 @@ PID=$!
kill -0 $PID || exit 1
python test_forward.py
kill $PID
wait $PID
# run no-server-id tests
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
wait $PID
echo generating darkhttpd.c.gcov report
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
printf "test/type3\\tapp3\n" >> $DIR/mimemap
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
echo "===> generating darkhttpd.c.gcov report"
gcov darkhttpd
rm -rf $DIR
rm -f darkhttpd.gcda darkhttpd.gcno darkhttpd.log a.out