--- embedaddon/miniupnpc/testminiwget.sh 2012/02/21 23:16:22 1.1.1.1 +++ embedaddon/miniupnpc/testminiwget.sh 2013/07/22 00:36:10 1.1.1.2 @@ -1,7 +1,7 @@ #!/bin/sh -# $Id: testminiwget.sh,v 1.1.1.1 2012/02/21 23:16:22 misho Exp $ +# $Id: testminiwget.sh,v 1.1.1.2 2013/07/22 00:36:10 misho Exp $ # project miniupnp : http://miniupnp.free.fr/ -# (c) 2011 Thomas Bernard +# (c) 2011-2012 Thomas Bernard # # test program for miniwget.c # is usually invoked by "make check" @@ -12,21 +12,35 @@ # 3 - compares served and received data # 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 -EXPECTEDFILE=/tmp/expectedfile -DOWNLOADEDFILE=/tmp/downloadedfile -#ADDR=localhost -ADDR="[::1]" +TMPDIR=`mktemp -d` +HTTPSERVEROUT="${TMPDIR}/httpserverout" +EXPECTEDFILE="${TMPDIR}/expectedfile" +DOWNLOADEDFILE="${TMPDIR}/downloadedfile" PORT= RET=0 +case "$HAVE_IPV6" in + n|no|0) + ADDR=localhost + SERVERARGS="" + ;; + *) + ADDR="[::1]" + SERVERARGS="-6" + ;; + +esac + #make minihttptestserver #make testminiwget # launching the test HTTP server -./minihttptestserver -6 -e $EXPECTEDFILE > $HTTPSERVEROUT & -while [ "$PORT" == "" ]; do +./minihttptestserver $SERVERARGS -e $EXPECTEDFILE > $HTTPSERVEROUT & +while [ -z "$PORT" ]; do + sleep 1 PORT=`cat $HTTPSERVEROUT | sed 's/Listening on port \([0-9]*\)/\1/' ` done echo "Test HTTP server is listening on $PORT" @@ -72,8 +86,10 @@ if [ $RET -eq 0 ]; then rm -f "${DOWNLOADEDFILE}.2" rm -f "${DOWNLOADEDFILE}.3" rm -f $EXPECTEDFILE $HTTPSERVEROUT + rmdir ${TMPDIR} else echo "at least one of the test FAILED" + echo "directory ${TMPDIR} is left intact" fi exit $RET