lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e8c28a7e-bc08-4c50-96ca-afe62cfcf9fd@linaro.org>
Date: Mon, 23 Jun 2025 15:12:00 +0100
From: James Clark <james.clark@...aro.org>
To: Chun-Tse Shao <ctshao@...gle.com>
Cc: wy.shih90@...il.com, Ian Rogers <irogers@...gle.com>,
 peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
 namhyung@...nel.org, mark.rutland@....com,
 alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
 adrian.hunter@...el.com, kan.liang@...ux.intel.com, tmricht@...ux.ibm.com,
 leo.yan@....com, atrajeev@...ux.vnet.ibm.com,
 linux-perf-users@...r.kernel.org,
 "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1] perf test: Replace grep perl regexp with awk



On 20/06/2025 6:40 pm, Chun-Tse Shao wrote:
> 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 <irogers@...gle.com>
> Signed-off-by: Chun-Tse Shao <ctshao@...gle.com>
> ---
>   tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> index c4bab5b5cc59..aaa5ee06ae18 100755
> --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
> @@ -23,7 +23,8 @@ event_pattern='probe_libc:inet_pton(\_[[:digit:]]+)?'
>   add_libc_inet_pton_event() {
> 
>   	event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
> -			grep -P -o "$event_pattern(?=[[:space:]]\(on inet_pton in $libc\))")
> +			awk -v ep="$event_pattern" -v l="$libc" '$0 ~ ep && $0 ~ \
> +			("\\(on inet_pton in " l "\\)") {print $1}')
> 
>   	if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
>   		printf "FAIL: could not add event\n"
> --
> 2.50.0.rc2.701.gf1e915cc24-goog
> 

Minor nit: the underscore in event_pattern (not shown in the diff) never 
needed to be escaped.

But now we're using awk it gives a warning so we should remove it in 
case anyone is searching through the output:

   awk: warning: escape sequence `\_' treated as plain `_'

Reviewed-by: James Clark <james.clark@...aro.org>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ