Skip to contentSkip to conversation

perf test: Add skip to --per-thread test

PATCH Applied Ian Rogers 2 participants 2 messages May 5, 2022 – May 6, 2022 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH v3 1/1 perf test: Add skip to --per-thread test

As reported in:
https://lore.kernel.org/linux-perf-users/[email protected]/
the 'instructions:u' event may not be supported. Add a skip using 'perf record'.

Switch some code away from pipe to make the failures clearer.

---
 tools/perf/tests/shell/record.sh | 46 ++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 5 deletions(-)
tools/perf/tests/shell/record.sh +41 -5
index d98f4d4a00e1..00c7285ce1ac 100755
@@ -5,11 +5,43 @@
 set -e
 
 err=0
+perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+
+cleanup() {
+  rm -f ${perfdata}
+  rm -f ${perfdata}.old
+  trap - exit term int
+}
+
+trap_cleanup() {
+  cleanup
+  exit 1
+}
+trap trap_cleanup exit term int
+
 test_per_thread() {
   echo "Basic --per-thread mode test"
-  perf record -e instructions:u --per-thread -o- true 2> /dev/null \
-    | perf report -i- -q \
-    | egrep -q true
+  if ! perf record -e instructions:u -o ${perfdata} --quiet true 2> /dev/null
+  then
+    echo "Per-thread record [Skipped instructions:u not supported]"
+    if [ $err -ne 1 ]
+    then
+      err=2
+    fi
+    return
+  fi
+  if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null
+  then
+    echo "Per-thread record of instructions:u [Failed]"
+    err=1
+    return
+  fi
+  if ! perf report -i ${perfdata} -q | egrep -q true
+  then
+    echo "Per-thread record [Failed missing output]"
+    err=1
+    return
+  fi
   echo "Basic --per-thread mode test [Success]"
 }
 
@@ -18,6 +50,10 @@ test_register_capture() {
   if ! perf list | egrep -q 'br_inst_retired.near_call'
   then
     echo "Register capture test [Skipped missing instruction]"
+    if [ $err -ne 1 ]
+    then
+      err=2
+    fi
     return
   fi
   if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
@@ -37,8 +73,8 @@ test_register_capture() {
   echo "Register capture test [Success]"
 }
 
-# Test for platform support and return TEST_SKIP
-[ $(uname -m) = s390x ] && exit 2
 test_per_thread
 test_register_capture
+
+cleanup
 exit $err
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
maintainer Applied
#1 lore raw

Em Thu, May 05, 2022 at 11:25:05AM -0700, Ian Rogers escreveu:

Quoted 6 lines

As reported in:
https://lore.kernel.org/linux-perf-users/[email protected]/
the 'instructions:u' event may not be supported. Add a skip using 'perf record'.

Switch some code away from pipe to make the failures clearer.

Thanks, applied.

- Arnaldo

Quoted 82 lines
---
 tools/perf/tests/shell/record.sh | 46 ++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 5 deletions(-)
tools/perf/tests/shell/record.sh +41 -5
index d98f4d4a00e1..00c7285ce1ac 100755
@@ -5,11 +5,43 @@
 set -e
 
 err=0
+perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+
+cleanup() {
+  rm -f ${perfdata}
+  rm -f ${perfdata}.old
+  trap - exit term int
+}
+
+trap_cleanup() {
+  cleanup
+  exit 1
+}
+trap trap_cleanup exit term int
+
 test_per_thread() {
   echo "Basic --per-thread mode test"
-  perf record -e instructions:u --per-thread -o- true 2> /dev/null \
-    | perf report -i- -q \
-    | egrep -q true
+  if ! perf record -e instructions:u -o ${perfdata} --quiet true 2> /dev/null
+  then
+    echo "Per-thread record [Skipped instructions:u not supported]"
+    if [ $err -ne 1 ]
+    then
+      err=2
+    fi
+    return
+  fi
+  if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null
+  then
+    echo "Per-thread record of instructions:u [Failed]"
+    err=1
+    return
+  fi
+  if ! perf report -i ${perfdata} -q | egrep -q true
+  then
+    echo "Per-thread record [Failed missing output]"
+    err=1
+    return
+  fi
   echo "Basic --per-thread mode test [Success]"
 }
 
@@ -18,6 +50,10 @@ test_register_capture() {
   if ! perf list | egrep -q 'br_inst_retired.near_call'
   then
     echo "Register capture test [Skipped missing instruction]"
+    if [ $err -ne 1 ]
+    then
+      err=2
+    fi
     return
   fi
   if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
@@ -37,8 +73,8 @@ test_register_capture() {
   echo "Register capture test [Success]"
 }
 
-# Test for platform support and return TEST_SKIP
-[ $(uname -m) = s390x ] && exit 2
 test_per_thread
 test_register_capture
+
+cleanup
 exit $err
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
Signature · 1 line
- Arnaldo