Skip to content

Commit

Permalink
allow running of all tests if NOEXIT=1, tested and works,
Browse files Browse the repository at this point in the history
From Simon Ruderich
  • Loading branch information
vext01 committed Feb 5, 2012
1 parent 932cb93 commit c9f4234
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Options
The following options can be passed to make or the individual tests.

* To run tests with valgrind, use 'VALGRIND=1'.
* To continue running tests if one failed, use 'NOEXIT=1'.

Reporting Radare2 Bugs
----------------------
Expand Down
4 changes: 3 additions & 1 deletion t/asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

FILE=malloc://1024
ARGS="-a x86 -b 32"
CMDS='
Expand All @@ -9,4 +11,4 @@ pi 2
'
EXPECT="nop
mov eax, 0x21"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/echo
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

# test echo works
NAME=echo
FILE=malloc://1024
Expand All @@ -11,4 +13,4 @@ q!
"
EXPECT="fuck
yeah"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/filesize
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/sh

. ../tests.sh

# Tests file size reporting
FILE=malloc://1024
ARGS=""
CMDS='?v $s'
EXPECT="0x400"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/flag_add
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

# Test adding of flags
FILE=malloc://1024
ARGS=""
Expand All @@ -16,4 +18,4 @@ EXPECT="0x0000000c 1 skutter
0x0000029a 32 lister
0x00000000 12 rimmer
0x00000000 64 cat"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/grep
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

# Test writing of bytes
FILE=malloc://1024
ARGS=""
Expand All @@ -8,4 +10,4 @@ wx 10203040
px~:1[1]
'
EXPECT="1020"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/math
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/sh

. ../tests.sh

# test arithmetic
FILE=malloc://1024
ARGS=""
CMDS='
?v 0x10+0x30
'
EXPECT="0x40"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/noargs_Qv
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/sh

. ../tests.sh

# Some commands expect arguments and should not crash if none given
FILE=malloc://1024
ARGS=""
CMDS='?v
'
EXPECT="0x0"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/noargs_f
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/sh

. ../tests.sh

# 'f' command with no args should not crash
FILE=malloc://1024
ARGS=""
CMDS='f
'
EXPECT=""
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/redo
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

FILE=malloc://1024
ARGS=""
CMDS='
Expand Down Expand Up @@ -28,4 +30,4 @@ EXPECT="0x40
0x20
0x10
0x0"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/search_ascii
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

# Tests ASCII searching
# For some reason searches entire address range rather than just
# 1024 bytes XXX
Expand All @@ -15,4 +17,4 @@ hits: 3 hit0_0 .. hit0_2
hit0_0
hit0_1
hit0_2"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/seek
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

# Tests seeking in hex, decimal and octal
FILE=malloc://1024
ARGS=""
Expand All @@ -14,4 +16,4 @@ s
EXPECT="0x666
0xf
0x1c"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/undo
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

FILE=malloc://1024
ARGS=""
CMDS='
Expand All @@ -22,4 +24,4 @@ EXPECT="0x40
0x20
0x10
0x0"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/woa
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

# test batch adding to bytes works
FILE=malloc://8
ARGS="-w"
Expand All @@ -9,4 +11,4 @@ woa 01 @0:8
p8 8
'
EXPECT="0102030405060708"
. ../tests.sh
run_test
4 changes: 3 additions & 1 deletion t/write
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

. ../tests.sh

# test writing of bytes works
FILE=malloc://1024
ARGS=""
Expand All @@ -8,4 +10,4 @@ wx 010203
p8 3
"
EXPECT="010203"
. ../tests.sh
run_test
9 changes: 4 additions & 5 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ run_test() {
fi
cmd="echo q | ${cmd}"

echo "Next Test: `basename ${NAME}`"
echo "Next Test: `basename $0`"
echo "Running: ${cmd}"

# put expected outcome and program to run in files
Expand All @@ -32,10 +32,12 @@ run_test() {
echo "FAIL (Valgrind error)"
printf "\033[0m"
cat ${val}
[ -z "${NOEXIT}" ] && exit ${code}
elif [ ! ${code} -eq 0 ]; then
printf "\033[31m"
echo "FAIL (Radare2 crashed?)"
printf "\033[0m"
[ -z "${NOEXIT}" ] && exit ${code}
elif [ "`cat $out`" = "${EXPECT}" ]; then
printf "\033[32m"
echo "SUCCESS"
Expand All @@ -45,6 +47,7 @@ run_test() {
echo "FAIL (Unexpected outcome)"
printf "\033[0m"
diff -u ${exp} ${out}
[ -z "${NOEXIT}" ] && exit 1
fi
rm -f ${out} ${val} ${rad} ${exp}
echo "-------------------------------------------------------------------"
Expand All @@ -59,7 +62,3 @@ out=`mktemp out.XXXXXX`
val=`mktemp val.XXXXXX`
rad=`mktemp rad.XXXXXX`
exp=`mktemp exp.XXXXXX`

NAME=$0

run_test

0 comments on commit c9f4234

Please sign in to comment.