diff --git a/README.md b/README.md index 1764670f..06f17451 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ run_tests.sh or manually in t/. The following variables are available: + * NAME (recommend): radare2 command being tested (e.g. px). * FILE (required): File argument for radare2. * ARGS (optional): Additional arguments for radare2. If not present no additional arguments are used. diff --git a/run_tests.sh b/run_tests.sh index 2705569f..f25ce120 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -23,7 +23,7 @@ R2_SOURCED=1 # Run all tests. cd t || die "t/ doesn't exist" for file in *; do - NAME=$(echo "${file}" | sed 's/.sh$//') + TEST_NAME=$(echo "${file}" | sed 's/.sh$//') . "./${file}" done diff --git a/t/cmd_flag b/t/cmd_flag index 41690cac..03721503 100755 --- a/t/cmd_flag +++ b/t/cmd_flag @@ -5,6 +5,7 @@ ## "f" - set flags # No args should not crash (bug report #56). +NAME='f' FILE=malloc://1024 ARGS= CMDS='f' @@ -12,6 +13,7 @@ EXPECT= run_test # Add flags. +NAME='f' FILE=malloc://1024 ARGS= CMDS=' diff --git a/t/cmd_help b/t/cmd_help index 8aee9ed4..ccf1c4e8 100755 --- a/t/cmd_help +++ b/t/cmd_help @@ -5,6 +5,7 @@ ## "?v" - hex value of math expr # No crash if no arguments are given. +NAME='?v' FILE=malloc://1024 ARGS= CMDS='?v' @@ -12,6 +13,7 @@ EXPECT='0x0' run_test # File size reporting. +NAME='?v' FILE=malloc://1024 ARGS= CMDS='?v $s' diff --git a/t/cmd_search b/t/cmd_search index 70d52ab6..4be3699d 100755 --- a/t/cmd_search +++ b/t/cmd_search @@ -7,6 +7,7 @@ # Tests ASCII searching # For some reason searches entire address range rather than just # 1024 bytes XXX +NAME='/' FILE=malloc://1024 ARGS= CMDS=' @@ -26,6 +27,7 @@ run_test ## "/c" -- search for asm code # No crash if no arguments are given. +NAME='/c' FILE=malloc://1024 ARGS= CMDS='/c?' diff --git a/t/cmd_seek b/t/cmd_seek index be175238..1e82db0d 100755 --- a/t/cmd_seek +++ b/t/cmd_seek @@ -6,6 +6,7 @@ # Seeking in hex, decimal and octal in an empty file. touch empty.tmp +NAME='s' FILE=empty.tmp ARGS= CMDS=' @@ -31,6 +32,7 @@ run_test rm -f empty.tmp # Seeking in hex, decimal and octal. +NAME='s' FILE=malloc://1024 ARGS= CMDS=' @@ -57,6 +59,7 @@ run_test ## "s+"/"s-" - seek undo/redo +NAME='s+/s-' FILE=malloc://1024 ARGS= CMDS=' diff --git a/t/cmd_system b/t/cmd_system index 9d904be0..be7a3f24 100755 --- a/t/cmd_system +++ b/t/cmd_system @@ -4,6 +4,7 @@ # "!" - run commands (via system) +NAME='!' FILE=malloc://1024 ARGS= CMDS=' diff --git a/t/cmd_write b/t/cmd_write index 0579fc89..3f46589d 100755 --- a/t/cmd_write +++ b/t/cmd_write @@ -4,6 +4,7 @@ ## "wa" - write opcode +NAME='wa' FILE=malloc://1024 ARGS='-a x86 -b 32' CMDS=' @@ -19,6 +20,7 @@ run_test ## "wx" - write hex value # Writing of bytes. +NAME='wx' FILE=malloc://1024 ARGS= CMDS=' @@ -32,6 +34,7 @@ run_test ## "wo" - write in block with operation # Batch adding to bytes works (bug report #59). +NAME='wo' FILE=malloc://8 ARGS='-w' CMDS=' diff --git a/tests.sh b/tests.sh index 2a785427..37bad3eb 100644 --- a/tests.sh +++ b/tests.sh @@ -7,13 +7,14 @@ run_test() { # Set by run_tests.sh if all tests are run - otherwise get it from test # name. - if [ -z "${NAME}" ]; then - NAME=$(basename "$0" | sed 's/\.sh$//') + if [ -z "${TEST_NAME}" ]; then + TEST_NAME=$(basename "$0" | sed 's/\.sh$//') fi - printf "${NAME}" - [ -n "${VALGRIND}" ] && printf " (valgrind)" - printf " .. " + NAME_TMP="${TEST_NAME}" + [ -n "${NAME}" ] && NAME_TMP="${NAME_TMP}: ${NAME}" + [ -n "${VALGRIND}" ] && NAME_TMP="${NAME_TMP} (valgrind)" + printf "%-40s" "${NAME_TMP}" # Check required variables. if [ -z "${FILE}" ]; then @@ -34,10 +35,10 @@ run_test() { fi mkdir -p ../tmp - TMP_RAD=$(mktemp "../tmp/${NAME}-rad.XXXXXX") - TMP_OUT=$(mktemp "../tmp/${NAME}-out.XXXXXX") - TMP_VAL=$(mktemp "../tmp/${NAME}-val.XXXXXX") - TMP_EXP=$(mktemp "../tmp/${NAME}-exp.XXXXXX") + TMP_RAD=$(mktemp "../tmp/${TEST_NAME}-rad.XXXXXX") + TMP_OUT=$(mktemp "../tmp/${TEST_NAME}-out.XXXXXX") + TMP_VAL=$(mktemp "../tmp/${TEST_NAME}-val.XXXXXX") + TMP_EXP=$(mktemp "../tmp/${TEST_NAME}-exp.XXXXXX") # No colors and no user configs. R2ARGS="${R2} -e scr.color=0 -N -q -i ${TMP_RAD} ${ARGS} ${FILE}" @@ -100,6 +101,7 @@ run_test() { } test_reset() { + NAME= FILE= ARGS= CMDS=