]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tests/TESTrun.sh
test scripts overhaul
[tcpdump] / tests / TESTrun.sh
index d1baaa7be6039c184a4353713a6c6bda8da82404..a22260e30dfb1a432317bd2b40b2879ee24dfb3d 100755 (executable)
@@ -4,59 +4,66 @@ mkdir -p NEW
 mkdir -p DIFF
 passed=0
 failed=0
+INDENT='    '
 cat /dev/null > failure-outputs.txt
 
-# first run any specific tests.
-for i in *.sh
-do
-  case $i in TEST*.sh) continue;; esac
-
-  if sh ./$i >DIFF/$i.result
-  then
-      echo $i: passed.
-      rm -f DIFF/$i.result
+runComplexTests()
+{
+  for i in *.sh
+  do
+    case $i in TEST*.sh) continue;; esac
+    echo -n "$INDENT"
+    if sh ./$i
+    then
       passed=`expr $passed + 1`
-  else
-      echo $i: failed.
+    else
       failed=`expr $failed + 1`
-  fi          
-done 
-
-echo $passed >.passed
-echo $failed >.failed
+    fi
+  done
+}
 
-# now run typical tests
-cat TESTLIST | while read name input output options
-do
-  case $name in
+runSimpleTests()
+{
+  local only=$1
+  echo $passed >.passed
+  echo $failed >.failed
+  cat TESTLIST | while read name input output options
+  do
+    case $name in
       \#*) continue;;
       '') continue;;
-  esac
-
-  if ./TESTonce $name $input $output "$options"
-  then
-      echo $name: passed.
-      rm -f DIFF/$output.diff
+    esac
+    [ "$only" != "" -a "$name" != "$only" ] && continue
+    echo -n "$INDENT"
+    if ./TESTonce $name $input $output "$options"
+    then
       passed=`expr $passed + 1`
       echo $passed >.passed
-  else
-      echo $name: failed.
+    else
       failed=`expr $failed + 1`
       echo $failed >.failed
-      echo "Failed test: $name" >> failure-outputs.txt
-      echo >> failure-outputs.txt
-      cat DIFF/$output.diff >> failure-outputs.txt
-      echo >> failure-outputs.txt
-  fi
-done 
+    fi
+    [ "$only" != "" -a "$name" == "$only" ] && break
+  done
+  # I hate shells with their stupid, useless subshells.
+  passed=`cat .passed`
+  failed=`cat .failed`
+}
 
-# I hate shells with their stupid, useless subshells.
-passed=`cat .passed`
-failed=`cat .failed`
+if [ $# -eq 0 ]
+then
+  runComplexTests
+  runSimpleTests
+elif [ $# -eq 1 ]
+then
+  runSimpleTests $1
+else
+  echo "Usage: $0 [test_name]"
+  exit 30
+fi
 
 # exit with number of failing tests.
-echo 
-echo
+echo '------------------------------------------------'
 printf "%4u tests failed\n" $failed
 printf "%4u tests passed\n" $passed
 echo
@@ -64,8 +71,4 @@ echo
 cat failure-outputs.txt
 echo
 echo
-exit $failed      
-
-
-
-
+exit $failed