From 74e86763c680f98234b27267d21a2696603cb457 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sun, 11 Aug 2019 19:46:24 +1200 Subject: Add new tests --- test/asm/run-asm.sh | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'test/asm/run-asm.sh') diff --git a/test/asm/run-asm.sh b/test/asm/run-asm.sh index 7574abb..2fc4ba3 100755 --- a/test/asm/run-asm.sh +++ b/test/asm/run-asm.sh @@ -30,6 +30,43 @@ export ASM="$PWD/../../assembler" export DISASM="$PWD/../../disassembler" has_failure=0 +test_should_fail() { + local t="$1" + local xc="$2" + if (( xc > 0 && xc < 128 )); then + pass "$t" "assembly xfailed" + elif (( xc == 0 )); then + fail "$t" "assembly didn't fail as expected" + else + fail "$t" "assembler was sent signal $(( xc - 128 ))" + fi +} + +test_should_pass() { + local t="$1" + local xc="$2" + if (( xc == 0 )); then + pass "$t" + else + fail "$t" "assembly failed" + fi +} + +echo "Should pass:" +for first_stage_asm in should-pass/*.asm ; do + t=$(basename "$first_stage_asm") + first_stage_bin="$WORK/${t}-first_stage.bin" + log="$WORK/${t}.log" + + # Assemble test code + set +e + $VALGRIND $VALGRIND_OPTS "$ASM" "$first_stage_asm" "$first_stage_bin" 2>"$log" + xc="$?" + set -e + test_should_pass "$t" "$xc" +done + +echo "Should fail (pass means asm failed as expected):" for first_stage_asm in should-fail/*.asm ; do t=$(basename "$first_stage_asm") first_stage_bin="$WORK/${t}-first_stage.bin" @@ -40,13 +77,7 @@ for first_stage_asm in should-fail/*.asm ; do $VALGRIND $VALGRIND_OPTS "$ASM" "$first_stage_asm" "$first_stage_bin" 2>"$log" xc="$?" set -e - if (( xc > 0 && xc < 128 )); then - pass "$t" "assembly xfailed" - elif (( xc == 0 )); then - fail "$t" "assembly didn't fail as expected" - else - fail "$t" "assembler was sent signal $(( xc - 128 ))" - fi + test_should_fail "$t" "$xc" done popd >/dev/null -- cgit v1.1