Commit dab5b6cb authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo

perf test: Add new test cases for the branch counter feature

Enhance the test case for the branch counter feature.

Now, the test verifies:

- The new filter can be successfully applied on the supported platforms.
- The counter value can be outputted via the perf report -D
- The counter value and the abbr name can be outputted via the
  perf script (New)
Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240813160208.2493643-10-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6f9d8d1d
...@@ -21,6 +21,7 @@ testprog="perf test -w thloop" ...@@ -21,6 +21,7 @@ testprog="perf test -w thloop"
cpu_pmu_dir="/sys/bus/event_source/devices/cpu*" cpu_pmu_dir="/sys/bus/event_source/devices/cpu*"
br_cntr_file="/caps/branch_counter_nr" br_cntr_file="/caps/branch_counter_nr"
br_cntr_output="branch stack counters" br_cntr_output="branch stack counters"
br_cntr_script_output="br_cntr: A"
cleanup() { cleanup() {
rm -rf "${perfdata}" rm -rf "${perfdata}"
...@@ -165,7 +166,7 @@ test_workload() { ...@@ -165,7 +166,7 @@ test_workload() {
} }
test_branch_counter() { test_branch_counter() {
echo "Basic branch counter test" echo "Branch counter test"
# Check if the branch counter feature is supported # Check if the branch counter feature is supported
for dir in $cpu_pmu_dir for dir in $cpu_pmu_dir
do do
...@@ -175,19 +176,25 @@ test_branch_counter() { ...@@ -175,19 +176,25 @@ test_branch_counter() {
return return
fi fi
done done
if ! perf record -o "${perfdata}" -j any,counter ${testprog} 2> /dev/null if ! perf record -o "${perfdata}" -e "{branches:p,instructions}" -j any,counter ${testprog} 2> /dev/null
then then
echo "Basic branch counter test [Failed record]" echo "Branch counter record test [Failed record]"
err=1 err=1
return return
fi fi
if ! perf report -i "${perfdata}" -D -q | grep -q "$br_cntr_output" if ! perf report -i "${perfdata}" -D -q | grep -q "$br_cntr_output"
then then
echo "Basic branch record test [Failed missing output]" echo "Branch counter report test [Failed missing output]"
err=1 err=1
return return
fi fi
echo "Basic branch counter test [Success]" if ! perf script -i "${perfdata}" -F +brstackinsn,+brcntr | grep -q "$br_cntr_script_output"
then
echo " Branch counter script test [Failed missing output]"
err=1
return
fi
echo "Branch counter test [Success]"
} }
test_per_thread test_per_thread
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment