if RUN_TESTS
-TESTS = \
+TESTS_ASM = \
add.sh \
mul1.sh mul2.sh \
div.sh div32u.sh \
sqroot.sh \
timer0.sh timer1.sh timer2.sh
+TESTS_CMD = \
+ cmd_dr.sh \
+ cmd_de.sh \
+ cmd_di.sh \
+ cmd_dp.sh \
+ cmd_we.sh \
+ cmd_wi.sh \
+ cmd_wp.sh \
+ cmd_wr.sh
+
+TESTS = \
+ $(TESTS_CMD) \
+ $(TESTS_ASM)
+
+# If you do not want an implicit rule to be used for a target that has no
+# commands, you can give that target empty commands by writing a semicolon.
+cli.sh: ;
+
# Tell make how to generate a .sh file after a .hex file is generated:
.hex.sh:
@ln -sf $(srcdir)/opcodes.sh $@
TESTS =
endif
-EXTRA_DIST = opcodes.sh $(ASM_SRC)
+EXTRA_DIST = $(TESTS_CMD) cmd.sh opcodes.sh $(ASM_SRC)
-CLEANFILES = *~ *.lst *.hex $(TESTS)
+CLEANFILES = *~ *.lst *.hex $(TESTS_ASM)
MAINTAINERCLEANFILES = Makefile.in
--- /dev/null
+#!/bin/sh
+
+# Get the symlink name (how we were called):
+test_name=`basename $0`
+
+lf=${test_name}.log
+
+name=$(basename ${test_name} .sh)
+
+echo "Testing command ${CMD_NAME}" > ${lf}
+
+echo "${CMD}" | ../src/cli/emu8051-cli -d 2 >> ${lf}
+if test $? -ne 0 ; then
+ return 1
+fi
+
+# Verify syntax errors
+if grep -q "syntax" ${lf}; then
+ echo "Failed test: ${CMD_NAME} (syntax error)" >> ${lf}
+ exit 1
+fi
+
+# Verify for valid test values
+if ! grep -q "${TEST_OUTPUT}" ${lf}; then
+ echo "Failed test: ${CMD_NAME} (values not found)" >> ${lf}
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="de"
+CMD=$'de 0x00 16\x0a'
+TEST_OUTPUT="0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................"
+
+. $srcdir/cmd.sh
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="di"
+CMD=$'di 0x80 16\x0a'
+TEST_OUTPUT="0080 FF 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................"
+
+. $srcdir/cmd.sh
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="dp"
+CMD=$'dp 0x00 16\x0a'
+TEST_OUTPUT="0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................"
+
+. $srcdir/cmd.sh
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="dr"
+CMD=$'dr\x0a'
+TEST_OUTPUT="| 0000 | 07 |"
+
+. $srcdir/cmd.sh
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="we"
+CMD=$'we 0x80 0x30\x0a we 0x81 0x31\x0a we 0x82 0x32\x0a de 0x80 16'
+TEST_OUTPUT="0080 30 31 32 00 00 00 00 00 00 00 00 00 00 00 00 00 012............."
+
+. $srcdir/cmd.sh
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="wi"
+CMD=$'wi 0x40 0x30\x0a wi 0x41 0x31\x0a wi 0x42 0x32\x0a di 0x40 16'
+TEST_OUTPUT="0040 30 31 32 00 00 00 00 00 00 00 00 00 00 00 00 00 012............."
+
+. $srcdir/cmd.sh
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="wp"
+CMD=$'wp 0x1000 0x41\x0a wp 0x1001 0x42\x0a wp 0x1002 0x43\x0a dp 0x1000 16'
+TEST_OUTPUT="1000 41 42 43 00 00 00 00 00 00 00 00 00 00 00 00 00 ABC............."
+
+. $srcdir/cmd.sh
--- /dev/null
+#!/bin/sh
+
+CMD_NAME="wr"
+CMD=$'wr pc 0x5555 \x0a dr \x0a'
+TEST_OUTPUT="| 5555 | 07 |"
+
+. $srcdir/cmd.sh