aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression/Runtest
blob: f693219af4342f1a4e5dfc8e6e42ba927360325c (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
70
71
#!/bin/sh

# The name of the test
name="$1"
shift

# The temp file for output
out="test$$.log"
rm -f $out
trap "rm -f $out" 0 INT QUIT

# Is the test expected to fail?
expect_fail=false

# The architecture and the bitsize
arch=`sed -n -e 's/^ARCH=//p' ../../Makefile.config`
bits=`sed -n -e 's/^BITSIZE=//p' ../../Makefile.config`

# The reference output
if test -f "Results/$name-$arch-$bits"; then
  ref="Results/$name-$arch-$bits"
elif test -f "Results/$name-$arch"; then
  ref="Results/$name-$arch"
elif test -f "Results/$name-$bits"; then
  ref="Results/$name-$bits"
elif test -f "Results/$name"; then
  ref="Results/$name"
else
  ref=""
fi

# Special conditions

if test -f "$name.cond"; then
  RUN=0 SKIP=1 EXPECT_FAIL=2 sh "$name.cond"
  case "$?" in
    1) echo "$name: skipped"; exit 0;;
    2) expect_fail=true;;
  esac
fi

# Administer the test
if $SIMU $* > $out
then
  if $expect_fail; then
    echo "$name: ERROR (should have failed but did not)"
    exit 2
  elif test -n "$ref"; then
    if cmp -s "$out" "$ref"; then
      echo "$name: passed"
      exit 0
    else
      echo "$name: WRONG OUTPUT (diff follows)"
      diff -u "$ref" "$out"
      exit 2
    fi
  else
    echo "$name: passed"
    exit 0
  fi
else
  retcode=$?
  if $expect_fail; then
    echo "$name: passed (failed as expected)"
    exit 0
  else
    echo "$name: EXECUTION FAILED (status $retcode)"
    exit 2
  fi
fi