]> www.infradead.org Git - users/hch/misc.git/commitdiff
perf test: Refactor brstack test
authorJames Clark <james.clark@linaro.org>
Wed, 13 Aug 2025 13:38:49 +0000 (14:38 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 1 Oct 2025 18:30:58 +0000 (15:30 -0300)
check_branches() will be used by other tests in a later commit so make
it a function. And the any_call filters are duplicated and will also
be extended in a later commit, so move them to a variable.

No functional changes intended.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Adam Young <admiyo@os.amperecomputing.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/shell/test_brstack.sh

index 9138fa83bf36de18d2c646fa3187017100457f33..46e5aa9ce8ee7b22158a43487fc94e9fac91bf7c 100755 (executable)
@@ -34,6 +34,13 @@ trap_cleanup() {
 }
 trap trap_cleanup EXIT TERM INT
 
+check_branches() {
+       if ! tr -s ' ' '\n' < "$TMPDIR/perf.script" | grep -E -m1 -q "$1"; then
+               echo "Branches missing $1"
+               err=1
+       fi
+}
+
 test_user_branches() {
        echo "Testing user branch stack sampling"
 
@@ -55,11 +62,7 @@ test_user_branches() {
        )
        for x in "${expected[@]}"
        do
-               if ! tr -s ' ' '\n' < "$TMPDIR/perf.script" | grep -E -m1 -q "$x"
-               then
-                       echo "Branches missing $x"
-                       err=1
-               fi
+               check_branches "$x"
        done
        # some branch types are still not being tested:
        # IND COND_CALL COND_RET SYSCALL SYSRET IRQ SERROR NO_TX
@@ -101,14 +104,16 @@ set -e
 
 test_user_branches
 
-test_filter "any_call" "CALL|IND_CALL|COND_CALL|SYSCALL|IRQ"
+any_call="CALL|IND_CALL|COND_CALL|SYSCALL|IRQ"
+
+test_filter "any_call" "$any_call"
 test_filter "call"     "CALL|SYSCALL"
 test_filter "cond"     "COND"
 test_filter "any_ret"  "RET|COND_RET|SYSRET|ERET"
 
 test_filter "call,cond"                "CALL|SYSCALL|COND"
-test_filter "any_call,cond"            "CALL|IND_CALL|COND_CALL|IRQ|SYSCALL|COND"
-test_filter "cond,any_call,any_ret"    "COND|CALL|IND_CALL|COND_CALL|SYSCALL|IRQ|RET|COND_RET|SYSRET|ERET"
+test_filter "any_call,cond"        "$any_call|COND"
+test_filter "any_call,cond,any_ret" "$any_call|COND|RET|COND_RET"
 
 cleanup
 exit $err