From: James Clark <hidden> Date: 2021-10-28 13:48:46
These tests were either failing or printing warnings on my Ubuntu 18
and 20 systems. I'm not sure if there is a system where /bin/sh allows
bash constructs, or perf invokes bash instead of sh, but I saw that
there have been similar fixes made in the past so I assume this should
be done.
Adding set -e to the scripts didn't highlight these issues, so I didn't
do it at this time.
For stat_bpf_counters.sh, there are further bashisms after the skip,
but I couldn't get BPF working, so I only fixed it up to that point.
Applies to perf/core 624ff63abfd36
James Clark (3):
perf test: Remove bash construct from stat_bpf_counters.sh test
perf tests: Remove bash construct from record+zstd_comp_decomp.sh
perf tests: Remove bash constructs from stat_all_pmu.sh
tools/perf/tests/shell/record+zstd_comp_decomp.sh | 2 +-
tools/perf/tests/shell/stat_all_pmu.sh | 4 ++--
tools/perf/tests/shell/stat_bpf_counters.sh | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
--
2.28.0
From: James Clark <hidden> Date: 2021-10-28 13:49:11
Currently the test skips with an error because == only works in bash:
$ ./perf test 91 -v
Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
91: perf stat --bpf-counters test :
--- start ---
test child forked, pid 44586
./tests/shell/stat_bpf_counters.sh: 26: [: -v: unexpected operator
test child finished with -2
---- end ----
perf stat --bpf-counters test: Skip
Changing == to = does the same thing, but doesn't result in an error:
./perf test 91 -v
Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
91: perf stat --bpf-counters test :
--- start ---
test child forked, pid 45833
Skipping: --bpf-counters not supported
Error: unknown option `bpf-counters'
[...]
test child finished with -2
---- end ----
perf stat --bpf-counters test: Skip
Signed-off-by: James Clark <redacted>
---
tools/perf/tests/shell/stat_bpf_counters.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -23,7 +23,7 @@ compare_number()# skip if --bpf-counters is not supportedif!perfstat--bpf-counterstrue>/dev/null2>&1;then-if["$1"=="-v"];then+if["$1"="-v"];thenecho"Skipping: --bpf-counters not supported"perf--no-pagerstat--bpf-counterstrue||truefi
From: James Clark <hidden> Date: 2021-10-28 13:49:17
Commit 463538a383a2 ("perf tests: Fix test 68 zstd compression for
s390") inadvertently removed the -g flag from all platforms rather than
just s390, because the [[ ]] construct fails in sh. Changing to single
brackets restores testing of call graphs and removes the following error
from the output:
$ ./perf test -v 85
85: Zstd perf.data compression/decompression :
--- start ---
test child forked, pid 50643
Collecting compressed record file:
./tests/shell/record+zstd_comp_decomp.sh: 15: [[: not found
Fixes: 463538a383a2 ("perf tests: Fix test 68 zstd compression for s390")
Signed-off-by: James Clark <redacted>
---
tools/perf/tests/shell/record+zstd_comp_decomp.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: James Clark <hidden> Date: 2021-10-28 13:49:29
The tests were passing but without testing and were printing the
following:
$ ./perf test -v 90
90: perf all PMU test :
--- start ---
test child forked, pid 51650
Testing cpu/branch-instructions/
./tests/shell/stat_all_pmu.sh: 10: [:
Performance counter stats for 'true':
137,307 cpu/branch-instructions/
0.001686672 seconds time elapsed
0.001376000 seconds user
0.000000000 seconds sys: unexpected operator
Changing the regexes to a grep works in sh and prints this:
$ ./perf test -v 90
90: perf all PMU test :
--- start ---
test child forked, pid 60186
[...]
Testing tlb_flush.stlb_any
test child finished with 0
---- end ----
perf all PMU test: Ok
Signed-off-by: James Clark <redacted>
---
tools/perf/tests/shell/stat_all_pmu.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -7,11 +7,11 @@ set -eforpin$(perflist--raw-dumppmu);doecho"Testing $p"result=$(perfstat-e"$p"true2>&1)-if[[!"$result"=~"$p"]]&&[[!"$result"=~"<not supported>"]];then+if!echo"$result"|grep-q"$p"&&!echo"$result"|grep-q"<not supported>";then# We failed to see the event and it is supported. Possibly the workload was# too small so retry with something longer.result=$(perfstat-e"$p"perfbenchinternalssynthesize2>&1)-if[[!"$result"=~"$p"]];then+if!echo"$result"|grep-q"$p";thenecho"Event '$p' not printed in:"echo"$result"exit1