bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix various bash constructs in tests
@ 2021-10-28 13:48 James Clark
  2021-10-28 13:48 ` [PATCH 1/3] perf test: Remove bash construct from stat_bpf_counters.sh test James Clark
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: James Clark @ 2021-10-28 13:48 UTC (permalink / raw)
  To: acme, linux-perf-users, f.fainelli, irogers
  Cc: James Clark, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Thomas Richter, Sumanth Korikkar,
	Arnaldo Carvalho de Melo, linux-kernel, netdev, bpf

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] perf test: Remove bash construct from stat_bpf_counters.sh test
  2021-10-28 13:48 [PATCH 0/3] Fix various bash constructs in tests James Clark
@ 2021-10-28 13:48 ` James Clark
  2021-10-28 13:48 ` [PATCH 2/3] perf tests: Remove bash construct from record+zstd_comp_decomp.sh James Clark
  2021-10-28 13:48 ` [PATCH 3/3] perf tests: Remove bash constructs from stat_all_pmu.sh James Clark
  2 siblings, 0 replies; 4+ messages in thread
From: James Clark @ 2021-10-28 13:48 UTC (permalink / raw)
  To: acme, linux-perf-users, f.fainelli, irogers
  Cc: James Clark, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Arnaldo Carvalho de Melo,
	Sumanth Korikkar, Thomas Richter, linux-kernel, netdev, bpf

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 <james.clark@arm.com>
---
 tools/perf/tests/shell/stat_bpf_counters.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests/shell/stat_bpf_counters.sh
index 2aed20dc2262..13473aeba489 100755
--- a/tools/perf/tests/shell/stat_bpf_counters.sh
+++ b/tools/perf/tests/shell/stat_bpf_counters.sh
@@ -23,7 +23,7 @@ compare_number()
 
 # skip if --bpf-counters is not supported
 if ! perf stat --bpf-counters true > /dev/null 2>&1; then
-	if [ "$1" == "-v" ]; then
+	if [ "$1" = "-v" ]; then
 		echo "Skipping: --bpf-counters not supported"
 		perf --no-pager stat --bpf-counters true || true
 	fi
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] perf tests: Remove bash construct from record+zstd_comp_decomp.sh
  2021-10-28 13:48 [PATCH 0/3] Fix various bash constructs in tests James Clark
  2021-10-28 13:48 ` [PATCH 1/3] perf test: Remove bash construct from stat_bpf_counters.sh test James Clark
@ 2021-10-28 13:48 ` James Clark
  2021-10-28 13:48 ` [PATCH 3/3] perf tests: Remove bash constructs from stat_all_pmu.sh James Clark
  2 siblings, 0 replies; 4+ messages in thread
From: James Clark @ 2021-10-28 13:48 UTC (permalink / raw)
  To: acme, linux-perf-users, f.fainelli, irogers
  Cc: James Clark, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Arnaldo Carvalho de Melo,
	Sumanth Korikkar, Thomas Richter, linux-kernel, netdev, bpf

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 <james.clark@arm.com>
---
 tools/perf/tests/shell/record+zstd_comp_decomp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/record+zstd_comp_decomp.sh b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
index 8a168cf8bacc..49bd875d5122 100755
--- a/tools/perf/tests/shell/record+zstd_comp_decomp.sh
+++ b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
@@ -12,7 +12,7 @@ skip_if_no_z_record() {
 
 collect_z_record() {
 	echo "Collecting compressed record file:"
-	[[ "$(uname -m)" != s390x ]] && gflag='-g'
+	[ "$(uname -m)" != s390x ] && gflag='-g'
 	$perf_tool record -o $trace_file $gflag -z -F 5000 -- \
 		dd count=500 if=/dev/urandom of=/dev/null
 }
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] perf tests: Remove bash constructs from stat_all_pmu.sh
  2021-10-28 13:48 [PATCH 0/3] Fix various bash constructs in tests James Clark
  2021-10-28 13:48 ` [PATCH 1/3] perf test: Remove bash construct from stat_bpf_counters.sh test James Clark
  2021-10-28 13:48 ` [PATCH 2/3] perf tests: Remove bash construct from record+zstd_comp_decomp.sh James Clark
@ 2021-10-28 13:48 ` James Clark
  2 siblings, 0 replies; 4+ messages in thread
From: James Clark @ 2021-10-28 13:48 UTC (permalink / raw)
  To: acme, linux-perf-users, f.fainelli, irogers
  Cc: James Clark, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Arnaldo Carvalho de Melo,
	Thomas Richter, Sumanth Korikkar, linux-kernel, netdev, bpf

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 <james.clark@arm.com>
---
 tools/perf/tests/shell/stat_all_pmu.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/stat_all_pmu.sh b/tools/perf/tests/shell/stat_all_pmu.sh
index 2de7fd0394fd..b30dba455f36 100755
--- a/tools/perf/tests/shell/stat_all_pmu.sh
+++ b/tools/perf/tests/shell/stat_all_pmu.sh
@@ -7,11 +7,11 @@ set -e
 for p in $(perf list --raw-dump pmu); do
   echo "Testing $p"
   result=$(perf stat -e "$p" true 2>&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=$(perf stat -e "$p" perf bench internals synthesize 2>&1)
-    if [[ ! "$result" =~ "$p" ]]; then
+    if ! echo "$result" | grep -q "$p" ; then
       echo "Event '$p' not printed in:"
       echo "$result"
       exit 1
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-28 13:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 13:48 [PATCH 0/3] Fix various bash constructs in tests James Clark
2021-10-28 13:48 ` [PATCH 1/3] perf test: Remove bash construct from stat_bpf_counters.sh test James Clark
2021-10-28 13:48 ` [PATCH 2/3] perf tests: Remove bash construct from record+zstd_comp_decomp.sh James Clark
2021-10-28 13:48 ` [PATCH 3/3] perf tests: Remove bash constructs from stat_all_pmu.sh James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).