run-tests 824 Bytes
Newer Older
1
#! /bin/sh
Niels Möller's avatar
Niels Möller committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15

failed=0
all=0

env_program () {
  if [ -x ./"$1" ] ; then
    if ./"$1"; then : ; else
      echo FAIL: $1
      exit 1
    fi
  fi
}

test_program () {
16
  "./$1"
17
  testname=`echo "$1" | sed -e 's/-test//'`
18
19
  case "$?" in
      0)
20
    	echo PASS: $testname
21
22
23
	all=`expr $all + 1`
	;;
      77)
24
      	echo SKIP: $testname
25
26
      ;;
      *)
27
    	echo FAIL: $testname
28
29
30
31
	failed=`expr $failed + 1`
	all=`expr $all + 1`
	;;
  esac
Niels Möller's avatar
Niels Möller committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
}

env_program setup-env

if [ $# -eq 0 ] ; then
  for f in *-test; do test_program "$f"; done
else
  for f in "$@" ; do test_program "$f"; done
fi

if [ $failed -eq 0 ] ; then
  banner="All $all tests passed"
else
  banner="$failed of $all tests failed"
fi
dashes=`echo "$banner" | sed s/./=/g`
echo "$dashes"
echo "$banner"
echo "$dashes"

env_program teardown-env

[ "$failed" -eq 0 ]