linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf test: Add flake tolerance to record test
@ 2022-06-09  3:28 Ian Rogers
  0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2022-06-09  3:28 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Thomas Richter, linux-perf-users, linux-kernel
  Cc: Stephane Eranian, Ian Rogers

Testing at scale exposes record tests failing with no samples. Retry the
test a bounded number of times to eliminate this.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/shell/record.sh | 70 +++++++++++++++++++++-----------
 1 file changed, 47 insertions(+), 23 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 00c7285ce1ac..aeed364e834a 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -30,19 +30,29 @@ test_per_thread() {
     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]"
+  flake_count=0
+  while true
+  do
+    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 "Basic --per-thread mode test [Success]"
+      return
+    else
+      flake_count=$(($flake_count + 1))
+      if [ $flake_count -ge 30 ]
+      then
+        echo "Per-thread record attempted 30 times [Failed missing output]"
+        err=1
+        return
+      fi
+    fi
+  done
 }
 
 test_register_capture() {
@@ -61,16 +71,30 @@ test_register_capture() {
     echo "Register capture test [Skipped missing registers]"
     return
   fi
-  if ! perf record -o - --intr-regs=di,r8,dx,cx -e cpu/br_inst_retired.near_call/p \
-    -c 1000 --per-thread true 2> /dev/null \
-    | perf script -F ip,sym,iregs -i - 2> /dev/null \
-    | egrep -q "DI:"
-  then
-    echo "Register capture test [Failed missing output]"
-    err=1
-    return
-  fi
-  echo "Register capture test [Success]"
+  flake_count=0
+  while true
+  do
+    if ! perf record -o ${perfdata} --intr-regs=di,r8,dx,cx -e cpu/br_inst_retired.near_call/p \
+      -c 1000 --per-thread true 2> /dev/null
+    then
+      echo "Register capture test of cpu/br_inst_retired.near_call/p with --intr-regs [Failed]"
+      err=1
+      return
+    fi
+    if perf script -F ip,sym,iregs -i ${perfdata} 2> /dev/null | egrep -q "DI:"
+    then
+      echo "Register capture test [Success]"
+      return
+    else
+      flake_count=$(($flake_count + 1))
+      if [ $flake_count -ge 30 ]
+      then
+        echo "Register capture test attempted 30 times [Failed missing output]"
+        err=1
+        return
+      fi
+    fi
+  done
 }
 
 test_per_thread
-- 
2.36.1.255.ge46751e96f-goog


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-09  3:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-09  3:28 [PATCH] perf test: Add flake tolerance to record test Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).