File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / miniupnpc / testminiwget.sh
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:16:22 2012 UTC (12 years, 4 months ago) by misho
Branches: miniupnpc, elwix, MAIN
CVS tags: v1_6, HEAD
miniupnpc

    1: #!/bin/sh
    2: # $Id: testminiwget.sh,v 1.1.1.1 2012/02/21 23:16:22 misho Exp $
    3: # project miniupnp : http://miniupnp.free.fr/
    4: # (c) 2011 Thomas Bernard
    5: #
    6: # test program for miniwget.c
    7: # is usually invoked by "make check"
    8: #
    9: # This test program :
   10: #  1 - launches a local HTTP server (minihttptestserver)
   11: #  2 - uses testminiwget to retreive data from this server
   12: #  3 - compares served and received data
   13: #  4 - kills the local HTTP server and exits
   14: #
   15: 
   16: HTTPSERVEROUT=/tmp/httpserverout
   17: EXPECTEDFILE=/tmp/expectedfile
   18: DOWNLOADEDFILE=/tmp/downloadedfile
   19: #ADDR=localhost
   20: ADDR="[::1]"
   21: PORT=
   22: RET=0
   23: 
   24: #make minihttptestserver
   25: #make testminiwget
   26: 
   27: # launching the test HTTP server
   28: ./minihttptestserver -6 -e $EXPECTEDFILE > $HTTPSERVEROUT &
   29: while [ "$PORT" == "" ]; do
   30: 	PORT=`cat $HTTPSERVEROUT | sed 's/Listening on port \([0-9]*\)/\1/' `
   31: done
   32: echo "Test HTTP server is listening on $PORT"
   33: 
   34: URL1="http://$ADDR:$PORT/index.html"
   35: URL2="http://$ADDR:$PORT/chunked"
   36: URL3="http://$ADDR:$PORT/addcrap"
   37: 
   38: echo "standard test ..."
   39: ./testminiwget $URL1 "${DOWNLOADEDFILE}.1"
   40: if cmp $EXPECTEDFILE "${DOWNLOADEDFILE}.1" ; then
   41: 	echo "ok"
   42: else
   43: 	echo "standard test FAILED"
   44: 	RET=1
   45: fi
   46: 
   47: echo "chunked transfert encoding test ..."
   48: ./testminiwget $URL2 "${DOWNLOADEDFILE}.2"
   49: if cmp $EXPECTEDFILE "${DOWNLOADEDFILE}.2" ; then
   50: 	echo "ok"
   51: else
   52: 	echo "chunked transfert encoding test FAILED"
   53: 	RET=1
   54: fi
   55: 
   56: echo "response too long test ..."
   57: ./testminiwget $URL3 "${DOWNLOADEDFILE}.3"
   58: if cmp $EXPECTEDFILE "${DOWNLOADEDFILE}.3" ; then
   59: 	echo "ok"
   60: else
   61: 	echo "response too long test FAILED"
   62: 	RET=1
   63: fi
   64: 
   65: # kill the test HTTP server
   66: kill %1
   67: wait %1
   68: 
   69: # remove temporary files (for success cases)
   70: if [ $RET -eq 0 ]; then
   71: 	rm -f "${DOWNLOADEDFILE}.1"
   72: 	rm -f "${DOWNLOADEDFILE}.2"
   73: 	rm -f "${DOWNLOADEDFILE}.3"
   74: 	rm -f $EXPECTEDFILE $HTTPSERVEROUT
   75: else
   76: 	echo "at least one of the test FAILED"
   77: fi
   78: exit $RET
   79: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>