Add framework for regression testing

This commit is contained in:
Hugo Villeneuve 2013-11-24 16:04:30 -05:00
parent 594b0ac005
commit 7a22c370ea
5 changed files with 48 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

30
tests/opcodes Executable file
View File

@ -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