Reduce repetition in search consistency tests with macros and aliases (#5044)

This commit is contained in:
Khairul Azhar Kasmiran 2025-03-26 21:20:07 +08:00 committed by GitHub
parent 37c1d5d18e
commit 853629366f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 8 deletions

View file

@ -951,11 +951,17 @@ RUN
NAME=consistency btw /z and /x at 0x20k multiple
FILE=--
CMDS=<<EOF
!!rizin -qc "e search.show_progress=intervals; w abc+d @@=0x20000 0x40000; /z abc+d" -1 malloc://0x40000+10 | grep "^.*[[:punct:]]0x.*" | sed "s/^.*[[:cntrl:]]//"~$0
!!rizin -qc "w abc+d @@=0x20000 0x40000; /z abc+d" malloc://0x40000+10
$str=$abc+d
$bin=$malloc://0x40000+10
$setup=$"w `$str` @@=0x20000 0x40000"
(show_intervals cmd; !!rizin -qc "e search.show_progress=intervals; `$setup`; ${cmd}" -1 `$bin` | grep "^.*[[:punct:]]0x.*" | sed "s/^.*[[:cntrl:]]//"~$0)
(show_hits cmd; !!rizin -qc "`$setup`; ${cmd}" `$bin`)
(search.show_progress cmd; .(show_intervals ${cmd}); .(show_hits ${cmd}))
.(search.show_progress "/z\ `$str`")
echo ----
!!rizin -qc "e search.show_progress=intervals; w abc+d @@=0x20000 0x40000; /x `%x abc+d`" -1 malloc://0x40000+10 | grep "^.*[[:punct:]]0x.*" | sed "s/^.*[[:cntrl:]]//"~$0
!!rizin -qc "w abc+d @@=0x20000 0x40000; /x `%x abc+d`" malloc://0x40000+10
$bytes=%x `$str`
.(search.show_progress "/x\ `$bytes`")
EOF
EXPECT=<<EOF
[0x0, 0x207ff): 1

View file

@ -128,11 +128,18 @@ RUN
NAME=consistency btw /z and /x
FILE=bins/elf/analysis/ls2
CMDS=<<EOF
!!rizin -qc "e search.show_progress=intervals; /z lib" -1 bins/elf/analysis/ls2 | grep "^.*[[:punct:]]0x.*" | sed "s/^.*[[:cntrl:]]//"~$0
!!rizin -qc "/z lib" bins/elf/analysis/ls2
$str=$lib
$bin=$bins/elf/analysis/ls2
$setup=$""
(show_intervals cmd; !!rizin -qc "e search.show_progress=intervals; `$setup`; ${cmd}" -1 `$bin` | grep "^.*[[:punct:]]0x.*" | sed "s/^.*[[:cntrl:]]//"~$0)
(show_hits cmd; !!rizin -qc "`$setup`; ${cmd}" `$bin`)
(search.show_progress cmd; .(show_intervals ${cmd}); .(show_hits ${cmd}))
.(search.show_progress "/z\ `$str`")
echo ----
!!rizin -qc "e search.show_progress=intervals; /x `%x lib`" -1 bins/elf/analysis/ls2 | grep "^.*[[:punct:]]0x.*" | sed "s/^.*[[:cntrl:]]//"~$0
!!rizin -qc "/x `%x lib`" bins/elf/analysis/ls2
$bytes=%x `$str`
.(search.show_progress "/x\ `$bytes`")
echo ----
/z lib > /dev/null
ps ascii @ hit.string.ascii.0