version 1.1.1.1, 2012/02/21 23:16:22
|
version 1.1.1.2, 2013/07/22 00:36:10
|
Line 1
|
Line 1
|
#!/bin/sh |
#!/bin/sh |
# $Id$ |
# $Id$ |
# project miniupnp : http://miniupnp.free.fr/ |
# project miniupnp : http://miniupnp.free.fr/ |
# (c) 2011 Thomas Bernard | # (c) 2011-2012 Thomas Bernard |
# |
# |
# test program for miniwget.c |
# test program for miniwget.c |
# is usually invoked by "make check" |
# is usually invoked by "make check" |
Line 12
|
Line 12
|
# 3 - compares served and received data |
# 3 - compares served and received data |
# 4 - kills the local HTTP server and exits |
# 4 - kills the local HTTP server and exits |
# |
# |
|
# The script was tested and works with ksh, bash |
|
# It fails to run with dash 0.5.5.1 because of "kill %1" |
|
|
HTTPSERVEROUT=/tmp/httpserverout | TMPDIR=`mktemp -d` |
EXPECTEDFILE=/tmp/expectedfile | HTTPSERVEROUT="${TMPDIR}/httpserverout" |
DOWNLOADEDFILE=/tmp/downloadedfile | EXPECTEDFILE="${TMPDIR}/expectedfile" |
#ADDR=localhost | DOWNLOADEDFILE="${TMPDIR}/downloadedfile" |
ADDR="[::1]" | |
PORT= |
PORT= |
RET=0 |
RET=0 |
|
|
|
case "$HAVE_IPV6" in |
|
n|no|0) |
|
ADDR=localhost |
|
SERVERARGS="" |
|
;; |
|
*) |
|
ADDR="[::1]" |
|
SERVERARGS="-6" |
|
;; |
|
|
|
esac |
|
|
#make minihttptestserver |
#make minihttptestserver |
#make testminiwget |
#make testminiwget |
|
|
# launching the test HTTP server |
# launching the test HTTP server |
./minihttptestserver -6 -e $EXPECTEDFILE > $HTTPSERVEROUT & | ./minihttptestserver $SERVERARGS -e $EXPECTEDFILE > $HTTPSERVEROUT & |
while [ "$PORT" == "" ]; do | while [ -z "$PORT" ]; do |
| sleep 1 |
PORT=`cat $HTTPSERVEROUT | sed 's/Listening on port \([0-9]*\)/\1/' ` |
PORT=`cat $HTTPSERVEROUT | sed 's/Listening on port \([0-9]*\)/\1/' ` |
done |
done |
echo "Test HTTP server is listening on $PORT" |
echo "Test HTTP server is listening on $PORT" |
Line 72 if [ $RET -eq 0 ]; then
|
Line 86 if [ $RET -eq 0 ]; then
|
rm -f "${DOWNLOADEDFILE}.2" |
rm -f "${DOWNLOADEDFILE}.2" |
rm -f "${DOWNLOADEDFILE}.3" |
rm -f "${DOWNLOADEDFILE}.3" |
rm -f $EXPECTEDFILE $HTTPSERVEROUT |
rm -f $EXPECTEDFILE $HTTPSERVEROUT |
|
rmdir ${TMPDIR} |
else |
else |
echo "at least one of the test FAILED" |
echo "at least one of the test FAILED" |
|
echo "directory ${TMPDIR} is left intact" |
fi |
fi |
exit $RET |
exit $RET |
|
|