Run each test separately from single shell script
authorHugo Villeneuve <hugo@hugovil.com>
Fri, 29 Nov 2013 04:11:43 +0000 (23:11 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Mon, 2 Dec 2013 02:00:08 +0000 (21:00 -0500)
Each new test is simply a link to opcodes.sh, generatated automatically.

tests/Makefile.am
tests/opcodes [deleted file]
tests/opcodes.sh [new file with mode: 0755]

index 53f352b..147846b 100644 (file)
@@ -2,28 +2,36 @@
 
 AS51 = asem
 
-SUFFIXES = .hex .asm
+SUFFIXES = .hex .asm .sh
 
+# Should find a way to automatically generate each symlink here:
 TESTS = \
-    opcodes
-
-check_PROGRAMS = mul1.hex mul2.hex div.hex orl.hex anl.hex mov.hex timer0.hex timer1.hex timer2.hex
-
-mul1.hex: mul1.asm
-mul2.hex: mul2.asm
-div.hex: div.asm
-orl.hex: orl.asm
-anl.hex: anl.asm
-mov.hex: mov.asm
-timer0.hex: timer0.asm
-timer1.hex: timer1.asm
-timer2.hex: timer2.asm
-
+    mul1.sh mul2.sh \
+    div.sh \
+    orl.sh anl.sh \
+    mov.sh \
+    timer0.sh timer1.sh timer2.sh
+
+mul1.sh: mul1.hex
+mul2.sh: mul2.hex
+div.sh: div.hex
+orl.sh: orl.hex
+anl.sh: anl.hex
+mov.sh: mov.hex
+timer0.sh: timer0.hex
+timer1.sh: timer1.hex
+timer2.sh: timer2.hex
+
+# Tell make how to generate a .sh file after a .hex file is generated:
+.hex.sh:
+       ln -sf opcodes.sh $@
+
+# Tell make how to generate a .hex file from a .asm source file:
 .asm.hex:
        $(AS51) $<
 
-EXTRA_DIST = $(TESTS)
+EXTRA_DIST = $(TESTS) *.asm *.hex
 
-CLEANFILES = *~ *.lst *.log
+CLEANFILES = *~ *.lst *.hex $(TESTS)
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/tests/opcodes b/tests/opcodes
deleted file mode 100755 (executable)
index 0dba166..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/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: //")
-
-            if ! grep -q "${test_str}" ${lf}; then
-                echo "Failed test: ${test_str}" >> ${lf}
-                exit 1
-            fi
-        fi
-    done < ${name}.asm
-
-done
-
-exit 0
diff --git a/tests/opcodes.sh b/tests/opcodes.sh
new file mode 100755 (executable)
index 0000000..f6ff764
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# Get the symlink name (how we were called):
+test_name=`basename $0`
+
+lf=${test_name}.log
+
+STOP_ADDRESS="0xFFF0"
+XRAM_SIZE="256"
+
+name=$(basename ${test_name} .sh)
+hexfile=${name}.hex
+
+echo "Testing ${name}.hex" > ${lf}
+../src/emu8051-cli -d 2 --xram=${XRAM_SIZE} -s ${STOP_ADDRESS} ${hexfile} >> ${lf}
+if test $? -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: //")
+
+        if ! grep -q "${test_str}" ${lf}; then
+            echo "Failed test: ${test_str}" >> ${lf}
+            exit 1
+        fi
+    fi
+done < ${name}.asm
+
+exit 0