[PATCH 5/6] perf test: Add target workload test in perf record tests

From: Namhyung Kim
Date: Wed Sep 07 2022 - 02:47:20 EST


Add a subtest which profiles the given workload on the command line.
As it's a minimal requirement, test should run ok so it doesn't skip
the test even if it failed to run the perf record.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/tests/shell/record.sh | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index bd4ef60948bd..ff66e58f3a26 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -167,11 +167,42 @@ test_system_wide() {
echo "Basic --system-wide mode test [Success]"
}

+test_workload() {
+ echo "Basic target workload test"
+ if ! perf record ${testopt} -o ${perfdata} ${testprog} 2> /dev/null
+ then
+ echo "Workload record [Failed record]"
+ err=1
+ return
+ fi
+ if ! perf report -i ${perfdata} -q | egrep -q ${testsym}
+ then
+ echo "Workload record [Failed missing output]"
+ err=1
+ return
+ fi
+ if ! perf record -e cpu-clock,cs --threads=package ${testopt} \
+ -o ${perfdata} ${testprog} 2> /dev/null
+ then
+ echo "Workload record [Failed recording with threads]"
+ err=1
+ return
+ fi
+ if ! perf report -i ${perfdata} -q | egrep -q ${testsym}
+ then
+ echo "Workload record [Failed missing output]"
+ err=1
+ return
+ fi
+ echo "Basic target workload test [Success]"
+}
+
build_test_program

test_per_thread
test_register_capture
test_system_wide
+test_workload

cleanup
exit $err
--
2.37.2.789.g6183377224-goog