run-tests 1.01 KB
Newer Older
Pontus Freyhult's avatar
Pontus Freyhult committed
1
#! /bin/sh
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

failed=0
all=0

if [ -z "$srcdir" ] ; then
  srcdir=`pwd`
fi

export srcdir

find_program () {
  if [ -x "$1" ] ; then
    echo "./$1"
  else
    echo "$srcdir/$1"
  fi
}

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

test_program () {
30
  testname=`echo "$1" | sed -e 's,-test$,,' -e 's,^\./,,`
31
32
33
  "$1"
  case "$?" in
      0)
Pontus Freyhult's avatar
Pontus Freyhult committed
34
    	echo PASS: $testname
35
36
37
	all=`expr $all + 1`
	;;
      77)
Pontus Freyhult's avatar
Pontus Freyhult committed
38
      	echo SKIP: $testname
39
40
      ;;
      *)
Pontus Freyhult's avatar
Pontus Freyhult committed
41
    	echo FAIL: $testname
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
	failed=`expr $failed + 1`
	all=`expr $all + 1`
	;;
  esac
}

env_program `find_program setup-env`

if [ $# -eq 0 ] ; then
  for f in *-test; do test_program "./$f"; done
else
  for f in "$@" ; do test_program `find_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 `find_program teardown-env`

[ "$failed" -eq 0 ]