Add tests for CLI version commands

This commit is contained in:
Hugo Villeneuve 2014-02-17 22:58:44 -05:00
parent 401c1d7060
commit 3edaa24acc
10 changed files with 106 additions and 3 deletions

View File

@ -19,7 +19,7 @@ ASM_SRC = \
if RUN_TESTS if RUN_TESTS
TESTS = \ TESTS_ASM = \
add.sh \ add.sh \
mul1.sh mul2.sh \ mul1.sh mul2.sh \
div.sh div32u.sh \ div.sh div32u.sh \
@ -28,6 +28,24 @@ TESTS = \
sqroot.sh \ sqroot.sh \
timer0.sh timer1.sh timer2.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: # Tell make how to generate a .sh file after a .hex file is generated:
.hex.sh: .hex.sh:
@ln -sf $(srcdir)/opcodes.sh $@ @ln -sf $(srcdir)/opcodes.sh $@
@ -54,8 +72,8 @@ else
TESTS = TESTS =
endif 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 MAINTAINERCLEANFILES = Makefile.in

29
tests/cmd.sh Normal file
View File

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

7
tests/cmd_de.sh Executable file
View File

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

7
tests/cmd_di.sh Executable file
View File

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

7
tests/cmd_dp.sh Executable file
View File

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

7
tests/cmd_dr.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
CMD_NAME="dr"
CMD=$'dr\x0a'
TEST_OUTPUT="| 0000 | 07 |"
. $srcdir/cmd.sh

7
tests/cmd_we.sh Executable file
View File

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

7
tests/cmd_wi.sh Executable file
View File

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

7
tests/cmd_wp.sh Executable file
View File

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

7
tests/cmd_wr.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
CMD_NAME="wr"
CMD=$'wr pc 0x5555 \x0a dr \x0a'
TEST_OUTPUT="| 5555 | 07 |"
. $srcdir/cmd.sh