Regression test driver now can read different expected output files
[cacao.git] / tests / regression / Test.sh
1 #!/bin/sh
2
3 JAVA=$1
4 TEST=$2
5 SRCDIR=$3
6
7 #
8 # test which classlibrary was used
9 # depending on whether classpath or openjdk class library was used we may expect different results from the tests, this may e.g.
10 # by simple things like intentation when printing stack traces or even more subtile stuff ...
11 #
12 $JAVA -XX:+PrintConfig 2>&1 | grep gnu.classpath.boot.library.path: > /dev/null
13 if [ $? -eq "0" ]; then
14 IS_CLASSPATH=1
15 POSTFIX="cp"
16 fi
17 $JAVA -XX:+PrintConfig 2>&1 | grep sun.boot.library.path  > /dev/null
18 if [ $? -eq "0" ]; then
19 IS_OPENJDK=1
20 POSTFIX="ojdk"
21 fi
22
23 if [ -z $POSTFIX ]; then
24 echo "Warning: Could not detect classlibrary the java VM uses, assuming openJDK"
25 POSTFIX="ojdk"
26 fi
27
28 # mostly classpath and openjdk deliver same results
29 REFERENCE_OUTPUT=$SRCDIR/$TEST.output
30 REFERENCE_2OUTPUT=$SRCDIR/$TEST.2output
31
32 # if they do not exist, we try the postfixed versions
33 if [ ! -f $REFERENCE_OUTPUT ]; then
34 REFERENCE_OUTPUT=$SRCDIR/$TEST.output.$POSTFIX
35 fi
36 if [ ! -f $REFERENCE_2OUTPUT ]; then
37 REFERENCE_2OUTPUT=$SRCDIR/$TEST.2output.$POSTFIX
38 fi
39
40 echo -n "$TEST: "
41
42 $JAVA $TEST > $TEST.thisoutput 2>&1
43
44 if [ $? -eq "0" ]; then
45     # no Error returned
46     if [ -f $REFERENCE_2OUTPUT ]; then
47         # Error should have been returned
48         echo "OK, but wrong return value: $?"
49         head $TEST.thisoutput
50         exit
51     fi
52         
53     cmp -s $REFERENCE_OUTPUT $TEST.thisoutput
54
55     if [ $? -eq "0" ]; then
56         echo "OK"
57     else
58         echo "FAILED"
59         diff -u $REFERENCE_OUTPUT $TEST.thisoutput
60     fi
61
62 else
63     # Error returned
64     if [ ! -f $REFERENCE_2OUTPUT ]; then
65         # No Error should have been returned
66         echo "FAILED, but wrong return value: $?"
67         head $TEST.this2output
68         exit
69     fi
70
71     cmp -s $REFERENCE_2OUTPUT $TEST.thisoutput
72
73     if [ $? -eq "0" ]; then
74         echo "OK"
75     else
76         echo "FAILED"
77         diff -u $REFERENCE_2OUTPUT $TEST.thisoutput
78     fi
79 fi              
80
81 rm -f $TEST.thisoutput