Add search-consistency-test macro to reduce repetition (#5063)

This commit is contained in:
Khairul Azhar Kasmiran 2025-04-03 20:59:14 +08:00 committed by GitHub
parent b0e8fbbbaa
commit 3b5c817786
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 10 deletions

View file

@ -955,10 +955,9 @@ CMDS=<<EOF
$str=$abc+d
$bin=$malloc://0x40000+10
$setup=$"w `$str` @@=0x20000 0x40000"
.(search.show_progress "/z `$str`")
echo ----
$bytes=%x `$str`
.(search.show_progress "/x `$bytes`")
$cmd_z=$/z ${str}
$cmd_x=$/x ${bytes}
.(search-consistency-test)
EOF
EXPECT=<<EOF
[0x0, 0x207ff): 1

View file

@ -132,11 +132,9 @@ CMDS=<<EOF
$str=$lib
$bin=$bins/elf/analysis/ls2
$setup=$""
.(search.show_progress "/z `$str`")
echo ----
$bytes=%x `$str`
.(search.show_progress "/x `$bytes`")
$cmd_z=$/z ${str}
$cmd_x=$/x ${bytes}
.(search-consistency-test)
echo ----
/z lib > /dev/null
ps ascii @ hit.string.ascii.0

View file

@ -1,5 +1,9 @@
# $setup and $bin need to be defined before calling this script's macros
# $setup and $bin need to be defined before calling these macros:
(show_intervals cmd; !!rizin -qc "e search.show_progress=intervals; `$setup`; `echo ${cmd}`" -1 `$bin` | grep "^.*[[:punct:]]0x.*" | sed "s/^.*[[:cntrl:]]//"~$0)
(show_hits cmd; !!rizin -qc "`$setup`; `echo ${cmd}`" `$bin`)
(search.show_progress cmd; .(show_intervals ${cmd}); .(show_hits ${cmd}))
# Additionally, $cmd_z, $cmd_x and $str need to be defined before calling the macro below:
(search-consistency-test; .(search.show_progress "(cmd_z str; `$cmd_z`); .(cmd_z `$str`)"); echo "----"; .(search.show_progress "(cmd_x bytes; `$cmd_x`); .(cmd_x \`%x `$str`\`)"))