Skip to content

Commit

Permalink
added some tests for analysis x86 32bit functions (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaemmert authored and radare committed Nov 18, 2016
1 parent 7499bdd commit 73bc5ee
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 0 deletions.
106 changes: 106 additions & 0 deletions t.anal/x86/cmd_a2f_x86
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/sh
# GPL 3+ - Copyright (C) 2012 pancake, Edd Barrett, Simon Ruderich
for a in . .. ../.. ; do [ -e $a/tests.sh ] && . $a/tests.sh ; done

NAME='a2f jmp after ret'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f26b8ffffffff4839ca7c1c498b4838498b5138b8010000004839ca7f0ab8ffffffff4839ca7d025dc34883c7684883c6685dc3
a2f
afl~?
'
EXPECT='1
'
run_test


NAME='a2f jmp after ret'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f26b8ffffffff4839ca7c1c498b4838498b5138b8010000004839ca7f0ab8ffffffff4839ca7d025dc34883c7684883c6685dc3
a2f
afl~?
afl~[2]
'
EXPECT='1
60
'
run_test


NAME='a2f 8 bbs 4 ret and some jumps'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=32
wx 85c0740585c07405c385c0eb01c385c07401c3b8efbeaddec3
a2f
afb
'
EXPECT='0x00000000 0x00000004 00:0000 4 j 0x00000009 f 0x00000004
0x00000004 0x00000008 00:0000 4 j 0x0000000d f 0x00000008
0x00000008 0x00000009 00:0000 1
0x00000009 0x0000000d 00:0000 4 j 0x0000000e
0x0000000d 0x0000000e 00:0000 1
0x0000000e 0x00000012 00:0000 4 j 0x00000013 f 0x00000012
0x00000012 0x00000013 00:0000 1
0x00000013 0x00000019 00:0000 6
'
run_test


NAME='a2f 3bbs with entry in the middle of the function'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=32
wx 31c031c983c10183c10285c975f231c931c040c3
s 0xa
a2f
afb
'
EXPECT='0x00000000 0x0000000a 00:0000 10 j 0x0000000a
0x0000000a 0x0000000e 00:0000 4 j 0x00000000 f 0x0000000e
0x0000000e 0x00000014 00:0000 6
'

run_test


NAME='a2f 6 bbs with entry at the end of the function'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=32
wx 31c083c00183e801750831c083e80183c00131c983c10183e90175e431d283ea0183c2017402ebd831c0c3
s 0x26
a2f
afb
'
EXPECT='0x00000000 0x0000000a 00:0000 10 j 0x00000012 f 0x0000000a
0x0000000a 0x00000012 00:0000 8 j 0x00000012
0x00000012 0x0000001c 00:0000 10 j 0x00000000 f 0x0000001c
0x0000001c 0x00000026 00:0000 10 j 0x00000028 f 0x00000026
0x00000026 0x00000028 00:0000 2 j 0x00000000
0x00000028 0x0000002b 00:0000 3
'
run_test
68 changes: 68 additions & 0 deletions t.anal/x86/cmd_anal_x86
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,71 @@ EXPECT='1
60
'
run_test


NAME='af 8 bbs 4 ret and some jumps'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=32
wx 85c0740585c07405c385c0eb01c385c07401c3b8efbeaddec3
af
afb
'
EXPECT='0x00000000 0x00000004 00:0000 4 j 0x00000009 f 0x00000004
0x00000004 0x00000008 00:0000 4 j 0x0000000d f 0x00000008
0x00000008 0x00000009 00:0000 1
0x00000009 0x0000000d 00:0000 4 j 0x0000000e
0x0000000d 0x0000000e 00:0000 1
0x0000000e 0x00000012 00:0000 4 j 0x00000013 f 0x00000012
0x00000012 0x00000013 00:0000 1
0x00000013 0x00000019 00:0000 6
'
run_test


NAME='af 3bbs with entry in the middle of the function'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=32
wx 31c031c983c10183c10285c975f231c931c040c3
s 0xa
af
afb
'
EXPECT='0x00000000 0x0000000a 00:0000 10 j 0x0000000a
0x0000000a 0x0000000e 00:0000 4 j 0x00000000 f 0x0000000e
0x0000000e 0x00000014 00:0000 6
'

run_test


NAME='af 6 bbs with entry at the end of the function'
BROKEN=
FILE=malloc://512
ARGS=
CMDS='
e anal.hasnext=0
e asm.arch=x86
e asm.bits=32
wx 31c083c00183e801750831c083e80183c00131c983c10183e90175e431d283ea0183c2017402ebd831c0c3
s 0x26
af
afb
'
EXPECT='0x00000000 0x0000000a 00:0000 10 j 0x00000012 f 0x0000000a
0x0000000a 0x00000012 00:0000 8 j 0x00000012
0x00000012 0x0000001c 00:0000 10 j 0x00000000 f 0x0000001c
0x0000001c 0x00000026 00:0000 10 j 0x00000028 f 0x00000026
0x00000026 0x00000028 00:0000 2 j 0x00000000
0x00000028 0x0000002b 00:0000 3
'
run_test

0 comments on commit 73bc5ee

Please sign in to comment.