From: Hugo Villeneuve Date: Tue, 18 Feb 2014 03:58:44 +0000 (-0500) Subject: Add tests for CLI version commands X-Git-Tag: v2.0.1~2 X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=3edaa24accd3e0eead9c9c51043961e141d3c9c6;hp=401c1d7060d3f4f71ad1fbfee7c108eaf713ded3;p=emu8051.git Add tests for CLI version commands --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 2dbcf9b..d1aa30d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,7 +19,7 @@ ASM_SRC = \ if RUN_TESTS -TESTS = \ +TESTS_ASM = \ add.sh \ mul1.sh mul2.sh \ div.sh div32u.sh \ @@ -28,6 +28,24 @@ TESTS = \ 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 $@ @@ -54,8 +72,8 @@ else 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 diff --git a/tests/cmd.sh b/tests/cmd.sh new file mode 100644 index 0000000..02cc242 --- /dev/null +++ b/tests/cmd.sh @@ -0,0 +1,29 @@ +#!/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 diff --git a/tests/cmd_de.sh b/tests/cmd_de.sh new file mode 100755 index 0000000..3a36687 --- /dev/null +++ b/tests/cmd_de.sh @@ -0,0 +1,7 @@ +#!/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 diff --git a/tests/cmd_di.sh b/tests/cmd_di.sh new file mode 100755 index 0000000..933e83d --- /dev/null +++ b/tests/cmd_di.sh @@ -0,0 +1,7 @@ +#!/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 diff --git a/tests/cmd_dp.sh b/tests/cmd_dp.sh new file mode 100755 index 0000000..6d067ab --- /dev/null +++ b/tests/cmd_dp.sh @@ -0,0 +1,7 @@ +#!/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 diff --git a/tests/cmd_dr.sh b/tests/cmd_dr.sh new file mode 100755 index 0000000..1d3c951 --- /dev/null +++ b/tests/cmd_dr.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +CMD_NAME="dr" +CMD=$'dr\x0a' +TEST_OUTPUT="| 0000 | 07 |" + +. $srcdir/cmd.sh diff --git a/tests/cmd_we.sh b/tests/cmd_we.sh new file mode 100755 index 0000000..2580329 --- /dev/null +++ b/tests/cmd_we.sh @@ -0,0 +1,7 @@ +#!/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 diff --git a/tests/cmd_wi.sh b/tests/cmd_wi.sh new file mode 100755 index 0000000..a68fed1 --- /dev/null +++ b/tests/cmd_wi.sh @@ -0,0 +1,7 @@ +#!/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 diff --git a/tests/cmd_wp.sh b/tests/cmd_wp.sh new file mode 100755 index 0000000..ca6347b --- /dev/null +++ b/tests/cmd_wp.sh @@ -0,0 +1,7 @@ +#!/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 diff --git a/tests/cmd_wr.sh b/tests/cmd_wr.sh new file mode 100755 index 0000000..96f6011 --- /dev/null +++ b/tests/cmd_wr.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +CMD_NAME="wr" +CMD=$'wr pc 0x5555 \x0a dr \x0a' +TEST_OUTPUT="| 5555 | 07 |" + +. $srcdir/cmd.sh