-
Notifications
You must be signed in to change notification settings - Fork 16
/
test.sh
executable file
·94 lines (88 loc) · 2.58 KB
/
test.sh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
if [ ! "$AHEUI" ]; then
echo "\$AHEUI must be set to run test"
echo "try: AHEUI=<binary> bash test.sh"
exit 1
fi
if [ ${1} ]; then
if [ $1 == --disable ]; then
ds=*/
mode='optout'
else
ds=${*}
mode='optin'
fi
else
ds=*/
mode='optout'
fi
echo "mode: $mode / targets: $ds"
success=0
fail=0
for d in $ds; do
check=''
if [ $mode == optout ]; then
for dx in ${*}; do
if [ $d == $dx ]; then
check=1
break
fi
if [ $d == $dx'/' ]; then
check=1
break
fi
done
fi
if [ $check ]; then
continue
fi
echo 'testset:' $d
for f in $d/*.aheui; do
fbase=`basename "$f" .aheui`
echo -n " test $fbase"...
if [ -e "$d/$fbase".out ]; then
if [ -e "$d/$fbase".in ]; then
$AHEUI $AHEUIFLAGS "$f" < "$d/$fbase.in" > .test.tmp
else
$AHEUI $AHEUIFLAGS "$f" > .test.tmp
fi
exitcode=$?
out=`cat .test.tmp`
if [ -e "$d/$fbase".exitcode ]; then
exitcodetest=1
exitcodedata=`cat "$d/$fbase".exitcode`
else
exitcodetest=0
fi
outdata=`cat "$d/$fbase".out`
if [ "$out" == "$outdata" ]; then
if [ "$exitcodetest" == 1 ]; then
if [ "$exitcode" == "$exitcodedata" ]; then
success=$(($success + 1))
echo -e "\x1B[92msuccess!\x1B[0m"
else
fail=$(($fail + 1))
echo -e "\x1B[91mfail!\x1B[0m"
echo -e " \x1B[92mexpected exitcode\x1B[0m $exitcodedata"
echo -e " \x1B[91mactual exitcode\x1B[0m $exitcode"
fi
else
success=$(($success + 1))
echo -e "\x1B[92msuccess!\x1B[0m"
fi
else
fail=$(($fail + 1))
echo -e "\x1B[91mfail!\x1B[0m"
echo -e " \x1B[92mexpected\x1B[0m $outdata"
echo -e " \x1B[91mactual\x1B[0m $out"
echo -e "diff from actual to expected"
diff -u .test.tmp "$d/$fbase.out"
fi
rm .test.tmp
else
echo -e '\x1B[93moutput not found\x1B[0m'
fi
done
done
echo -e "test status: $success/\x1B[92m$(($success + $fail))\x1B[0m"
exit $fail