From b75cb8388fb9b5f2393443d008bb46c522c5ec9b Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Mon, 28 Mar 2016 12:53:53 -0400 Subject: new layout, put LICENSE in root --- tools/abifuzz.sh | 2 +- tools/fptox.c | 18 --------- tools/pmov.c | 2 +- tools/regress.sh | 17 -------- tools/unit.sh | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 37 deletions(-) delete mode 100644 tools/fptox.c delete mode 100755 tools/regress.sh create mode 100755 tools/unit.sh (limited to 'tools') diff --git a/tools/abifuzz.sh b/tools/abifuzz.sh index 57930fb..e715b3d 100755 --- a/tools/abifuzz.sh +++ b/tools/abifuzz.sh @@ -2,7 +2,7 @@ OCAMLC=${OCAMLC:-/usr/bin/ocamlc} DIR=`cd $(dirname "$0"); pwd` -QBE=$DIR/../src/qbe +QBE=$DIR/../obj/qbe failure() { echo "Failure at stage:" $1 >&2 diff --git a/tools/fptox.c b/tools/fptox.c deleted file mode 100644 index a2bc155..0000000 --- a/tools/fptox.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -int -main(int ac, char *av[]) -{ - double d; - float f; - - if (ac < 2) { - usage: - fputs("usage: fptox NUMBER\n", stderr); - return 1; - } - f = d = strtod(av[1], 0); - printf("0x%08x 0x%016llx\n", *(unsigned *)&f, *(unsigned long long*)&d); - return 0; -} diff --git a/tools/pmov.c b/tools/pmov.c index 9136374..62d3921 100644 --- a/tools/pmov.c +++ b/tools/pmov.c @@ -13,7 +13,7 @@ static void assert_test(char *, int), fail(void), iexec(int *); -#include "../src/rega.c" +#include "../../rega.c" static void bsinit_(BSet *, uint); diff --git a/tools/regress.sh b/tools/regress.sh deleted file mode 100755 index 5aaea35..0000000 --- a/tools/regress.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -for t in ../test/* -do - printf "Test $t ... " - - ./qbe $t >/tmp/out.0 2>&1 - ./qbe.1 $t >/tmp/out.1 2>&1 - - if diff /tmp/out.0 /tmp/out.1 > /dev/null - then - echo "OK" - else - echo "KO" - break - fi -done diff --git a/tools/unit.sh b/tools/unit.sh new file mode 100755 index 0000000..c4a85d2 --- /dev/null +++ b/tools/unit.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +DIR=`cd $(dirname "$0"); pwd` +QBE=$DIR/../obj/qbe + +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 + + echo "$(basename $T)..." + + if ! $QBE -o $ASM $T + 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 -g -o $BIN $LNK + then + echo "[cc fail]" + return 1 + fi + + if test -s $OUT + then + $BIN a b c | diff - $OUT + RET=$? + REASON="output" + else + $BIN a b c + RET=$? + REASON="returned $RET" + fi + + if test $RET -ne 0 + then + echo "[$REASON fail]" + return 1 + fi + + printf "\033[1A\033[45C[ok]\n" +} + + +#trap cleanup TERM QUIT + +if test -z "$1" +then + echo "usage: test/go.sh {all, SSAFILE}" 2>&1 + exit 1 +fi + +case $1 in + "all") + F=0 + for T in $DIR/../test/[!_]*.ssa + 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