From 5373de9c3676247e307893d16ba3a209475ffc0c Mon Sep 17 00:00:00 2001 From: Philip Zembrod Date: Thu, 6 Jan 2022 14:55:53 +0100 Subject: [PATCH] First automated make test for MSDOS volks4th.com in dosbox. --- 8086/msdos/Makefile | 18 +++++++++++++ 8086/msdos/emulator/run-in-dosbox.sh | 36 ++++++++++++++++++++++++++ 8086/msdos/tests/LOG2FILE.FB | 1 + 8086/msdos/tests/LOGTEST.FB | 1 + 8086/msdos/tests/evaluate-test.sh | 16 ++++++++++++ 8086/msdos/tests/golden/logtest.golden | 1 + 6 files changed, 73 insertions(+) create mode 100644 8086/msdos/Makefile create mode 100755 8086/msdos/emulator/run-in-dosbox.sh create mode 100644 8086/msdos/tests/LOG2FILE.FB create mode 100644 8086/msdos/tests/LOGTEST.FB create mode 100755 8086/msdos/tests/evaluate-test.sh create mode 100644 8086/msdos/tests/golden/logtest.golden diff --git a/8086/msdos/Makefile b/8086/msdos/Makefile new file mode 100644 index 0000000..e94fd1e --- /dev/null +++ b/8086/msdos/Makefile @@ -0,0 +1,18 @@ + + +test: logtest.result + +clean: + rm -f *.log *.LOG *.result *.golden + + +logtest.log: volks4th.com tests/LOG2FILE.FB tests/LOGTEST.FB emulator/run-in-dosbox.sh + ./emulator/run-in-dosbox.sh volks4th.com logtest + +logtest.golden: tests/golden/logtest.golden + cp -p $< $@ + +%.result: %.log %.golden tests/evaluate-test.sh + rm -f $@ + tests/evaluate-test.sh $(basename $@) + diff --git a/8086/msdos/emulator/run-in-dosbox.sh b/8086/msdos/emulator/run-in-dosbox.sh new file mode 100755 index 0000000..efd0ff5 --- /dev/null +++ b/8086/msdos/emulator/run-in-dosbox.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +emulatordir="$(realpath --relative-to="$PWD" "$(dirname "${BASH_SOURCE[0]}")")" +basedir="$(realpath --relative-to="$PWD" "${emulatordir}/..")" + +forth="$1" +srcbasename="$2" +forthcmd="" +if [ -n "${srcbasename}" ]; then + forthcmd="include ${srcbasename}.fb" + logname="${srcbasename}.log" + doslogname="$(echo ${logname}|tr '[:lower:]' '[:upper:]')" + rm -f "${logname}" "${doslogname}" +fi + +exit="" +bye="" +if [ -z "${KEEPEMU}" ]; then + exit="-c exit" + bye="bye" +fi + +auto_c="" +autocmd="" +if [ -n "${forth}" ]; then + auto_c="-c" + autocmd="${forth} path f:\\;f:\\tests ${forthcmd} ${bye}" +fi + +dosbox -c "mount f ${basedir}" -c "f:" "${auto_c}" "${autocmd}" $exit + +if [ -n "${srcbasename}" ]; then + dos2unix -n "${doslogname}" "${logname}" +fi diff --git a/8086/msdos/tests/LOG2FILE.FB b/8086/msdos/tests/LOG2FILE.FB new file mode 100644 index 0000000..5f100db --- /dev/null +++ b/8086/msdos/tests/LOG2FILE.FB @@ -0,0 +1 @@ +\ logging to a text file phz 03jan22 \ load screen phz 04jan22 1 2 +thru \ log-type log-emit log-cr alsologtofile phz 04jan22 context @ dos also context ! \ vocabulary log dos also log definitions file logfile variable logfcb : log-type 2dup (type ds@ -rot logfcb @ lfputs ; : log-emit dup (emit logfcb @ fputc ; : log-cr (cr #cr logfcb @ fputc #lf logfcb @ fputc ; Output: alsologtofile log-emit log-cr log-type (del (page (at (at? ; \ logopen logclose phz 04jan22 : logopen ( -- ) logfile make isfile@ dup freset logfcb ! alsologtofile ; : logclose ( -- ) display logfcb @ fclose ; \ No newline at end of file diff --git a/8086/msdos/tests/LOGTEST.FB b/8086/msdos/tests/LOGTEST.FB new file mode 100644 index 0000000..4bf54a9 --- /dev/null +++ b/8086/msdos/tests/LOGTEST.FB @@ -0,0 +1 @@ +\ logtest.fb phz 04jan22 basic tests for log2file.fb \ loadscreen phz 04jan22 include log2file.fb logopen logtest.log .( logtest done) cr logclose \ No newline at end of file diff --git a/8086/msdos/tests/evaluate-test.sh b/8086/msdos/tests/evaluate-test.sh new file mode 100755 index 0000000..144f661 --- /dev/null +++ b/8086/msdos/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/8086/msdos/tests/golden/logtest.golden b/8086/msdos/tests/golden/logtest.golden new file mode 100644 index 0000000..6000c89 --- /dev/null +++ b/8086/msdos/tests/golden/logtest.golden @@ -0,0 +1 @@ +logtest done