From 7a22c370eadad96e32adfd11958a1df155ca62ab Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sun, 24 Nov 2013 16:04:30 -0500 Subject: [PATCH] Add framework for regression testing --- Makefile.am | 3 ++- tests/Makefile.am | 11 ++++++++--- tests/mul1.asm | 7 ++++--- tests/mul2.asm | 7 ++++--- tests/opcodes | 30 ++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 10 deletions(-) create mode 100755 tests/opcodes diff --git a/Makefile.am b/Makefile.am index b387b0f..89723db 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,4 +23,5 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config-h.in \ $(ac_aux_dir)/install-sh $(ac_aux_dir)/missing \ $(ac_aux_dir)/mkinstalldirs $(ac_aux_dir)/config.guess \ $(ac_aux_dir)/config.sub $(ac_aux_dir)/ltmain.sh \ - $(ac_aux_dir)/compile + $(ac_aux_dir)/compile \ + $(ac_aux_dir)/test-driver diff --git a/tests/Makefile.am b/tests/Makefile.am index baae742..be13db3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,10 +1,13 @@ -# tests for emu8051 +# Regression tests for emu8051 AS51 = asem SUFFIXES = .hex .asm -bin_PROGRAMS = mul1.hex mul2.hex +TESTS = \ + opcodes + +check_PROGRAMS = mul1.hex mul2.hex mul1.hex: mul1.asm @@ -13,6 +16,8 @@ mul2.hex: mul2.asm .asm.hex: $(AS51) $< -CLEANFILES = *~ *.lst +EXTRA_DIST = $(TESTS) + +CLEANFILES = *~ *.lst *.log MAINTAINERCLEANFILES = Makefile.in diff --git a/tests/mul1.asm b/tests/mul1.asm index 4e600a6..b56857f 100644 --- a/tests/mul1.asm +++ b/tests/mul1.asm @@ -1,9 +1,9 @@ ; Test program to verify correct emu8051 operation ; ; Test desc: MUL AB (no overflow) -; Test output1: ACC = 0xC2 -; Test output2: B = 0x00 -; Test output2: PSW = 0x01 +; Test output1: A = $C2 +; Test output2: B = $00 +; Test output3: PSW = $01 CSEG @@ -13,4 +13,5 @@ MOV B, #002h MUL AB ; CY should be cleared, OV should be cleared + LJMP 0FFF0h END diff --git a/tests/mul2.asm b/tests/mul2.asm index ec931d6..1925d28 100644 --- a/tests/mul2.asm +++ b/tests/mul2.asm @@ -1,9 +1,9 @@ ; Test program to verify correct emu8051 operation ; ; Test desc: MUL AB (overflow) -; Test output1: ACC = 0x5B -; Test output2: B = 0x0B -; Test output3: PSW = 0x05 +; Test output1: A = $5B +; Test output2: B = $0B +; Test output3: PSW = $05 CSEG @@ -13,4 +13,5 @@ MOV B, #013h MUL AB ; CY should be cleared, OV should be cleared + LJMP 0FFF0h END diff --git a/tests/opcodes b/tests/opcodes new file mode 100755 index 0000000..dc30e5e --- /dev/null +++ b/tests/opcodes @@ -0,0 +1,30 @@ +#!/bin/sh + +lf=test.log + +STOP_ADDRESS="0xFFF0" +XRAM_SIZE="256" + +for f in *.hex; do + name=$(basename ${f} .hex) + + echo "Testing ${name}" > ${lf} + ../src/emu8051-cli -d 2 --xram=${XRAM_SIZE} -s ${STOP_ADDRESS} ${f} >> ${lf} + if $? -ne 0; then + return 1 + fi + + while read line; do + if echo ${line} | grep -q "; Test output"; then + test_str=$(echo ${line} | sed "s/^; Test output[0-9]: //") + + if ! grep -q "${test_str}" ${lf}; then + echo "Failed test: ${test_str}" >> ${lf} + exit 1 + fi + fi + done < ${name}.asm + +done + +exit 0 -- 2.20.1