Re: [PATCH 1/2] perf test shell: Replace '|&' with '2>&1 |' to work with more shells

From: Arnaldo Carvalho de Melo
Date: Wed Jun 20 2018 - 09:48:03 EST


Em Tue, Jun 19, 2018 at 06:49:48PM -0500, Kim Phillips escreveu:
> Since we do not specify bash (and/or zsh) as a requirement, use the

This one is minor, so could be acceptable, but then if we make bash a
requirement for 'perf test' due to the other patch in this series, we
could as well keep the shorter |& form

- Arnaldo

> standard error redirection that is more widely supported.
>
> BEFORE:
>
> $ sudo ./perf test -v 62
> 62: Check open filename arg using perf trace + vfs_getname:
> --- start ---
> test child forked, pid 27305
> ./tests/shell/trace+probe_vfs_getname.sh: 20: ./tests/shell/trace+probe_vfs_getname.sh: Syntax error: "&" unexpected
> test child finished with -2
> ---- end ----
> Check open filename arg using perf trace + vfs_getname: Skip
>
> AFTER:
>
> $ sudo ./perf test -v 64
> 64: Check open filename arg using perf trace + vfs_getname :
> --- start ---
> test child forked, pid 23008
> Added new event:
> probe:vfs_getname (on getname_flags:72 with pathname=result->name:string)
>
> You can now use it in all perf tools, such as:
>
> perf record -e probe:vfs_getname -aR sleep 1
>
> 0.361 ( 0.008 ms): touch/23032 openat(dfd: CWD, filename: /tmp/temporary_file.VEh0n, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: IRUGO|IWUGO) = 4
> test child finished with 0
> ---- end ----
> Check open filename arg using perf trace + vfs_getname: Ok
>
> Similar to commit 35435cd06081, with the same title.
>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Thomas Richter <tmricht@xxxxxxxxxxxxxxxxxx>
> Cc: Michael Petlan <mpetlan@xxxxxxxxxx>
> Signed-off-by: Kim Phillips <kim.phillips@xxxxxxx>
> ---
> tools/perf/tests/shell/trace+probe_vfs_getname.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
> index 55ad9793d544..4ce276efe6b4 100755
> --- a/tools/perf/tests/shell/trace+probe_vfs_getname.sh
> +++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
> @@ -17,7 +17,7 @@ skip_if_no_perf_probe || exit 2
> file=$(mktemp /tmp/temporary_file.XXXXX)
>
> trace_open_vfs_getname() {
> - evts=$(echo $(perf list syscalls:sys_enter_open* |& egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/')
> + evts=$(echo $(perf list syscalls:sys_enter_open* 2>&1 | egrep 'open(at)? ' | sed -r 's/.*sys_enter_([a-z]+) +\[.*$/\1/') | sed 's/ /,/')
> perf trace -e $evts touch $file 2>&1 | \
> egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ open(at)?\((dfd: +CWD, +)?filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$"
> }
> --
> 2.17.1