From 3a12c94b738b654537a2cd830d6af668b6c74e9b Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Wed, 2 Mar 2016 22:11:50 -0500 Subject: start work on automating tests --- lisc/test/cup.ssa | 5 +++ lisc/test/go.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100755 lisc/test/go.sh (limited to 'lisc/test') diff --git a/lisc/test/cup.ssa b/lisc/test/cup.ssa index 3ffe198..96649e6 100644 --- a/lisc/test/cup.ssa +++ b/lisc/test/cup.ssa @@ -10,3 +10,8 @@ function $test() { @end ret } + +# >>> driver +# extern void test(); +# int main() { test(); return 0; } +# <<< diff --git a/lisc/test/go.sh b/lisc/test/go.sh new file mode 100755 index 0000000..b65f2d2 --- /dev/null +++ b/lisc/test/go.sh @@ -0,0 +1,96 @@ +#!/bin/sh + +QBE=./lisc +CC=cc + +TMP=/tmp/qbe.zzzz + +DRV=$TMP.c +ASM=$TMP.s +BIN=$TMP.bin +OUT=$TMP.out + +cleanup() { + rm -f $DRV $ASM $BIN $OUT +} + +extract() { + WHAT="$1" + FILE="$2" + + awk " + /^# >>> $WHAT/ { + p = 1 + next + } + /^# <<&2 + exit 1 + fi + + printf "$T... " + + if ! $QBE $T -o $ASM 2> /dev/null + then + echo "[qbe fail]" + return 1 + fi + + extract driver $T > $DRV + extract output $T > $OUT + + if test -s $DRV + then + LNK="$DRV $ASM" + else + LNK="$ASM" + fi + + if ! $CC -o $BIN $LNK + then + echo "[cc fail]" + return 1 + fi + + echo "[ok]" +} + + +#trap cleanup TERM QUIT + +case $1 in + "all") + F=0 + for T in test/* + do + once $T + F=`expr $F + $?` + done + if test $F -ge 1 + then + echo + echo "$F test(s) failed!" + else + echo + echo "All is fine!" + fi + ;; + *) + once $1 + exit $? + ;; +esac -- cgit 1.4.1