-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.sh
executable file
·77 lines (72 loc) · 2.41 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
#!/bin/bash
require_rpaheui() {
if [ -z "${RPAHEUI}" ]; then
echo You need to set an '${RPAHEUI}' environment variable. >&2
exit 1
fi
}
case ${1} in
proto) AHEUI=$(dirname "$0")/proto;;
asm) require_rpaheui; AHEUI="${RPAHEUI}/aheui-c --no-c $(dirname "$0")/aheui.aheuis";;
aheui) require_rpaheui; AHEUI="${RPAHEUI}/aheui-c --no-c $(dirname "$0")/aheui.aheui";;
*) echo "Usage: $0 {proto|asm|aheui} [testname ...]" >&1; exit 1
esac
git submodule init
git submodule update
if [ ${2} ]; then
shift
ds=snippets/${*}
else
ds=snippets/*/
fi
success=0
fail=0
for d in $ds; do
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
#out=`$AHEUI $f < $d/$fbase.in`
out=`(cat $f <(echo -ne '\0') $d/$fbase.in) | $AHEUI`
else
#out=`$AHEUI $f`
out=`$AHEUI <$f`
fi
exitcode=$?
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 $(echo $out | cut -b -100)"
fi
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