summaryrefslogtreecommitdiff
path: root/tests/TESTrun.sh
blob: 6449082448d17988ccef57c597030ba27101f00c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

mkdir -p NEW
mkdir -p DIFF
passed=0
failed=0
cat /dev/null > failure-outputs.txt

runComplexTests()
{
  for i in *.sh
  do
    case $i in TEST*.sh) continue;; esac
    sh ./$i
  done
}

runSimpleTests()
{
  passed=`cat .passed`
  failed=`cat .failed`
  only=$1
  cat TESTLIST | while read name input output options
  do
    case $name in
      \#*) continue;;
      '') continue;;
    esac
    rm -f core
    [ "$only" != "" -a "$name" != "$only" ] && continue
    if ./TESTonce $name $input $output "$options"
    then
      passed=`expr $passed + 1`
      echo $passed >.passed
    else
      failed=`expr $failed + 1`
      echo $failed >.failed
    fi
    [ "$only" != "" -a "$name" = "$only" ] && break
  done
  # I hate shells with their stupid, useless subshells.
  passed=`cat .passed`
  failed=`cat .failed`
}

echo $passed >.passed
echo $failed >.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 '------------------------------------------------'
printf "%4u tests failed\n" $failed
printf "%4u tests passed\n" $passed
echo
echo
cat failure-outputs.txt
echo
echo
exit $failed