summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDapeng Mi <dapeng1.mi@linux.intel.com>2024-09-13 08:47:10 +0000
committerNamhyung Kim <namhyung@kernel.org>2024-09-30 15:23:44 -0700
commit387892723ad4044ff139ad7433e4dd24f7cfe303 (patch)
treeac5432e44170ab785592f86f625f390e7152a4ff
parent3b5edc0421e2598a0ae7f0adcd592017f37e3cdf (diff)
perf tests: Add leader sampling test in record tests
Add leader sampling test to validate event counts are captured into record and the count value is consistent. Suggested-by: Kan Liang <kan.liang@linux.intel.com> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Cc: Yongwei Ma <yongwei.ma@intel.com> Link: https://lore.kernel.org/r/20240913084712.13861-5-dapeng1.mi@linux.intel.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rwxr-xr-xtools/perf/tests/shell/record.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 048078ee2eca..45baf7910640 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -17,6 +17,7 @@ skip_test_missing_symbol ${testsym}
err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+script_output=$(mktemp /tmp/__perf_test.perf.data.XXXXX.script)
testprog="perf test -w thloop"
cpu_pmu_dir="/sys/bus/event_source/devices/cpu*"
br_cntr_file="/caps/branch_counter_nr"
@@ -228,6 +229,32 @@ test_cgroup() {
echo "Cgroup sampling test [Success]"
}
+test_leader_sampling() {
+ echo "Basic leader sampling test"
+ if ! perf record -o "${perfdata}" -e "{branches,branches}:Su" perf test -w brstack 2> /dev/null
+ then
+ echo "Leader sampling [Failed record]"
+ err=1
+ return
+ fi
+ index=0
+ perf script -i "${perfdata}" > $script_output
+ while IFS= read -r line
+ do
+ # Check if the two branches counts are equal in each record
+ branches=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="branches:") print $(i-1)}')
+ if [ $(($index%2)) -ne 0 ] && [ ${branches}x != ${prev_branches}x ]
+ then
+ echo "Leader sampling [Failed inconsistent branches count]"
+ err=1
+ return
+ fi
+ index=$(($index+1))
+ prev_branches=$branches
+ done < $script_output
+ echo "Basic leader sampling test [Success]"
+}
+
# raise the limit of file descriptors to minimum
if [[ $default_fd_limit -lt $min_fd_limit ]]; then
ulimit -Sn $min_fd_limit
@@ -239,6 +266,7 @@ test_system_wide
test_workload
test_branch_counter
test_cgroup
+test_leader_sampling
# restore the default value
ulimit -Sn $default_fd_limit