From a49ed2b4e2e5eed0b5082f7f5d36123c0070b9ab Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 17 Jun 2021 11:42:16 -0700 Subject: [PATCH] perf test: Make stat bpf counters test more robust If the test is run on a hypervisor then the cycles event may not be counted, skip the test in this situation. Fail the test if cycles are not counted in the subsequent bpf counter run. Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: bpf@vger.kernel.org Link: http://lore.kernel.org/lkml/20210617184216.2075588-4-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/shell/stat_bpf_counters.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests/shell/stat_bpf_counters.sh index 85eb689fe2029..6b156dd85469b 100755 --- a/tools/perf/tests/shell/stat_bpf_counters.sh +++ b/tools/perf/tests/shell/stat_bpf_counters.sh @@ -31,7 +31,15 @@ if ! perf stat --bpf-counters true > /dev/null 2>&1; then fi base_cycles=$(perf stat --no-big-num -e cycles -- perf bench sched messaging -g 1 -l 100 -t 2>&1 | awk '/cycles/ {print $1}') +if [ "$base_cycles" == "&1 | awk '/cycles/ {print $1}') +if [ "$bpf_cycles" == "