blob: f1ffa3a8051382a71cd3b740b7f5786fdfd25fae (
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
|
#!/bin/sh
: ${CCQBE:=./cproc-qbe}
if [ $# = 0 ] ; then
set -- test/*.c
fi
numtest=0
numpass=0
numfail=0
fail=
got=$(mktemp)
trap 'rm "$got"' EXIT
for test ; do
name=${test%.c}
case $name in
*+*) arch=${name##*+} ;;
*) arch=x86_64-sysv ;;
esac
if [ -f "$name.qbe" ] ; then
want=$name.qbe
set -- $CCQBE -t $arch -o "$got" "$test"
elif [ -f "$name.pp" ] ; then
want=$name.pp
set -- $CCQBE -t $arch -E -o "$got" "$test"
else
echo "invalid test '$test'" >&2
set -- false
fi
numtest=$((numtest + 1))
if "$@" && diff -Nu "$want" "$got" ; then
result="PASS"
numpass=$((numpass + 1))
else
result="FAIL"
numfail=$((numfail + 1))
fail="$fail $test"
fi
echo "[$result] $test" >&2
done
printf "\n%d/%d tests passed\n" "$numpass" "$numtest"
if [ "$numfail" -gt 0 ] ; then
printf "%d test(s) failed (%s)\n" "$numfail" "${fail# }"
exit 1
fi
|