summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/asm/run-asm.sh45
-rw-r--r--test/asm/should-fail/005-open-comment.asm3
-rw-r--r--test/asm/should-pass/001-empty.asm0
-rw-r--r--test/asm/should-pass/002-eol.asm1
-rw-r--r--test/asm/should-pass/003-comment.asm1
-rw-r--r--test/asm/should-pass/004-comment-2.asm8
-rw-r--r--test/asm/should-pass/005-comment-mix.asm7
7 files changed, 58 insertions, 7 deletions
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
diff --git a/test/asm/should-fail/005-open-comment.asm b/test/asm/should-fail/005-open-comment.asm
new file mode 100644
index 0000000..d4ebc0a
--- /dev/null
+++ b/test/asm/should-fail/005-open-comment.asm
@@ -0,0 +1,3 @@
+nop
+/*
+addi $0, $0, 0
diff --git a/test/asm/should-pass/001-empty.asm b/test/asm/should-pass/001-empty.asm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/asm/should-pass/001-empty.asm
diff --git a/test/asm/should-pass/002-eol.asm b/test/asm/should-pass/002-eol.asm
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/test/asm/should-pass/002-eol.asm
@@ -0,0 +1 @@
+
diff --git a/test/asm/should-pass/003-comment.asm b/test/asm/should-pass/003-comment.asm
new file mode 100644
index 0000000..092bc2b
--- /dev/null
+++ b/test/asm/should-pass/003-comment.asm
@@ -0,0 +1 @@
+;
diff --git a/test/asm/should-pass/004-comment-2.asm b/test/asm/should-pass/004-comment-2.asm
new file mode 100644
index 0000000..3e81d51
--- /dev/null
+++ b/test/asm/should-pass/004-comment-2.asm
@@ -0,0 +1,8 @@
+/**/
+;
+/* */
+/*
+asdf
+*/
+# foo fou #
+! fa foo
diff --git a/test/asm/should-pass/005-comment-mix.asm b/test/asm/should-pass/005-comment-mix.asm
new file mode 100644
index 0000000..01d1e65
--- /dev/null
+++ b/test/asm/should-pass/005-comment-mix.asm
@@ -0,0 +1,7 @@
+nop ; test
+nop;
+nop # test
+ldi $0, 123 // asdf
+//asdf
+/* */ nop
+jmp $0 ! foo