From f4a22707b559913b66be95e50f20a9cf8d1ef978 Mon Sep 17 00:00:00 2001 From: Jeroen Venema Date: Sun, 25 Feb 2024 15:02:50 +0100 Subject: [PATCH] Added several tests --- test.sh | 3 +- tests/Conditional_asm/test.output | 1 + tests/Conditional_asm/test.sh | 34 +++++++ .../tests/basic_ifelse.s} | 16 ++-- tests/Errors_labels/test.sh | 8 +- tests/Errors_literals/test copy.sh | 34 +++++++ tests/Errors_literals/test.output | 2 +- tests/Errors_literals/test.sh | 8 +- tests/Errors_macros/test.sh | 8 +- tests/Errors_opcodes/test.sh | 8 +- tests/Errors_registers/test.sh | 8 +- tests/Errors_strings/test.sh | 8 +- tests/Errors_value_operators/test copy.sh | 34 +++++++ tests/Errors_value_operators/test.output | 3 + tests/Errors_value_operators/test.sh | 34 +++++++ .../tests/illegal_shift_left.s | 1 + .../tests/illegal_shift_right.s | 1 + tests/Labels/test.output | 1 + tests/Labels/test.sh | 34 +++++++ tests/Labels/tests/back_reference.s | 6 ++ tests/Labels/tests/basic_label.s | 1 + .../Labels/tests/basic_label_single_opcode.s | 1 + .../tests/basic_label_single_opcode_spaced.s | 1 + tests/Labels/tests/basic_label_with_comment.s | 1 + .../tests/basic_label_with_spaced_comment.s | 1 + tests/Labels/tests/forward_reference.s | 6 ++ tests/{jumps/test.s => Labels/tests/jumps.s} | 32 +++---- .../tests/labels_using_cc_strings.s} | 32 +++---- .../test.s => Labels/tests/local_labels.s} | 86 +++++++++--------- .../tests/value_definitions.s} | 0 tests/Value_operators/test.output | 1 + tests/Value_operators/test.sh | 34 +++++++ tests/Value_operators/tests/operator_and.s | 1 + tests/Value_operators/tests/operator_div.s | 1 + tests/Value_operators/tests/operator_min.s | 1 + tests/Value_operators/tests/operator_or.s | 1 + tests/Value_operators/tests/operator_plus.s | 1 + tests/Value_operators/tests/operator_shleft.s | 1 + .../Value_operators/tests/operator_shright.s | 1 + tests/Value_operators/tests/operator_times.s | 1 + tests/Value_operators/tests/operator_xor.s | 1 + .../tests/unary_operator_min.s | 1 + .../tests/unary_operator_not.s | 1 + .../tests/unary_operator_plus.s | 1 + tests/advancedlabels/asm.output | 5 - tests/advancedlabels/reference-manual.bat | 13 --- tests/advancedlabels/reference.bin | Bin 83 -> 0 bytes tests/advancedlabels/reftest.s | 45 --------- tests/advancedlabels/test.bin | Bin 83 -> 0 bytes tests/advancedlabels/test.output | 3 - tests/advancedlabels/test.sh | 36 -------- tests/basiclabels/asm.output | 5 - tests/basiclabels/test.bin | 0 tests/basiclabels/test.output | 1 - tests/basiclabels/test.s | 3 - tests/basiclabels/test.sh | 36 -------- tests/basiclabels_cc/asm.output | 5 - tests/basiclabels_cc/test.bin | 0 tests/basiclabels_cc/test.output | 1 - tests/basiclabels_cc/test.sh | 36 -------- tests/conditional/asm.output | 5 - tests/conditional/reference.bin | 1 - tests/conditional/test.bin | 1 - tests/conditional/test.output | 3 - tests/conditional/test.sh | 36 -------- tests/definitions/asm.output | 5 - tests/definitions/reference.bat | 12 --- tests/definitions/reference.bin | 2 - tests/definitions/test.bin | 2 - tests/definitions/test.output | 3 - tests/definitions/test.sh | 36 -------- tests/jumps/asm.output | 5 - tests/jumps/reference.bat | 12 --- tests/jumps/reference.bin | Bin 32 -> 0 bytes tests/jumps/test.bin | Bin 32 -> 0 bytes tests/jumps/test.output | 3 - tests/jumps/test.sh | 36 -------- tests/jumps/testn.bin | 1 - tests/jumps/testn.s | 2 - tests/template_tests/test.output | 1 + tests/template_tests/test.sh | 34 +++++++ 81 files changed, 386 insertions(+), 463 deletions(-) create mode 100644 tests/Conditional_asm/test.output create mode 100644 tests/Conditional_asm/test.sh rename tests/{conditional/test.s => Conditional_asm/tests/basic_ifelse.s} (87%) create mode 100644 tests/Errors_literals/test copy.sh create mode 100644 tests/Errors_value_operators/test copy.sh create mode 100644 tests/Errors_value_operators/test.output create mode 100644 tests/Errors_value_operators/test.sh create mode 100644 tests/Errors_value_operators/tests/illegal_shift_left.s create mode 100644 tests/Errors_value_operators/tests/illegal_shift_right.s create mode 100644 tests/Labels/test.output create mode 100644 tests/Labels/test.sh create mode 100644 tests/Labels/tests/back_reference.s create mode 100644 tests/Labels/tests/basic_label.s create mode 100644 tests/Labels/tests/basic_label_single_opcode.s create mode 100644 tests/Labels/tests/basic_label_single_opcode_spaced.s create mode 100644 tests/Labels/tests/basic_label_with_comment.s create mode 100644 tests/Labels/tests/basic_label_with_spaced_comment.s create mode 100644 tests/Labels/tests/forward_reference.s rename tests/{jumps/test.s => Labels/tests/jumps.s} (94%) rename tests/{basiclabels_cc/test.s => Labels/tests/labels_using_cc_strings.s} (90%) rename tests/{advancedlabels/test.s => Labels/tests/local_labels.s} (94%) rename tests/{definitions/test.s => Labels/tests/value_definitions.s} (100%) create mode 100644 tests/Value_operators/test.output create mode 100644 tests/Value_operators/test.sh create mode 100644 tests/Value_operators/tests/operator_and.s create mode 100644 tests/Value_operators/tests/operator_div.s create mode 100644 tests/Value_operators/tests/operator_min.s create mode 100644 tests/Value_operators/tests/operator_or.s create mode 100644 tests/Value_operators/tests/operator_plus.s create mode 100644 tests/Value_operators/tests/operator_shleft.s create mode 100644 tests/Value_operators/tests/operator_shright.s create mode 100644 tests/Value_operators/tests/operator_times.s create mode 100644 tests/Value_operators/tests/operator_xor.s create mode 100644 tests/Value_operators/tests/unary_operator_min.s create mode 100644 tests/Value_operators/tests/unary_operator_not.s create mode 100644 tests/Value_operators/tests/unary_operator_plus.s delete mode 100644 tests/advancedlabels/asm.output delete mode 100644 tests/advancedlabels/reference-manual.bat delete mode 100644 tests/advancedlabels/reference.bin delete mode 100644 tests/advancedlabels/reftest.s delete mode 100644 tests/advancedlabels/test.bin delete mode 100644 tests/advancedlabels/test.output delete mode 100644 tests/advancedlabels/test.sh delete mode 100644 tests/basiclabels/asm.output delete mode 100644 tests/basiclabels/test.bin delete mode 100644 tests/basiclabels/test.output delete mode 100644 tests/basiclabels/test.s delete mode 100644 tests/basiclabels/test.sh delete mode 100644 tests/basiclabels_cc/asm.output delete mode 100644 tests/basiclabels_cc/test.bin delete mode 100644 tests/basiclabels_cc/test.output delete mode 100644 tests/basiclabels_cc/test.sh delete mode 100644 tests/conditional/asm.output delete mode 100644 tests/conditional/reference.bin delete mode 100644 tests/conditional/test.bin delete mode 100644 tests/conditional/test.output delete mode 100644 tests/conditional/test.sh delete mode 100644 tests/definitions/asm.output delete mode 100644 tests/definitions/reference.bat delete mode 100644 tests/definitions/reference.bin delete mode 100644 tests/definitions/test.bin delete mode 100644 tests/definitions/test.output delete mode 100644 tests/definitions/test.sh delete mode 100644 tests/jumps/asm.output delete mode 100644 tests/jumps/reference.bat delete mode 100644 tests/jumps/reference.bin delete mode 100644 tests/jumps/test.bin delete mode 100644 tests/jumps/test.output delete mode 100644 tests/jumps/test.sh delete mode 100644 tests/jumps/testn.bin delete mode 100644 tests/jumps/testn.s create mode 100644 tests/template_tests/test.output create mode 100644 tests/template_tests/test.sh diff --git a/test.sh b/test.sh index 3d4a552..dbe82b1 100644 --- a/test.sh +++ b/test.sh @@ -14,10 +14,11 @@ for FILE in *; do cd "$FILE" printf $FORMAT $FILE if [ -f "test.sh" ]; then + test_number=0 ./test.sh > ./test.output testresult=$? if [ $testresult -eq 1 ]; then - echo -e "${RED}FAIL${NOCOLOR}" + echo -e " ${RED}FAIL${NOCOLOR}" failed=$((failed+1)) else if [ $testresult -eq 2 ]; then diff --git a/tests/Conditional_asm/test.output b/tests/Conditional_asm/test.output new file mode 100644 index 0000000..5f2174d --- /dev/null +++ b/tests/Conditional_asm/test.output @@ -0,0 +1 @@ +All (1) files assembled succesfully diff --git a/tests/Conditional_asm/test.sh b/tests/Conditional_asm/test.sh new file mode 100644 index 0000000..d339798 --- /dev/null +++ b/tests/Conditional_asm/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Positive test - assembler needs to pass all tests in all subfolders +# return 0 on succesfull tests (all passed) +# return 1 on issue during test (one or more tests didn't pass correctly) +# return 2 on error in test SETUP +# + +test_number=0 +tests_successfull=0 + +cd tests +rm -f *.bin +for FILE in *; do + if [ -f "$FILE" ]; then + test_number=$((test_number+1)) + ../$ASMBIN $FILE -b FF > ../asm.output + if [ $? -eq 1 ]; then + echo "Error in" \'$FILE\' + else + tests_successfull=$((tests_successfull+1)) + fi + fi +done +rm -f *.bin +cd .. + +rm -f asm.output +if [ $test_number -eq $tests_successfull ]; then + echo "All ($test_number) files assembled succesfully" + exit 0 +else + exit 1 +fi +exit 0 diff --git a/tests/conditional/test.s b/tests/Conditional_asm/tests/basic_ifelse.s similarity index 87% rename from tests/conditional/test.s rename to tests/Conditional_asm/tests/basic_ifelse.s index 5f1a082..faaf30d 100644 --- a/tests/conditional/test.s +++ b/tests/Conditional_asm/tests/basic_ifelse.s @@ -1,8 +1,8 @@ -TEST: EQU 1 - -.if TEST - ld a,1 -.else - ld a,2 -.endif - +TEST: EQU 1 + +.if TEST + ld a,1 +.else + ld a,2 +.endif + diff --git a/tests/Errors_labels/test.sh b/tests/Errors_labels/test.sh index d59426e..6dc4bc7 100644 --- a/tests/Errors_labels/test.sh +++ b/tests/Errors_labels/test.sh @@ -5,14 +5,14 @@ # return 2 on error in test SETUP # -negtest_number=0 +test_number=0 negtest_failed_successfull=0 cd tests rm -f *.bin for FILE in *; do if [ -f "$FILE" ]; then - negtest_number=$((negtest_number+1)) + test_number=$((test_number+1)) ../$ASMBIN $FILE -b FF > ../asm.output if [ $? -eq 0 ]; then echo "Failed to detect error in" \'$FILE\' @@ -25,8 +25,8 @@ rm -f *.bin cd .. rm -f asm.output -if [ $negtest_number -eq $negtest_failed_successfull ]; then - echo "Detected all errors succesfully" +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" exit 0 else exit 1 diff --git a/tests/Errors_literals/test copy.sh b/tests/Errors_literals/test copy.sh new file mode 100644 index 0000000..6dc4bc7 --- /dev/null +++ b/tests/Errors_literals/test copy.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Negative test - assembler needs to fail tests in all subfolders +# return 0 on succesfull test (all failed) +# return 1 on issue during test (one or more tests didn't fail correctly) +# return 2 on error in test SETUP +# + +test_number=0 +negtest_failed_successfull=0 + +cd tests +rm -f *.bin +for FILE in *; do + if [ -f "$FILE" ]; then + test_number=$((test_number+1)) + ../$ASMBIN $FILE -b FF > ../asm.output + if [ $? -eq 0 ]; then + echo "Failed to detect error in" \'$FILE\' + else + negtest_failed_successfull=$((negtest_failed_successfull+1)) + fi + fi +done +rm -f *.bin +cd .. + +rm -f asm.output +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" + exit 0 +else + exit 1 +fi +exit 0 diff --git a/tests/Errors_literals/test.output b/tests/Errors_literals/test.output index 8ab05f9..7e3a2d5 100644 --- a/tests/Errors_literals/test.output +++ b/tests/Errors_literals/test.output @@ -1 +1 @@ -Detected all errors succesfully +Detected all (5) errors succesfully diff --git a/tests/Errors_literals/test.sh b/tests/Errors_literals/test.sh index d59426e..6dc4bc7 100644 --- a/tests/Errors_literals/test.sh +++ b/tests/Errors_literals/test.sh @@ -5,14 +5,14 @@ # return 2 on error in test SETUP # -negtest_number=0 +test_number=0 negtest_failed_successfull=0 cd tests rm -f *.bin for FILE in *; do if [ -f "$FILE" ]; then - negtest_number=$((negtest_number+1)) + test_number=$((test_number+1)) ../$ASMBIN $FILE -b FF > ../asm.output if [ $? -eq 0 ]; then echo "Failed to detect error in" \'$FILE\' @@ -25,8 +25,8 @@ rm -f *.bin cd .. rm -f asm.output -if [ $negtest_number -eq $negtest_failed_successfull ]; then - echo "Detected all errors succesfully" +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" exit 0 else exit 1 diff --git a/tests/Errors_macros/test.sh b/tests/Errors_macros/test.sh index d59426e..6dc4bc7 100644 --- a/tests/Errors_macros/test.sh +++ b/tests/Errors_macros/test.sh @@ -5,14 +5,14 @@ # return 2 on error in test SETUP # -negtest_number=0 +test_number=0 negtest_failed_successfull=0 cd tests rm -f *.bin for FILE in *; do if [ -f "$FILE" ]; then - negtest_number=$((negtest_number+1)) + test_number=$((test_number+1)) ../$ASMBIN $FILE -b FF > ../asm.output if [ $? -eq 0 ]; then echo "Failed to detect error in" \'$FILE\' @@ -25,8 +25,8 @@ rm -f *.bin cd .. rm -f asm.output -if [ $negtest_number -eq $negtest_failed_successfull ]; then - echo "Detected all errors succesfully" +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" exit 0 else exit 1 diff --git a/tests/Errors_opcodes/test.sh b/tests/Errors_opcodes/test.sh index d59426e..6dc4bc7 100644 --- a/tests/Errors_opcodes/test.sh +++ b/tests/Errors_opcodes/test.sh @@ -5,14 +5,14 @@ # return 2 on error in test SETUP # -negtest_number=0 +test_number=0 negtest_failed_successfull=0 cd tests rm -f *.bin for FILE in *; do if [ -f "$FILE" ]; then - negtest_number=$((negtest_number+1)) + test_number=$((test_number+1)) ../$ASMBIN $FILE -b FF > ../asm.output if [ $? -eq 0 ]; then echo "Failed to detect error in" \'$FILE\' @@ -25,8 +25,8 @@ rm -f *.bin cd .. rm -f asm.output -if [ $negtest_number -eq $negtest_failed_successfull ]; then - echo "Detected all errors succesfully" +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" exit 0 else exit 1 diff --git a/tests/Errors_registers/test.sh b/tests/Errors_registers/test.sh index d59426e..6dc4bc7 100644 --- a/tests/Errors_registers/test.sh +++ b/tests/Errors_registers/test.sh @@ -5,14 +5,14 @@ # return 2 on error in test SETUP # -negtest_number=0 +test_number=0 negtest_failed_successfull=0 cd tests rm -f *.bin for FILE in *; do if [ -f "$FILE" ]; then - negtest_number=$((negtest_number+1)) + test_number=$((test_number+1)) ../$ASMBIN $FILE -b FF > ../asm.output if [ $? -eq 0 ]; then echo "Failed to detect error in" \'$FILE\' @@ -25,8 +25,8 @@ rm -f *.bin cd .. rm -f asm.output -if [ $negtest_number -eq $negtest_failed_successfull ]; then - echo "Detected all errors succesfully" +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" exit 0 else exit 1 diff --git a/tests/Errors_strings/test.sh b/tests/Errors_strings/test.sh index d59426e..6dc4bc7 100644 --- a/tests/Errors_strings/test.sh +++ b/tests/Errors_strings/test.sh @@ -5,14 +5,14 @@ # return 2 on error in test SETUP # -negtest_number=0 +test_number=0 negtest_failed_successfull=0 cd tests rm -f *.bin for FILE in *; do if [ -f "$FILE" ]; then - negtest_number=$((negtest_number+1)) + test_number=$((test_number+1)) ../$ASMBIN $FILE -b FF > ../asm.output if [ $? -eq 0 ]; then echo "Failed to detect error in" \'$FILE\' @@ -25,8 +25,8 @@ rm -f *.bin cd .. rm -f asm.output -if [ $negtest_number -eq $negtest_failed_successfull ]; then - echo "Detected all errors succesfully" +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" exit 0 else exit 1 diff --git a/tests/Errors_value_operators/test copy.sh b/tests/Errors_value_operators/test copy.sh new file mode 100644 index 0000000..6dc4bc7 --- /dev/null +++ b/tests/Errors_value_operators/test copy.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Negative test - assembler needs to fail tests in all subfolders +# return 0 on succesfull test (all failed) +# return 1 on issue during test (one or more tests didn't fail correctly) +# return 2 on error in test SETUP +# + +test_number=0 +negtest_failed_successfull=0 + +cd tests +rm -f *.bin +for FILE in *; do + if [ -f "$FILE" ]; then + test_number=$((test_number+1)) + ../$ASMBIN $FILE -b FF > ../asm.output + if [ $? -eq 0 ]; then + echo "Failed to detect error in" \'$FILE\' + else + negtest_failed_successfull=$((negtest_failed_successfull+1)) + fi + fi +done +rm -f *.bin +cd .. + +rm -f asm.output +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" + exit 0 +else + exit 1 +fi +exit 0 diff --git a/tests/Errors_value_operators/test.output b/tests/Errors_value_operators/test.output new file mode 100644 index 0000000..e178c79 --- /dev/null +++ b/tests/Errors_value_operators/test.output @@ -0,0 +1,3 @@ +Failed to detect error in 'illegal_shift_left.s' +Failed to detect error in 'illegal_shift_right.s' +Failed to detect error in 'illegal_unary_times.s' diff --git a/tests/Errors_value_operators/test.sh b/tests/Errors_value_operators/test.sh new file mode 100644 index 0000000..6dc4bc7 --- /dev/null +++ b/tests/Errors_value_operators/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Negative test - assembler needs to fail tests in all subfolders +# return 0 on succesfull test (all failed) +# return 1 on issue during test (one or more tests didn't fail correctly) +# return 2 on error in test SETUP +# + +test_number=0 +negtest_failed_successfull=0 + +cd tests +rm -f *.bin +for FILE in *; do + if [ -f "$FILE" ]; then + test_number=$((test_number+1)) + ../$ASMBIN $FILE -b FF > ../asm.output + if [ $? -eq 0 ]; then + echo "Failed to detect error in" \'$FILE\' + else + negtest_failed_successfull=$((negtest_failed_successfull+1)) + fi + fi +done +rm -f *.bin +cd .. + +rm -f asm.output +if [ $test_number -eq $negtest_failed_successfull ]; then + echo "Detected all ($test_number) errors succesfully" + exit 0 +else + exit 1 +fi +exit 0 diff --git a/tests/Errors_value_operators/tests/illegal_shift_left.s b/tests/Errors_value_operators/tests/illegal_shift_left.s new file mode 100644 index 0000000..1a80b69 --- /dev/null +++ b/tests/Errors_value_operators/tests/illegal_shift_left.s @@ -0,0 +1 @@ + ld a, 8 < 2 \ No newline at end of file diff --git a/tests/Errors_value_operators/tests/illegal_shift_right.s b/tests/Errors_value_operators/tests/illegal_shift_right.s new file mode 100644 index 0000000..de79aa9 --- /dev/null +++ b/tests/Errors_value_operators/tests/illegal_shift_right.s @@ -0,0 +1 @@ + ld a, 8 > 2 \ No newline at end of file diff --git a/tests/Labels/test.output b/tests/Labels/test.output new file mode 100644 index 0000000..3526a49 --- /dev/null +++ b/tests/Labels/test.output @@ -0,0 +1 @@ +All (11) files assembled succesfully diff --git a/tests/Labels/test.sh b/tests/Labels/test.sh new file mode 100644 index 0000000..d339798 --- /dev/null +++ b/tests/Labels/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Positive test - assembler needs to pass all tests in all subfolders +# return 0 on succesfull tests (all passed) +# return 1 on issue during test (one or more tests didn't pass correctly) +# return 2 on error in test SETUP +# + +test_number=0 +tests_successfull=0 + +cd tests +rm -f *.bin +for FILE in *; do + if [ -f "$FILE" ]; then + test_number=$((test_number+1)) + ../$ASMBIN $FILE -b FF > ../asm.output + if [ $? -eq 1 ]; then + echo "Error in" \'$FILE\' + else + tests_successfull=$((tests_successfull+1)) + fi + fi +done +rm -f *.bin +cd .. + +rm -f asm.output +if [ $test_number -eq $tests_successfull ]; then + echo "All ($test_number) files assembled succesfully" + exit 0 +else + exit 1 +fi +exit 0 diff --git a/tests/Labels/tests/back_reference.s b/tests/Labels/tests/back_reference.s new file mode 100644 index 0000000..57f69c0 --- /dev/null +++ b/tests/Labels/tests/back_reference.s @@ -0,0 +1,6 @@ +back: + ld a,b + jp back +newlabel: + ld a,b + jp back \ No newline at end of file diff --git a/tests/Labels/tests/basic_label.s b/tests/Labels/tests/basic_label.s new file mode 100644 index 0000000..2be538f --- /dev/null +++ b/tests/Labels/tests/basic_label.s @@ -0,0 +1 @@ +label: \ No newline at end of file diff --git a/tests/Labels/tests/basic_label_single_opcode.s b/tests/Labels/tests/basic_label_single_opcode.s new file mode 100644 index 0000000..49b0ae4 --- /dev/null +++ b/tests/Labels/tests/basic_label_single_opcode.s @@ -0,0 +1 @@ +label:ld a,b \ No newline at end of file diff --git a/tests/Labels/tests/basic_label_single_opcode_spaced.s b/tests/Labels/tests/basic_label_single_opcode_spaced.s new file mode 100644 index 0000000..9ad9f1f --- /dev/null +++ b/tests/Labels/tests/basic_label_single_opcode_spaced.s @@ -0,0 +1 @@ +label: ld a,b \ No newline at end of file diff --git a/tests/Labels/tests/basic_label_with_comment.s b/tests/Labels/tests/basic_label_with_comment.s new file mode 100644 index 0000000..b1a0a8e --- /dev/null +++ b/tests/Labels/tests/basic_label_with_comment.s @@ -0,0 +1 @@ +label:;comment \ No newline at end of file diff --git a/tests/Labels/tests/basic_label_with_spaced_comment.s b/tests/Labels/tests/basic_label_with_spaced_comment.s new file mode 100644 index 0000000..69e2126 --- /dev/null +++ b/tests/Labels/tests/basic_label_with_spaced_comment.s @@ -0,0 +1 @@ +label: ;comment \ No newline at end of file diff --git a/tests/Labels/tests/forward_reference.s b/tests/Labels/tests/forward_reference.s new file mode 100644 index 0000000..a411c53 --- /dev/null +++ b/tests/Labels/tests/forward_reference.s @@ -0,0 +1,6 @@ + jp forward + jp newlabel + ld a,b +forward: + ld a,b +newlabel: \ No newline at end of file diff --git a/tests/jumps/test.s b/tests/Labels/tests/jumps.s similarity index 94% rename from tests/jumps/test.s rename to tests/Labels/tests/jumps.s index f1cd353..45b201f 100644 --- a/tests/jumps/test.s +++ b/tests/Labels/tests/jumps.s @@ -1,16 +1,16 @@ -label: - djnz label - jp label - jr nz, label - jr z, label - jr nc, label - jr c, label - jr label - djnz label2 - jp label2 - jr nz, label2 - jr z, label2 - jr nc, label2 - jr c, label2 - jr label2 -label2: +label: + djnz label + jp label + jr nz, label + jr z, label + jr nc, label + jr c, label + jr label + djnz label2 + jp label2 + jr nz, label2 + jr z, label2 + jr nc, label2 + jr c, label2 + jr label2 +label2: diff --git a/tests/basiclabels_cc/test.s b/tests/Labels/tests/labels_using_cc_strings.s similarity index 90% rename from tests/basiclabels_cc/test.s rename to tests/Labels/tests/labels_using_cc_strings.s index a380734..83946e1 100644 --- a/tests/basiclabels_cc/test.s +++ b/tests/Labels/tests/labels_using_cc_strings.s @@ -1,17 +1,17 @@ -; Labels that contain CC conditional strings, should be allowed without error -nze: -nzx: -ze: -zx: -nce: -ncx: -ce: -cx: -poe: -pox: -pea: -pex: -pa: -px: -ma: +; Labels that contain CC conditional strings, should be allowed without error +nze: +nzx: +ze: +zx: +nce: +ncx: +ce: +cx: +poe: +pox: +pea: +pex: +pa: +px: +ma: mx: \ No newline at end of file diff --git a/tests/advancedlabels/test.s b/tests/Labels/tests/local_labels.s similarity index 94% rename from tests/advancedlabels/test.s rename to tests/Labels/tests/local_labels.s index 96a21eb..c83c73d 100644 --- a/tests/advancedlabels/test.s +++ b/tests/Labels/tests/local_labels.s @@ -1,43 +1,43 @@ -; local labels before a global label - ld a,b -@local1: - ld a,b - ld hl, @local1 - ld hl, @local2 -@local2: - ld a,b - ld hl, @local2 - ld hl, @local1 -global1: -; local labels between global labels - ld a,b -@local1: - ld a,b - ld hl, @local1 - ld hl, @local2 -@local2: - ld a,b - ld hl, @local1 - ld hl, @local2 -; anonymous labels -@@: - ld a,b - ld hl, @p - ld hl, @b - ld hl, @n - ld hl, @f -global2: -; local labels after last global label - ld a,b -@local1: - ld a,b - ld hl, @local1 - ld hl, @local2 -@@: - ld a,b - ld hl, @b - ld hl, @p -@local2: - ld a,b - ld hl, @local1 - ld hl, @local2 +; local labels before a global label + ld a,b +@local1: + ld a,b + ld hl, @local1 + ld hl, @local2 +@local2: + ld a,b + ld hl, @local2 + ld hl, @local1 +global1: +; local labels between global labels + ld a,b +@local1: + ld a,b + ld hl, @local1 + ld hl, @local2 +@local2: + ld a,b + ld hl, @local1 + ld hl, @local2 +; anonymous labels +@@: + ld a,b + ld hl, @p + ld hl, @b + ld hl, @n + ld hl, @f +global2: +; local labels after last global label + ld a,b +@local1: + ld a,b + ld hl, @local1 + ld hl, @local2 +@@: + ld a,b + ld hl, @b + ld hl, @p +@local2: + ld a,b + ld hl, @local1 + ld hl, @local2 diff --git a/tests/definitions/test.s b/tests/Labels/tests/value_definitions.s similarity index 100% rename from tests/definitions/test.s rename to tests/Labels/tests/value_definitions.s diff --git a/tests/Value_operators/test.output b/tests/Value_operators/test.output new file mode 100644 index 0000000..c6bb19c --- /dev/null +++ b/tests/Value_operators/test.output @@ -0,0 +1 @@ +All (12) files assembled succesfully diff --git a/tests/Value_operators/test.sh b/tests/Value_operators/test.sh new file mode 100644 index 0000000..d339798 --- /dev/null +++ b/tests/Value_operators/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Positive test - assembler needs to pass all tests in all subfolders +# return 0 on succesfull tests (all passed) +# return 1 on issue during test (one or more tests didn't pass correctly) +# return 2 on error in test SETUP +# + +test_number=0 +tests_successfull=0 + +cd tests +rm -f *.bin +for FILE in *; do + if [ -f "$FILE" ]; then + test_number=$((test_number+1)) + ../$ASMBIN $FILE -b FF > ../asm.output + if [ $? -eq 1 ]; then + echo "Error in" \'$FILE\' + else + tests_successfull=$((tests_successfull+1)) + fi + fi +done +rm -f *.bin +cd .. + +rm -f asm.output +if [ $test_number -eq $tests_successfull ]; then + echo "All ($test_number) files assembled succesfully" + exit 0 +else + exit 1 +fi +exit 0 diff --git a/tests/Value_operators/tests/operator_and.s b/tests/Value_operators/tests/operator_and.s new file mode 100644 index 0000000..0efc10b --- /dev/null +++ b/tests/Value_operators/tests/operator_and.s @@ -0,0 +1 @@ + ld a, 10&2 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_div.s b/tests/Value_operators/tests/operator_div.s new file mode 100644 index 0000000..de4cc6e --- /dev/null +++ b/tests/Value_operators/tests/operator_div.s @@ -0,0 +1 @@ + ld a, 10/2 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_min.s b/tests/Value_operators/tests/operator_min.s new file mode 100644 index 0000000..1b080db --- /dev/null +++ b/tests/Value_operators/tests/operator_min.s @@ -0,0 +1 @@ + ld a,10-1 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_or.s b/tests/Value_operators/tests/operator_or.s new file mode 100644 index 0000000..ece1657 --- /dev/null +++ b/tests/Value_operators/tests/operator_or.s @@ -0,0 +1 @@ + ld a, 10|2 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_plus.s b/tests/Value_operators/tests/operator_plus.s new file mode 100644 index 0000000..4dbd432 --- /dev/null +++ b/tests/Value_operators/tests/operator_plus.s @@ -0,0 +1 @@ + ld a,10+1 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_shleft.s b/tests/Value_operators/tests/operator_shleft.s new file mode 100644 index 0000000..2eef4d4 --- /dev/null +++ b/tests/Value_operators/tests/operator_shleft.s @@ -0,0 +1 @@ + ld a, 10<<2 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_shright.s b/tests/Value_operators/tests/operator_shright.s new file mode 100644 index 0000000..9c8588c --- /dev/null +++ b/tests/Value_operators/tests/operator_shright.s @@ -0,0 +1 @@ + ld a, 10>>2 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_times.s b/tests/Value_operators/tests/operator_times.s new file mode 100644 index 0000000..e15510f --- /dev/null +++ b/tests/Value_operators/tests/operator_times.s @@ -0,0 +1 @@ + ld a, 10*1 \ No newline at end of file diff --git a/tests/Value_operators/tests/operator_xor.s b/tests/Value_operators/tests/operator_xor.s new file mode 100644 index 0000000..2067bdc --- /dev/null +++ b/tests/Value_operators/tests/operator_xor.s @@ -0,0 +1 @@ + ld a, 10^2 \ No newline at end of file diff --git a/tests/Value_operators/tests/unary_operator_min.s b/tests/Value_operators/tests/unary_operator_min.s new file mode 100644 index 0000000..5ec3df0 --- /dev/null +++ b/tests/Value_operators/tests/unary_operator_min.s @@ -0,0 +1 @@ + ld a, -10 \ No newline at end of file diff --git a/tests/Value_operators/tests/unary_operator_not.s b/tests/Value_operators/tests/unary_operator_not.s new file mode 100644 index 0000000..176ead9 --- /dev/null +++ b/tests/Value_operators/tests/unary_operator_not.s @@ -0,0 +1 @@ + ld a, ~10 \ No newline at end of file diff --git a/tests/Value_operators/tests/unary_operator_plus.s b/tests/Value_operators/tests/unary_operator_plus.s new file mode 100644 index 0000000..27c34e2 --- /dev/null +++ b/tests/Value_operators/tests/unary_operator_plus.s @@ -0,0 +1 @@ + ld a, +10 \ No newline at end of file diff --git a/tests/advancedlabels/asm.output b/tests/advancedlabels/asm.output deleted file mode 100644 index c1a9845..0000000 --- a/tests/advancedlabels/asm.output +++ /dev/null @@ -1,5 +0,0 @@ -Setting fillbyte to hex FF -Assembling test.s -Pass 1... -Pass 2... -Done in 0.00 seconds diff --git a/tests/advancedlabels/reference-manual.bat b/tests/advancedlabels/reference-manual.bat deleted file mode 100644 index 2cfb98c..0000000 --- a/tests/advancedlabels/reference-manual.bat +++ /dev/null @@ -1,13 +0,0 @@ -@echo off -set localdir=%cd% -echo Making reference... -cd ../../tools/make_reference/reference -REM Special copy of reftest, not test itself, due to ZDS syntax, same binary -copy %localdir%\reftest.s ..\test.s -echo ZDS assembler... -make rebuildall -f ../reference.mak -echo HEX conversion... -..\..\..\tools\hex2bin reference.hex -echo Copying reference.bin... -copy reference.bin %localdir%\reference.bin -cd %localdir% \ No newline at end of file diff --git a/tests/advancedlabels/reference.bin b/tests/advancedlabels/reference.bin deleted file mode 100644 index 2c02d6aa940a2bcfe91a2dad26d33fee8ef72ead..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 83 ycmb=ZP-J9aQRHG^sQ?imPDO>H2#_TU5`r_-fFdC52*E%#7C@F4NDWK~CISGupbC!w diff --git a/tests/advancedlabels/reftest.s b/tests/advancedlabels/reftest.s deleted file mode 100644 index 5264169..0000000 --- a/tests/advancedlabels/reftest.s +++ /dev/null @@ -1,45 +0,0 @@ -; local labels before a global label - ld a,b -$local1: - ld a,b - ld hl, $local1 - ld hl, $local2 -$local2: - ld a,b - ld hl, $local2 - ld hl, $local1 -global1: -SCOPE -; local labels between global labels - ld a,b -$local1: - ld a,b - ld hl, $local1 - ld hl, $local2 -$local2: - ld a,b - ld hl, $local1 - ld hl, $local2 -; anonymous labels -$$: - ld a,b - ld hl, $B - ld hl, $B - ld hl, $F - ld hl, $F -global2: -SCOPE -; local labels after last global label - ld a,b -$local1: - ld a,b - ld hl, $local1 - ld hl, $local2 -$$: - ld a,b - ld hl, $B - ld hl, $B -$local2: - ld a,b - ld hl, $local1 - ld hl, $local2 diff --git a/tests/advancedlabels/test.bin b/tests/advancedlabels/test.bin deleted file mode 100644 index 2c02d6aa940a2bcfe91a2dad26d33fee8ef72ead..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 83 ycmb=ZP-J9aQRHG^sQ?imPDO>H2#_TU5`r_-fFdC52*E%#7C@F4NDWK~CISGupbC!w diff --git a/tests/advancedlabels/test.output b/tests/advancedlabels/test.output deleted file mode 100644 index 699e315..0000000 --- a/tests/advancedlabels/test.output +++ /dev/null @@ -1,3 +0,0 @@ -Assembler done -Performing binary check -Binary output correct diff --git a/tests/advancedlabels/test.sh b/tests/advancedlabels/test.sh deleted file mode 100644 index 4265f60..0000000 --- a/tests/advancedlabels/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Positive test -# return 0 on succesfull test -# return 1 on issue during test -# return 2 on error in test SETUP -# -CHECKBIN=1 -# -if [ -f "test.s" ]; then - $ASMBIN test.s -b FF > asm.output - if [ $? -eq 1 ]; then - echo "Assembler error(s)" - exit 1 - else - echo "Assembler done" - fi - if [ $CHECKBIN -eq 1 ]; then - echo "Performing binary check" - if [ -f "reference.bin" ]; then - diff test.bin reference.bin >/dev/null - if [ $? -eq 1 ]; then - echo "Binary output incorrect" - exit 1 - else - echo "Binary output correct" - fi - else - echo "Missing reference.bin" - exit 2 - fi - fi -else - echo "test.s not present" - exit 2 -fi -exit 0 diff --git a/tests/basiclabels/asm.output b/tests/basiclabels/asm.output deleted file mode 100644 index c1a9845..0000000 --- a/tests/basiclabels/asm.output +++ /dev/null @@ -1,5 +0,0 @@ -Setting fillbyte to hex FF -Assembling test.s -Pass 1... -Pass 2... -Done in 0.00 seconds diff --git a/tests/basiclabels/test.bin b/tests/basiclabels/test.bin deleted file mode 100644 index e69de29..0000000 diff --git a/tests/basiclabels/test.output b/tests/basiclabels/test.output deleted file mode 100644 index fb53b04..0000000 --- a/tests/basiclabels/test.output +++ /dev/null @@ -1 +0,0 @@ -Assembler done diff --git a/tests/basiclabels/test.s b/tests/basiclabels/test.s deleted file mode 100644 index 622b859..0000000 --- a/tests/basiclabels/test.s +++ /dev/null @@ -1,3 +0,0 @@ -; simple labels to test lineparser -label: -label2 : diff --git a/tests/basiclabels/test.sh b/tests/basiclabels/test.sh deleted file mode 100644 index ceb743b..0000000 --- a/tests/basiclabels/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Positive test -# return 0 on succesfull test -# return 1 on issue during test -# return 2 on error in test SETUP -# -CHECKBIN=0 -# -if [ -f "test.s" ]; then - $ASMBIN test.s -b FF > asm.output - if [ $? -eq 1 ]; then - echo "Assembler error(s)" - exit 1 - else - echo "Assembler done" - fi - if [ $CHECKBIN -eq 1 ]; then - echo "Performing binary check" - if [ -f "reference.bin" ]; then - diff test.bin reference.bin >/dev/null - if [ $? -eq 1 ]; then - echo "Binary output incorrect" - exit 1 - else - echo "Binary output correct" - fi - else - echo "Missing reference.bin" - exit 2 - fi - fi -else - echo "test.s not present" - exit 2 -fi -exit 0 diff --git a/tests/basiclabels_cc/asm.output b/tests/basiclabels_cc/asm.output deleted file mode 100644 index c1a9845..0000000 --- a/tests/basiclabels_cc/asm.output +++ /dev/null @@ -1,5 +0,0 @@ -Setting fillbyte to hex FF -Assembling test.s -Pass 1... -Pass 2... -Done in 0.00 seconds diff --git a/tests/basiclabels_cc/test.bin b/tests/basiclabels_cc/test.bin deleted file mode 100644 index e69de29..0000000 diff --git a/tests/basiclabels_cc/test.output b/tests/basiclabels_cc/test.output deleted file mode 100644 index fb53b04..0000000 --- a/tests/basiclabels_cc/test.output +++ /dev/null @@ -1 +0,0 @@ -Assembler done diff --git a/tests/basiclabels_cc/test.sh b/tests/basiclabels_cc/test.sh deleted file mode 100644 index ceb743b..0000000 --- a/tests/basiclabels_cc/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Positive test -# return 0 on succesfull test -# return 1 on issue during test -# return 2 on error in test SETUP -# -CHECKBIN=0 -# -if [ -f "test.s" ]; then - $ASMBIN test.s -b FF > asm.output - if [ $? -eq 1 ]; then - echo "Assembler error(s)" - exit 1 - else - echo "Assembler done" - fi - if [ $CHECKBIN -eq 1 ]; then - echo "Performing binary check" - if [ -f "reference.bin" ]; then - diff test.bin reference.bin >/dev/null - if [ $? -eq 1 ]; then - echo "Binary output incorrect" - exit 1 - else - echo "Binary output correct" - fi - else - echo "Missing reference.bin" - exit 2 - fi - fi -else - echo "test.s not present" - exit 2 -fi -exit 0 diff --git a/tests/conditional/asm.output b/tests/conditional/asm.output deleted file mode 100644 index c1a9845..0000000 --- a/tests/conditional/asm.output +++ /dev/null @@ -1,5 +0,0 @@ -Setting fillbyte to hex FF -Assembling test.s -Pass 1... -Pass 2... -Done in 0.00 seconds diff --git a/tests/conditional/reference.bin b/tests/conditional/reference.bin deleted file mode 100644 index 65754de..0000000 --- a/tests/conditional/reference.bin +++ /dev/null @@ -1 +0,0 @@ -> \ No newline at end of file diff --git a/tests/conditional/test.bin b/tests/conditional/test.bin deleted file mode 100644 index 65754de..0000000 --- a/tests/conditional/test.bin +++ /dev/null @@ -1 +0,0 @@ -> \ No newline at end of file diff --git a/tests/conditional/test.output b/tests/conditional/test.output deleted file mode 100644 index 699e315..0000000 --- a/tests/conditional/test.output +++ /dev/null @@ -1,3 +0,0 @@ -Assembler done -Performing binary check -Binary output correct diff --git a/tests/conditional/test.sh b/tests/conditional/test.sh deleted file mode 100644 index 4265f60..0000000 --- a/tests/conditional/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Positive test -# return 0 on succesfull test -# return 1 on issue during test -# return 2 on error in test SETUP -# -CHECKBIN=1 -# -if [ -f "test.s" ]; then - $ASMBIN test.s -b FF > asm.output - if [ $? -eq 1 ]; then - echo "Assembler error(s)" - exit 1 - else - echo "Assembler done" - fi - if [ $CHECKBIN -eq 1 ]; then - echo "Performing binary check" - if [ -f "reference.bin" ]; then - diff test.bin reference.bin >/dev/null - if [ $? -eq 1 ]; then - echo "Binary output incorrect" - exit 1 - else - echo "Binary output correct" - fi - else - echo "Missing reference.bin" - exit 2 - fi - fi -else - echo "test.s not present" - exit 2 -fi -exit 0 diff --git a/tests/definitions/asm.output b/tests/definitions/asm.output deleted file mode 100644 index c1a9845..0000000 --- a/tests/definitions/asm.output +++ /dev/null @@ -1,5 +0,0 @@ -Setting fillbyte to hex FF -Assembling test.s -Pass 1... -Pass 2... -Done in 0.00 seconds diff --git a/tests/definitions/reference.bat b/tests/definitions/reference.bat deleted file mode 100644 index 43a87cb..0000000 --- a/tests/definitions/reference.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off -set localdir=%cd% -echo Making reference... -cd ../../tools/make_reference/reference -copy %localdir%\test.s ..\test.s -echo ZDS assembler... -make rebuildall -f ../reference.mak -echo HEX conversion... -..\..\..\tools\hex2bin reference.hex -echo Copying reference.bin... -copy reference.bin %localdir%\reference.bin -cd %localdir% \ No newline at end of file diff --git a/tests/definitions/reference.bin b/tests/definitions/reference.bin deleted file mode 100644 index 8892be5..0000000 --- a/tests/definitions/reference.bin +++ /dev/null @@ -1,2 +0,0 @@ ->> -> > >> \ No newline at end of file diff --git a/tests/definitions/test.bin b/tests/definitions/test.bin deleted file mode 100644 index 8892be5..0000000 --- a/tests/definitions/test.bin +++ /dev/null @@ -1,2 +0,0 @@ ->> -> > >> \ No newline at end of file diff --git a/tests/definitions/test.output b/tests/definitions/test.output deleted file mode 100644 index 699e315..0000000 --- a/tests/definitions/test.output +++ /dev/null @@ -1,3 +0,0 @@ -Assembler done -Performing binary check -Binary output correct diff --git a/tests/definitions/test.sh b/tests/definitions/test.sh deleted file mode 100644 index 4265f60..0000000 --- a/tests/definitions/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Positive test -# return 0 on succesfull test -# return 1 on issue during test -# return 2 on error in test SETUP -# -CHECKBIN=1 -# -if [ -f "test.s" ]; then - $ASMBIN test.s -b FF > asm.output - if [ $? -eq 1 ]; then - echo "Assembler error(s)" - exit 1 - else - echo "Assembler done" - fi - if [ $CHECKBIN -eq 1 ]; then - echo "Performing binary check" - if [ -f "reference.bin" ]; then - diff test.bin reference.bin >/dev/null - if [ $? -eq 1 ]; then - echo "Binary output incorrect" - exit 1 - else - echo "Binary output correct" - fi - else - echo "Missing reference.bin" - exit 2 - fi - fi -else - echo "test.s not present" - exit 2 -fi -exit 0 diff --git a/tests/jumps/asm.output b/tests/jumps/asm.output deleted file mode 100644 index c1a9845..0000000 --- a/tests/jumps/asm.output +++ /dev/null @@ -1,5 +0,0 @@ -Setting fillbyte to hex FF -Assembling test.s -Pass 1... -Pass 2... -Done in 0.00 seconds diff --git a/tests/jumps/reference.bat b/tests/jumps/reference.bat deleted file mode 100644 index 43a87cb..0000000 --- a/tests/jumps/reference.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off -set localdir=%cd% -echo Making reference... -cd ../../tools/make_reference/reference -copy %localdir%\test.s ..\test.s -echo ZDS assembler... -make rebuildall -f ../reference.mak -echo HEX conversion... -..\..\..\tools\hex2bin reference.hex -echo Copying reference.bin... -copy reference.bin %localdir%\reference.bin -cd %localdir% \ No newline at end of file diff --git a/tests/jumps/reference.bin b/tests/jumps/reference.bin deleted file mode 100644 index b43c02e202c51f7ecaeebf2ead89e9004be176da..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32 mcmWgmcbI{JMd63WH-j%0pCmpA@EukF@;Nlv3|K6fBp3j}7zslF diff --git a/tests/jumps/test.bin b/tests/jumps/test.bin deleted file mode 100644 index b43c02e202c51f7ecaeebf2ead89e9004be176da..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32 mcmWgmcbI{JMd63WH-j%0pCmpA@EukF@;Nlv3|K6fBp3j}7zslF diff --git a/tests/jumps/test.output b/tests/jumps/test.output deleted file mode 100644 index 699e315..0000000 --- a/tests/jumps/test.output +++ /dev/null @@ -1,3 +0,0 @@ -Assembler done -Performing binary check -Binary output correct diff --git a/tests/jumps/test.sh b/tests/jumps/test.sh deleted file mode 100644 index 4265f60..0000000 --- a/tests/jumps/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Positive test -# return 0 on succesfull test -# return 1 on issue during test -# return 2 on error in test SETUP -# -CHECKBIN=1 -# -if [ -f "test.s" ]; then - $ASMBIN test.s -b FF > asm.output - if [ $? -eq 1 ]; then - echo "Assembler error(s)" - exit 1 - else - echo "Assembler done" - fi - if [ $CHECKBIN -eq 1 ]; then - echo "Performing binary check" - if [ -f "reference.bin" ]; then - diff test.bin reference.bin >/dev/null - if [ $? -eq 1 ]; then - echo "Binary output incorrect" - exit 1 - else - echo "Binary output correct" - fi - else - echo "Missing reference.bin" - exit 2 - fi - fi -else - echo "test.s not present" - exit 2 -fi -exit 0 diff --git a/tests/jumps/testn.bin b/tests/jumps/testn.bin deleted file mode 100644 index cae4e43..0000000 --- a/tests/jumps/testn.bin +++ /dev/null @@ -1 +0,0 @@ -þ \ No newline at end of file diff --git a/tests/jumps/testn.s b/tests/jumps/testn.s deleted file mode 100644 index 6134c3a..0000000 --- a/tests/jumps/testn.s +++ /dev/null @@ -1,2 +0,0 @@ -label: - jr label diff --git a/tests/template_tests/test.output b/tests/template_tests/test.output new file mode 100644 index 0000000..53eb725 --- /dev/null +++ b/tests/template_tests/test.output @@ -0,0 +1 @@ +All (0) files assembled succesfully diff --git a/tests/template_tests/test.sh b/tests/template_tests/test.sh new file mode 100644 index 0000000..d339798 --- /dev/null +++ b/tests/template_tests/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Positive test - assembler needs to pass all tests in all subfolders +# return 0 on succesfull tests (all passed) +# return 1 on issue during test (one or more tests didn't pass correctly) +# return 2 on error in test SETUP +# + +test_number=0 +tests_successfull=0 + +cd tests +rm -f *.bin +for FILE in *; do + if [ -f "$FILE" ]; then + test_number=$((test_number+1)) + ../$ASMBIN $FILE -b FF > ../asm.output + if [ $? -eq 1 ]; then + echo "Error in" \'$FILE\' + else + tests_successfull=$((tests_successfull+1)) + fi + fi +done +rm -f *.bin +cd .. + +rm -f asm.output +if [ $test_number -eq $tests_successfull ]; then + echo "All ($test_number) files assembled succesfully" + exit 0 +else + exit 1 +fi +exit 0