public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: kan.liang@linux.intel.com
To: acme@kernel.org, namhyung@kernel.org, irogers@google.com,
	peterz@infradead.org, mingo@kernel.org,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Cc: adrian.hunter@intel.com, ak@linux.intel.com, eranian@google.com,
	Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH V2 9/9] perf test: Add new test cases for the branch counter feature
Date: Thu,  8 Aug 2024 12:33:24 -0700	[thread overview]
Message-ID: <20240808193324.2027665-10-kan.liang@linux.intel.com> (raw)
In-Reply-To: <20240808193324.2027665-1-kan.liang@linux.intel.com>

From: Kan Liang <kan.liang@linux.intel.com>

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)

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/tests/shell/record.sh | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 3d1a7759a7b2..7964ebd9007d 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -21,6 +21,7 @@ testprog="perf test -w thloop"
 cpu_pmu_dir="/sys/bus/event_source/devices/cpu*"
 br_cntr_file="/caps/branch_counter_nr"
 br_cntr_output="branch stack counters"
+br_cntr_script_output="br_cntr: A"
 
 cleanup() {
   rm -rf "${perfdata}"
@@ -165,7 +166,7 @@ test_workload() {
 }
 
 test_branch_counter() {
-  echo "Basic branch counter test"
+  echo "Branch counter test"
   # Check if the branch counter feature is supported
   for dir in $cpu_pmu_dir
   do
@@ -175,19 +176,25 @@ test_branch_counter() {
       return
     fi
   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
-    echo "Basic branch counter test [Failed record]"
+    echo "Branch counter record test [Failed record]"
     err=1
     return
   fi
   if ! perf report -i "${perfdata}" -D -q | grep -q "$br_cntr_output"
   then
-    echo "Basic branch record test [Failed missing output]"
+    echo "Branch counter report test [Failed missing output]"
     err=1
     return
   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
-- 
2.38.1


  parent reply	other threads:[~2024-08-08 19:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08 19:33 [PATCH V2 0/9] Support branch counters in block annotation kan.liang
2024-08-08 19:33 ` [PATCH V2 1/9] perf report: Fix --total-cycles --stdio output error kan.liang
2024-08-08 19:33 ` [PATCH V2 2/9] perf report: Remove the first overflow check for branch counters kan.liang
2024-08-08 19:33 ` [PATCH V2 3/9] perf evlist: Save branch counters information kan.liang
2024-08-08 19:33 ` [PATCH V2 4/9] perf annotate: Save branch counters for each block kan.liang
2024-08-08 19:33 ` [PATCH V2 5/9] perf evsel: Assign abbr name for the branch counter events kan.liang
2024-08-08 19:33 ` [PATCH V2 6/9] perf report: Display the branch counter histogram kan.liang
2024-08-08 19:33 ` [PATCH V2 7/9] perf annotate: " kan.liang
2024-08-08 19:33 ` [PATCH V2 8/9] perf script: Add branch counters kan.liang
2024-08-08 19:33 ` kan.liang [this message]
2024-08-08 20:27 ` [PATCH V2 0/9] Support branch counters in block annotation Andi Kleen
2024-08-12 19:39 ` Namhyung Kim
2024-08-12 20:13   ` Arnaldo Carvalho de Melo
2024-08-13 15:15     ` Liang, Kan
2024-08-13 15:17       ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240808193324.2027665-10-kan.liang@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox