From bc450511d826cbdd9c50402576b7d857e3b6fe4d Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Wed, 27 May 2015 21:54:00 +0200 Subject: [PATCH] Add some tests for things I have fixed while the last weeks. --- tests/RunTests | 25 ++++++++++++++++++++++ tests/incl.mac | 5 +++++ tests/test-asciz.mac | 12 +++++++++++ tests/test-backpatch.mac | 17 +++++++++++++++ tests/test-bsl-mac-arg.mac | 24 +++++++++++++++++++++ tests/test-complex-reloc.mac | 14 ++++++++++++ tests/test-endm.mac | 41 ++++++++++++++++++++++++++++++++++++ tests/test-include.mac | 17 +++++++++++++++ tests/test-locals.mac | 33 +++++++++++++++++++++++++++++ tests/test-macro-comma.mac | 14 ++++++++++++ tests/test-word-comma.mac | 12 +++++++++++ 11 files changed, 214 insertions(+) create mode 100755 tests/RunTests create mode 100644 tests/incl.mac create mode 100644 tests/test-asciz.mac create mode 100644 tests/test-backpatch.mac create mode 100644 tests/test-bsl-mac-arg.mac create mode 100644 tests/test-complex-reloc.mac create mode 100644 tests/test-endm.mac create mode 100644 tests/test-include.mac create mode 100644 tests/test-locals.mac create mode 100644 tests/test-macro-comma.mac create mode 100644 tests/test-word-comma.mac diff --git a/tests/RunTests b/tests/RunTests new file mode 100755 index 0000000..fbebf29 --- /dev/null +++ b/tests/RunTests @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Run some regression test cases. +# +# If there is a .lst.ok file, it compares the listing. +# If there is a .objd.ok file, it compares the result of dumpobj. +# + +TESTS="test-asciz test-backpatch test-bsl-mac-arg test-complex-reloc test-endm test-include test-locals test-macro-comma test-undef test-word-comma" + +for t in $TESTS +do + ../macro11 -l "$t".lst -o "$t".obj "$t".mac 2>/dev/null + + if [ -e "$t".lst.ok ] + then + diff -u "$t".lst.ok "$t".lst + fi + + if [ -e "$t".objd.ok ] + then + ../dumpobj "$t".obj >"$t".objd + diff -u "$t".objd.ok "$t".objd + fi +done diff --git a/tests/incl.mac b/tests/incl.mac new file mode 100644 index 0000000..0302894 --- /dev/null +++ b/tests/incl.mac @@ -0,0 +1,5 @@ +;;;;; +; +; file to be included + + .word 1 ; to show it is included diff --git a/tests/test-asciz.mac b/tests/test-asciz.mac new file mode 100644 index 0000000..21ba652 --- /dev/null +++ b/tests/test-asciz.mac @@ -0,0 +1,12 @@ +;;;;; +; +; Test delimiters of .ASCII and .ASCIZ + +CR = 13. +LF = 10. +SOH = 1 + + .asciz // ; 2 bytes and a string + .asciz // ; only a string + .asciz || ; the same string + .asciz ; 3 bytes diff --git a/tests/test-backpatch.mac b/tests/test-backpatch.mac new file mode 100644 index 0000000..1db522e --- /dev/null +++ b/tests/test-backpatch.mac @@ -0,0 +1,17 @@ +;;;; +; +; Test backpatching (seen in Kermit sources). + + .psect modinf ,ro,d,lcl,rel,con + +label = . + .blkb 50 ; create some data + + .byte 50,51,52 ; and some more + .save ; we're at 53 now + .psect modinf + . = label + 6 + .word 6 ; stored at 6 + .restore ; . gets restored to 53 + .byte 53 + diff --git a/tests/test-bsl-mac-arg.mac b/tests/test-bsl-mac-arg.mac new file mode 100644 index 0000000..9e6ca9e --- /dev/null +++ b/tests/test-bsl-mac-arg.mac @@ -0,0 +1,24 @@ + .list me + .macro test x + .blkb x ; test some directive that wants an expression + .endm + + size = 10 + foo = 2 + + ; likes: + + test size ; not replaced by "10" + test \size ; replaced by "10" + test \ ; ditto + test \ ; replaced by "12" + test ^/size + foo/ ; arg is "size + foo", not "12" + + ; dislikes: + + test <\size> ; parameter is \size, which might be ok for + ; macros where the argument is used differently. + test size + foo ; gets split at the space + test /size + foo/ ; gets split at the space + test \/size + foo/ ; invalid expression with division operator + test \^/size + foo/ ; original dislikes this, but we accept it. diff --git a/tests/test-complex-reloc.mac b/tests/test-complex-reloc.mac new file mode 100644 index 0000000..4f3929c --- /dev/null +++ b/tests/test-complex-reloc.mac @@ -0,0 +1,14 @@ + ; test complex relocations + + ; .globl IE.ITS,IE.MON ; implicit + mov #-IE.ITS, space + +space: .word IE.ITS ; the only simple relocation + .word -IE.ITS ; all others are complex relocations + .word ^C + .word IE.ITS + IE.MON + .word IE.ITS - IE.MON + .word IE.ITS * IE.MON + .word IE.ITS / IE.MON + .word IE.ITS & IE.MON + .word IE.ITS ! IE.MON diff --git a/tests/test-endm.mac b/tests/test-endm.mac new file mode 100644 index 0000000..2abfbed --- /dev/null +++ b/tests/test-endm.mac @@ -0,0 +1,41 @@ +;;;;; +; +; Test nested macros and name on .ENDM +; + + .macro M1 + .word 1 + .endm M1 ; ok + + M1 + + .macro M2 + .word 2 + .macro M3 + .word 3 + .endm M3 ; ok + .endm M2 ; ok + + M2 + M3 + + .macro M4 + .word 4 + .macro M4 + .endm M4 ; ok + .endm M4 ; ok + + M4 + M4 ; should be empty now + + .macro M5 + .word 5 + .macro M5 + .endm notM5 ; wrong; detected when M5 is expanded + .endm M5 ; ok + + M5 + M5 + + .macro M6 + .endm notM6 ; wrong diff --git a/tests/test-include.mac b/tests/test-include.mac new file mode 100644 index 0000000..9ee3b5e --- /dev/null +++ b/tests/test-include.mac @@ -0,0 +1,17 @@ +;;;;; +; +; Test some delimiters for the .INCLUDE directive +; + + .include "incl.mac" + .include /incl.mac/ + .include \incl.mac\ + .include ?incl.mac? + .include >incl.mac> + +; these are errors: (in MACRO V05.05, some terminate the assembler) + + .include + .include