Blame | Letzte Änderung | Log anzeigen | RSS feed
#!/bin/bash## Name: testCases.sh# Version: $Id: testCases.sh,v 1.2 2006-10-29 12:09:41 lukasfeiler Exp $#printUsage(){echo "testCases.sh [-C] [-f FIRST_CASE] [-c CASES] [-u BASE_URL] [-L CASES_LOCATION]" >&2echo " -C Clean up old files first" >&2echo " -f FIRST_CASE Case number to start with; default is 1" >&2echo " -c CASES Number of cases; default is 5" >&2echo " -u BASE_URL The URL of the cases directory; default" >&2echo " is http://localhost/Query2XML/cases" >&2echo " -L CASES_LOCATION The path to all case directories; default" >&2echo " is ../cases." >&2echo "" >&2echo "This script tests all eight cases by running all of them and" >&2echo "comparing their output to the XML files in the specified" >&2echo 'case directory. $BASE_URL/case$i/case$i.php is requested for' >&2echo "this purpose." >&2}CASE_COUNT=8FIRST_CASE=1BASE_URL="http://localhost/Query2XML/cases"CASES_LOCATION="../cases"while getopts ":Cf:c:u:L:" opt; docase $opt inC ) CLEANUP=true ;;f ) FIRST_CASE=$OPTARGCASE_COUNT=1;;c ) CASE_COUNT=$OPTARG ;;u ) BASE_URL=$OPTARG ;;L ) CASES_LOCATION=$OPTARG ;;? ) printUsageexit 1 ;;esacdoneCASES_DIR=`(cd $CASES_LOCATION; pwd)`TMP_FILE=$CASES_DIR/test.tmpif [ "$CLEANUP" = "true" ] ; thenecho -n "Cleanung up ... "i=1while [ $i -lt $CASE_COUNT ] ; do[ $i -lt 10 ] && i="0$i"rm -f case$i.xmlrm -f case$i.xml.diffi=$((i + 1))doneecho OKfiif [ "`find . -maxdepth 1 -name 'case[0-9]*.*'`" != "" ] ; thenecho "The following old case[0-9]*.* files need to be removed first:"find . -name 'case[0-9]*.*'exit 1fii=$FIRST_CASEMAX=$(($FIRST_CASE + $CASE_COUNT))ERRORS=0while [ $i -lt $MAX ] ; do[ $i -lt 10 ] && i="0$i"echo -n "Testing Case $i... "wget -O case$i.xml $BASE_URL/case$i/case$i.php >$TMP_FILE 2>&1;ret=$?if [ $ret -ne 0 ] ; thenecho "Could not download $BASE_URL/case$i/case$i.php:"cat $TMP_FILErm -f $TMP_FILEexit 1firm -f $TMP_FILEecho "download OK"echo -n " diffing case$i.xml... "diff -u case$i.xml $CASES_DIR/case$i/case$i.xml > case$i.xml.diff 2>&1;ret=$?if [ $ret -eq 0 ] ; thenecho "OK"rm -f case$i.xml case$i.xml.diffelseecho "ERROR: diff returned $ret: see case$i.xml.diff"ERRORS=$((ERRORS + 1))fii=${i##0}i=$((i + 1))donerm -f $TMP_FILEecho -n "Summary: "if [ $ERRORS -eq 0 ] ; thenecho "all OK"elseecho "$ERRORS errors"fi