Skip to content

Commit 614f806

Browse files
Chun-Tse Shaonamhyung
authored andcommitted
perf test: Replace grep perl regexp with awk
perl is not universal on all machines and should be replaced with awk, which is much more common. Before: $ perf test "probe libc's inet_pton & backtrace it with ping" -v --- start --- test child forked, pid 145431 grep: Perl matching not supported in a --disable-perl-regexp build FAIL: could not add event ---- end(-1) ---- 121: probe libc's inet_pton & backtrace it with ping : FAILED! After: $ perf test "probe libc's inet_pton & backtrace it with ping" -v 121: probe libc's inet_pton & backtrace it with ping : Ok Suggested-by: Ian Rogers <[email protected]> Signed-off-by: Chun-Tse Shao <[email protected]> Reviewed-by: James Clark <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ fold James' suggestion not to escape _ in the event pattern. ] Signed-off-by: Namhyung Kim <[email protected]>
1 parent be59dba commit 614f806

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/perf/tests/shell/record+probe_libc_inet_pton.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g')
1919
nm -Dg $libc 2>/dev/null | grep -F -q inet_pton || exit 254
2020

21-
event_pattern='probe_libc:inet_pton(\_[[:digit:]]+)?'
21+
event_pattern='probe_libc:inet_pton(_[[:digit:]]+)?'
2222

2323
add_libc_inet_pton_event() {
2424

2525
event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
26-
grep -P -o "$event_pattern(?=[[:space:]]\(on inet_pton in $libc\))")
26+
awk -v ep="$event_pattern" -v l="$libc" '$0 ~ ep && $0 ~ \
27+
("\\(on inet_pton in " l "\\)") {print $1}')
2728

2829
if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
2930
printf "FAIL: could not add event\n"

0 commit comments

Comments
 (0)