1
0
mirror of https://github.com/rzzzwilson/pymlac.git synced 2025-06-10 09:32:41 +00:00

Cleanup and add more harness checking

This commit is contained in:
Ross Wilson
2016-02-19 12:11:34 +07:00
parent c7454d6396
commit 90f2932998
8 changed files with 55 additions and 39 deletions

View File

@@ -190,14 +190,15 @@ def test_file(filename):
tests = []
for (lnum, line) in enumerate(lines):
if line.startswith(';|') or line.startswith(';!'):
test_pass = line.startswith(';|')
prefix = line[:2]
must_pass = line.startswith(';|')
test = line[2:]
test = test.replace('\t', ' ')
if ';' in test:
ndx = test.index(';')
test = test[:ndx].rstrip()
tests.append((lnum+1, test_pass, test))
tests.append((lnum+1, must_pass, prefix, test))
# make sure we have some tests
if not tests:
@@ -211,7 +212,7 @@ def test_file(filename):
# interpret the test instructions and check generated code
dot = None
for (lnum, must_pass, test) in tests:
for (lnum, must_pass, prefix, test) in tests:
# check for a label
if test[0] == ' ':
# no label
@@ -229,8 +230,8 @@ def test_file(filename):
except IndexError:
if must_pass:
errors += 1
warn("File '%s' has label '%s' with bad ORG number: %s"
% (filename, label, test))
warn("File '%s' has label '%s' with bad ORG number: %s%s"
% (filename, label, prefix, test))
return errors # must end testing
address = dot
else:
@@ -246,7 +247,6 @@ def test_file(filename):
warn("File '%s' has label '%s' with bad ORG number: %s"
% (filename, label, test))
return errors # must end testing
try:
mem_value = memory[address]
except KeyError:
@@ -264,6 +264,13 @@ def test_file(filename):
"%2d: %s\n"
"Memory at address %04o should be %06o, got %06o"
% (filename, lnum, test, address, value, mem_value))
else:
if not must_pass:
errors += 1
warn("%s\n"
"%2d: %s\n"
"Memory contents check should fail but didn't?"
% (filename, lnum, test))
dot += 1

View File

@@ -1,21 +0,0 @@
; test ASCIIZ pseudo-op
org 0100
print equ 0200
start law str
jms print
hlt
str asciiz 'str'
str2 asciiz 'str0'
end start
;|$1 0004000+.+3
;| 0034000+0200
;| 0000000
;| 0071564 ; 'st'
;| 0071000 ; 'r\0'
;| 0071564 ; 'st'
;| 0071060 ; 'r0'
;| 0000000 ; zero byte

View File

@@ -1,12 +0,0 @@
; test file with two ORG blocks
org 0100
law 1
hlt
org 0200
law 2
hlt
end
;|$1 004000 + 1
;| 000000
;|$2 004000 + 2
;| 000000

View File

@@ -0,0 +1,42 @@
; test pseudo-ops
org 0100
test equ 045
start hlt
law test
org 0200
start2 nop
org 0300
start3 nop
bss 1
hlt
str asciiz 'str'
str2 asciiz 'str0'
str3 ascii 'str11'
dat data 0
dat2 data 0177777
end start
;|$1 0000000
;| 0004000 + 045
;|$2 0100000
;|$3 0100000
;|$4 0000000 ; BSS behaves like 'org .+n'
;| 0071564 ; 'st'
;| 0071000 ; 'r\0'
;| 0071564 ; 'st'
;| 0071060 ; 'r0'
;| 0000000 ; zero byte
;| 0071564 ; 'rs'
;| 0071061 ; 't1'
;| 0030400 ; '1\0'
;| 0000000
;| 0177777