diff options
author | Daniel Stenberg <daniel@haxx.se> | 2000-11-13 16:06:16 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2000-11-13 16:06:16 +0000 |
commit | 8e735d1eea3af9e09bb5238ac450cee1192adcb8 (patch) | |
tree | b9c09bb556b35a76baf2e8202877b7d695b40221 /tests/runtests.sh | |
parent | aa9a60287d29821ded4a187ab83d6994335953ce (diff) |
converted shell script to perl
Diffstat (limited to 'tests/runtests.sh')
-rwxr-xr-x | tests/runtests.sh | 220 |
1 files changed, 0 insertions, 220 deletions
diff --git a/tests/runtests.sh b/tests/runtests.sh deleted file mode 100755 index dba912978..000000000 --- a/tests/runtests.sh +++ /dev/null @@ -1,220 +0,0 @@ -#!/bin/sh -# -# Main curl test script -# -####################################################################### -# These should be the only variables that might be needed to get edited: - -HOSTIP=127.0.0.1 -HOSTPORT=8999 -CURL=../src/curl -LOGDIR=log -SERVERIN=$LOGDIR/server.input -CURLOUT=$LOGDIR/curl.out -NC=nc - -# Normally, all test cases should be run, but at times it is handy to -# simply run a particular one: -TESTCASES=all - -# To run specific test cases, set them like: -# TESTCASES="1 2 3 7 8" - -####################################################################### -# No variables below this point should need to be modified -# - -PIDFILE=".server.pid" - -stopserver() { - # check for pidfile - if [ -f $PIDFILE ] ; then - PID=`cat $PIDFILE` - kill -9 $PID - rm -f $PIDFILE # server is killed - fi -} - -runserver () { - # check for pidfile - if [ -f $PIDFILE ] ; then - PID=`cat $PIDFILE` - if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then - STATUS="httpd (pid $PID) running" - RUNNING=1 - else - STATUS="httpd (pid $PID?) not running" - RUNNING=0 - fi - else - STATUS="httpd (no pid file) not running" - RUNNING=0 - fi - - if [ $RUNNING != "1" ]; then - ./httpserver.pl $HOSTPORT & - sleep 1 # give it a little time to start - else - echo $STATUS - - # verify that our server is one one running on this port: - data=`$CURL --silent -i $HOSTIP:$HOSTPORT/verifiedserver`; - - if { echo $data | grep -v "WE ROOLZ" >/dev/null 2>&1; } then - echo "Another HTTP server is running on port $HOSTPORT" - echo "Edit runtests.sh to use another port and rerun the test script" - exit - fi - - echo "The running HTTP server has been verified to be our test server" - - fi -} - -compare () { - # filter off the $4 pattern before compare! - - first="$1" - sec="$2" - text="$3" - strip="$4" - - if test -n "$strip"; then - egrep -v "$strip" < $first > $LOGDIR/generated.tmp - egrep -v "$strip" < $sec > $LOGDIR/stored.tmp - - first="$LOGDIR/generated.tmp" - sec="$LOGDIR/stored.tmp" - fi - - cmp $first $sec - if [ $? != "0" ]; then - echo " $text FAILED" - return 1 - else - echo " $text OK" - return 0 - fi -} - -singletest () -{ - NUMBER="$1" - - REPLY=data/reply$NUMBER.txt - CURLCMD=data/command$NUMBER.txt - HTTP=data/http$NUMBER.txt - DESC=`cat data/name$NUMBER.txt | tr -d '\012'` - - echo "test $NUMBER... [$DESC]" - - # get the command line options to use - cmd=`sed -e "s/%HOSTIP/$HOSTIP/g" \ - -e "s/%HOSTPORT/$HOSTPORT/g" \ - -e "s/%HOSTNAME/$HOSTNAME/g" <$CURLCMD ` - - # run curl - CMDLINE="$CURL -o $CURLOUT -i --silent $cmd" - - if test -n "$verbose"; then - echo "$CMDLINE" - fi - - # we do it the eval way to deal with quotes and similar stuff - eval $CMDLINE - - if [ $? != "0" ]; then - echo "Failed to invoke curl for test $NUMBER" - else - # when curl is done, the server has closed down as well - - # verify the received data - compare $CURLOUT $REPLY " fetch" - - if [ $? != "0" ]; then - exit; - fi - - # verify the sent request - compare $SERVERIN $HTTP " command" \ - "(User-Agent:|^--curl|Content-Type: multipart/form-data; boundary=)" - - # - # The strip pattern above is for stripping off User-Agent: since that'll - # be different in all versions, and the lines in a RFC1876-post that are - # randomly generated and therefore are doomed to always differ! - # - - - if [ $? != "0" ]; then - exit; - fi - fi - - return 0 -} - - -####################################################################### -# Check options to this test program -# - -if test "$1" = "-v"; then - verbose="1" -fi - -if test -n "$NEWSETUP"; then - - ####################################################################### - # Make sure the Host: lines are correct for this setup - # - - HOST="$HOSTIP:$HOSTPORT" - for test in data/http*.txt; do - sed -e "s/Host: \([0-9.:]*\)/Host: $HOST/g" < $test > $test.tmp - mv $test.tmp $test - done -fi - -####################################################################### -# Output curl version being tested -# -VERSION=`$CURL -V` -HOSTNAME=`hostname` - -echo "Running tests on:" -echo $VERSION -echo "host $HOSTNAME" - -####################################################################### -# remove and recreate logging directory: -# -rm -rf $LOGDIR -mkdir $LOGDIR - -####################################################################### -# First, start the TCP server -# - -runserver - -####################################################################### -# The main test-loop -# - -if [ x$TESTCASES = xall ]; then - TESTCASES=`ls -1 data/command*.txt | sed -e 's/[a-z\/\.]*//g'` -fi - -for NUMBER in $TESTCASES; do - - singletest $NUMBER - - # loop for next test -done - -####################################################################### -# Tests done, stop server -# - -stopserver |