diff --git a/8080/CPM/Makefile b/8080/CPM/Makefile index 6e719ff..45429fc 100644 --- a/8080/CPM/Makefile +++ b/8080/CPM/Makefile @@ -12,7 +12,7 @@ cpmfilesdir = cpmfiles fth: $(fthfiles) clean: - rm -f *.log + rm -f *.log *.golden *.result rm -rf $(runcpmdir) rm -f msdos @@ -54,10 +54,19 @@ logtest.log: $(patsubst %, $(cpmfilesdir)/%, volks4th.com) \ echo "exit" >> $(runcpmdir)/input.script ./emulator/run-in-runcpm.sh volks4th cp $(runcpmdir)/output.log output.log - cp $(runcpmdir)/A/0/LOGFILE.TXT $@ + ../../tools/trunc-ctrl-z.py $(runcpmdir)/A/0/LOGFILE.TXT \ + $(runcpmdir)/logfile.txt + dos2unix -n $(runcpmdir)/logfile.txt $@ emu: $(runcpmdir)/RunCPM +%.golden: tests/golden/%.golden + cp -p $< $@ + +%.result: %.log %.golden tests/evaluate-test.sh + rm -f $@ + tests/evaluate-test.sh $(basename $@) + $(runcpmdir)/RunCPM: $(whitch_runcpm) test -d $(runcpmdir) || mkdir -p $(runcpmdir) cp $< $@ diff --git a/8080/CPM/tests/evaluate-test.sh b/8080/CPM/tests/evaluate-test.sh new file mode 100755 index 0000000..144f661 --- /dev/null +++ b/8080/CPM/tests/evaluate-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +testsdir="$(realpath --relative-to="$PWD" "$(dirname "${BASH_SOURCE[0]}")")" +basedir="$(realpath --relative-to="$PWD" "${testsdir}/..")" + +testname="$1" + +diff --ignore-trailing-space "${basedir}/${testname}.golden" \ + "${basedir}/${testname}.log" > tmp.result +exitcode=$? +test $exitcode -eq 0 \ + && echo "PASS: ${testname}" >> tmp.result \ + || echo "FAIL: ${testname}" >> tmp.result +cat tmp.result +mv tmp.result "${basedir}/${testname}.result" +exit $exitcode diff --git a/8080/CPM/tests/golden/logtest.golden b/8080/CPM/tests/golden/logtest.golden new file mode 100644 index 0000000..6319d26 --- /dev/null +++ b/8080/CPM/tests/golden/logtest.golden @@ -0,0 +1,4 @@ + ok +.( hello world) cr hello world + ok +logclose diff --git a/8080/CPM/tests/log2file.fb b/8080/CPM/tests/log2file.fb index aa22479..f9d3fef 100644 --- a/8080/CPM/tests/log2file.fb +++ b/8080/CPM/tests/log2file.fb @@ -1 +1 @@ - \ log2file loadscreen phz 01jun23 1 3 +thru \ logfile phz 01jul23 Dos also Forth definitions $18 constant fcb\nam create logfile ," LOGFILE TXT" fcb\nam allot 1 logfile c! create logdma b/rec allot variable logoffset 0 logoffset ! : logflush logdma dma! logfile write-seq ; : logc! ( c -- ) logoffset @ dup >r logdma + c! r> 1+ dup logoffset ! b/rec = IF logflush 0 logoffset ! THEN ; \ log-emit log-type log-cr alsologtofile pphz 01jul23 : log-emit ( char -- ) dup (emit logc! ; : log-type ( addr count -- ) 2dup (type 0 ?DO count logc! LOOP drop ; : log-cr ( -- ) (cr #cr logc! #lf logc! ; Output: alsologtofile log-emit log-cr log-type (del (page (at (at? ; \ logopen phz 01jul23 : logopen ( -- ) logfile filenamelen + 1+ fcb\nam erase logfile killfile logfile createfile alsologtofile ; : logclose ( -- ) cr display logflush logfile closefile ; \ No newline at end of file + \ log2file loadscreen phz 01jun23 1 3 +thru \ logfile phz 01jul23 Dos also Forth definitions $18 constant fcb\nam create logfile ," LOGFILE TXT" fcb\nam allot 1 logfile c! create logdma b/rec allot variable logoffset 0 logoffset ! : logflush logdma dma! logfile write-seq ; : logc! ( c -- ) logoffset @ dup >r logdma + c! r> 1+ dup logoffset ! b/rec = IF logflush 0 logoffset ! THEN ; \ log-emit log-type log-cr alsologtofile pphz 01jul23 : log-emit ( char -- ) dup (emit logc! ; : log-type ( addr count -- ) 2dup (type 0 ?DO count logc! LOOP drop ; : log-cr ( -- ) (cr #cr logc! #lf logc! ; Output: alsologtofile log-emit log-cr log-type (del (page (at (at? ; \ logopen phz 01jul23 : logopen ( -- ) logfile filenamelen + 1+ fcb\nam erase logfile killfile logfile createfile alsologtofile ; : logclose ( -- ) cr display &26 logc! logflush logfile closefile ; \ No newline at end of file diff --git a/8080/CPM/tests/log2file.fth b/8080/CPM/tests/log2file.fth index b6cd84a..fa6886c 100644 --- a/8080/CPM/tests/log2file.fth +++ b/8080/CPM/tests/log2file.fth @@ -86,7 +86,7 @@ Output: alsologtofile alsologtofile ; : logclose ( -- ) - cr display logflush logfile closefile ; + cr display &26 logc! logflush logfile closefile ; diff --git a/tools/trunc-ctrl-z.py b/tools/trunc-ctrl-z.py new file mode 100755 index 0000000..f4d4751 --- /dev/null +++ b/tools/trunc-ctrl-z.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 + +import sys + +inFileName, outFileName = sys.argv[1], sys.argv[2] +inFile = open(inFileName, "rb") +source = inFile.read() +destination = bytearray() +for b in source: + if b == 26: + break + destination.append(b) +# result.append('') +outFile = open(outFileName, "wb") +outFile.write(destination)