summaryrefslogtreecommitdiffstats
path: root/tools/perf/tests/shell/record.sh
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2022-10-20 10:26:39 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-10-27 16:37:26 -0300
commit6b7e02ab1262141cfebd05b68410fa297f557961 (patch)
tree0b7996c3d629689f626b162e3f7d3f89cbf54229 /tools/perf/tests/shell/record.sh
parent4321ad4ee98b7325d6133e1d5b7fa25bcbdeb57e (diff)
downloadlinux-stable-6b7e02ab1262141cfebd05b68410fa297f557961.tar.gz
linux-stable-6b7e02ab1262141cfebd05b68410fa297f557961.tar.bz2
linux-stable-6b7e02ab1262141cfebd05b68410fa297f557961.zip
perf test: Wait for a new thread when testing --per-thread record
Just running the target program is not enough to test multi-thread target because it'd be racy perf vs target startup. I used the initial delay but it cannot guarantee for perf to see the thread. Instead, use wait_for_threads helper from shell/lib/waiting.sh to make sure it starts the sibling thread first. Then perf record can use -p option to profile the target process. Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20221020172643.3458767-5-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/shell/record.sh')
-rwxr-xr-xtools/perf/tests/shell/record.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 952981481239..d1640d1daf2e 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -4,6 +4,9 @@
set -e
+shelldir=$(dirname "$0")
+. "${shelldir}"/lib/waiting.sh
+
err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
@@ -96,6 +99,30 @@ test_per_thread() {
err=1
return
fi
+
+ # run the test program in background (forever)
+ ${testprog} 1 &
+ TESTPID=$!
+
+ rm -f "${perfdata}"
+
+ wait_for_threads ${TESTPID} 2
+ perf record -p "${TESTPID}" --per-thread -o "${perfdata}" sleep 1 2> /dev/null
+ kill ${TESTPID}
+
+ if [ ! -e "${perfdata}" ]
+ then
+ echo "Per-thread record [Failed record -p]"
+ err=1
+ return
+ fi
+ if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
+ then
+ echo "Per-thread record [Failed -p missing output]"
+ err=1
+ return
+ fi
+
echo "Basic --per-thread mode test [Success]"
}