Skip to content

Commit

Permalink
Display additional test name. Also align test output.
Browse files Browse the repository at this point in the history
  • Loading branch information
rudis committed Feb 7, 2012
1 parent b7b4ed8 commit ecf8ea3
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions t/cmd_flag
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
## "f" - set flags

# No args should not crash (bug report #56).
NAME='f'
FILE=malloc://1024
ARGS=
CMDS='f'
EXPECT=
run_test

# Add flags.
NAME='f'
FILE=malloc://1024
ARGS=
CMDS='
Expand Down
2 changes: 2 additions & 0 deletions t/cmd_help
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
## "?v" - hex value of math expr

# No crash if no arguments are given.
NAME='?v'
FILE=malloc://1024
ARGS=
CMDS='?v'
EXPECT='0x0'
run_test

# File size reporting.
NAME='?v'
FILE=malloc://1024
ARGS=
CMDS='?v $s'
Expand Down
2 changes: 2 additions & 0 deletions t/cmd_search
Original file line number Diff line number Diff line change
Expand Up @@ -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='
Expand All @@ -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?'
Expand Down
3 changes: 3 additions & 0 deletions t/cmd_seek
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# Seeking in hex, decimal and octal in an empty file.
touch empty.tmp
NAME='s'
FILE=empty.tmp
ARGS=
CMDS='
Expand All @@ -31,6 +32,7 @@ run_test
rm -f empty.tmp

# Seeking in hex, decimal and octal.
NAME='s'
FILE=malloc://1024
ARGS=
CMDS='
Expand All @@ -57,6 +59,7 @@ run_test

## "s+"/"s-" - seek undo/redo

NAME='s+/s-'
FILE=malloc://1024
ARGS=
CMDS='
Expand Down
1 change: 1 addition & 0 deletions t/cmd_system
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# "!" - run commands (via system)

NAME='!'
FILE=malloc://1024
ARGS=
CMDS='
Expand Down
3 changes: 3 additions & 0 deletions t/cmd_write
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## "wa" - write opcode

NAME='wa'
FILE=malloc://1024
ARGS='-a x86 -b 32'
CMDS='
Expand All @@ -19,6 +20,7 @@ run_test
## "wx" - write hex value

# Writing of bytes.
NAME='wx'
FILE=malloc://1024
ARGS=
CMDS='
Expand All @@ -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='
Expand Down
20 changes: 11 additions & 9 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down Expand Up @@ -100,6 +101,7 @@ run_test() {
}

test_reset() {
NAME=
FILE=
ARGS=
CMDS=
Expand Down

0 comments on commit ecf8ea3

Please sign in to comment.