Skip to content

Commit dab5b6c

Browse files
Kan Liangacmel
authored andcommitted
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: Andi Kleen <ak@linux.intel.com> Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Acked-by: Namhyung 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.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 6f9d8d1 commit dab5b6c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tools/perf/tests/shell/record.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ testprog="perf test -w thloop"
2121
cpu_pmu_dir="/sys/bus/event_source/devices/cpu*"
2222
br_cntr_file="/caps/branch_counter_nr"
2323
br_cntr_output="branch stack counters"
24+
br_cntr_script_output="br_cntr: A"
2425

2526
cleanup() {
2627
rm -rf "${perfdata}"
@@ -165,7 +166,7 @@ test_workload() {
165166
}
166167

167168
test_branch_counter() {
168-
echo "Basic branch counter test"
169+
echo "Branch counter test"
169170
# Check if the branch counter feature is supported
170171
for dir in $cpu_pmu_dir
171172
do
@@ -175,19 +176,25 @@ test_branch_counter() {
175176
return
176177
fi
177178
done
178-
if ! perf record -o "${perfdata}" -j any,counter ${testprog} 2> /dev/null
179+
if ! perf record -o "${perfdata}" -e "{branches:p,instructions}" -j any,counter ${testprog} 2> /dev/null
179180
then
180-
echo "Basic branch counter test [Failed record]"
181+
echo "Branch counter record test [Failed record]"
181182
err=1
182183
return
183184
fi
184185
if ! perf report -i "${perfdata}" -D -q | grep -q "$br_cntr_output"
185186
then
186-
echo "Basic branch record test [Failed missing output]"
187+
echo "Branch counter report test [Failed missing output]"
187188
err=1
188189
return
189190
fi
190-
echo "Basic branch counter test [Success]"
191+
if ! perf script -i "${perfdata}" -F +brstackinsn,+brcntr | grep -q "$br_cntr_script_output"
192+
then
193+
echo " Branch counter script test [Failed missing output]"
194+
err=1
195+
return
196+
fi
197+
echo "Branch counter test [Success]"
191198
}
192199

193200
test_per_thread

0 commit comments

Comments
 (0)