linux/tools/perf/tests/shell/pipe_test.sh

128 lines
3.2 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# perf pipe recording and injection test
# SPDX-License-Identifier: GPL-2.0
perf tests: Skip pipe test if noploop symbol is missing perf pipe recording and injection test depends on finding symbol noploop in perf, and fails if perf has been stripped and no debug object is available. In that case, skip the test instead. Example: Before: $ strip tools/perf/perf $ tools/perf/perf buildid-cache -p `realpath tools/perf/perf` $ tools/perf/perf test -v pipe 86: perf pipe recording and injection test : --- start --- test child forked, pid 47734 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] 47741 47741 -1 |perf [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] cannot find noploop function in pipe #1 test child finished with -1 ---- end ---- perf pipe recording and injection test: FAILED! After: $ tools/perf/perf test -v pipe 86: perf pipe recording and injection test : --- start --- test child forked, pid 48996 perf does not have symbol 'noploop' perf is missing symbols - skipping test test child finished with -2 ---- end ---- perf pipe recording and injection test: Skip Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Ian Rogers <irogers@google.com> Cc: German Gomez <german.gomez@arm.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20231123075848.9652-4-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-11-23 09:58:43 +02:00
shelldir=$(dirname "$0")
# shellcheck source=lib/perf_has_symbol.sh
. "${shelldir}"/lib/perf_has_symbol.sh
sym="noploop"
skip_test_missing_symbol ${sym}
data=$(mktemp /tmp/perf.data.XXXXXX)
data2=$(mktemp /tmp/perf.data2.XXXXXX)
2022-11-16 15:38:44 -08:00
prog="perf test -w noploop"
perf test: Fix perf test case 84 on s390 Perf test case 84 'perf pipe recording and injection test' sometime fails on s390, especially on z/VM virtual machines. This is caused by a very short run time of workload # perf test -w noploop which runs for 1 second. Occasionally this is not long enough and the perf report has no samples for symbol noploop. Fix this and enlarge the runtime for the perf work load to 3 seconds. This ensures the symbol noploop is always present. Since only s390 is affected, make this loop architecture dependend. Output before: Inject -b build-ids test [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.195 MB - ] [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.277 MB - ] [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.195 MB - ] [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.160 MB /tmp/perf.data.ELzRdq (4031 samples) ] [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.195 MB - ] [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.195 MB - ] Inject -b build-ids test [Success] Inject --buildid-all build-ids test [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.195 MB - ] [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.014 MB - ] Inject --buildid-all build-ids test [Failed - cannot find noploop function in pipe #2] Output after: Successful execution for over 10 times in a loop. Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Reviewed-by: Sumanth Korikkar <sumanthk@linux.ibm.com> Reviewed-by: Ian Rogers <irogers@google.com> Suggested-by: Namhyung Kim <namhyung@kernel.org> Cc: agordeev@linux.ibm.com Cc: gor@linux.ibm.com Cc: hca@linux.ibm.com Link: https://lore.kernel.org/r/20241018081732.1391060-1-tmricht@linux.ibm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2024-10-18 10:17:32 +02:00
[ "$(uname -m)" = "s390x" ] && prog="$prog 3"
err=0
set -e
cleanup() {
rm -rf "${data}"
rm -rf "${data}".old
rm -rf "${data2}"
rm -rf "${data2}".old
trap - EXIT TERM INT
}
trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
test_record_report() {
echo
echo "Record+report pipe test"
task="perf"
if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
then
echo "Record+report pipe test [Failed - cannot find the test file in the perf report #1]"
err=1
return
fi
if ! perf record -g -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
then
echo "Record+report pipe test [Failed - cannot find the test file in the perf report #2]"
err=1
return
fi
perf record -g -e task-clock:u -o - ${prog} > ${data}
if ! perf report -i ${data} --task | grep -q ${task}
then
echo "Record+report pipe test [Failed - cannot find the test file in the perf report #3]"
err=1
return
fi
echo "Record+report pipe test [Success]"
}
test_inject_bids() {
inject_opt=$1
echo
echo "Inject ${inject_opt} build-ids test"
if ! perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt}| perf report -i - | grep -q ${sym}
then
echo "Inject build-ids test [Failed - cannot find noploop function in pipe #1]"
err=1
return
fi
if ! perf record -g -e task-clock:u -o - ${prog} | perf inject ${inject_opt} | perf report -i - | grep -q ${sym}
then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #2]"
err=1
return
fi
perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt} -o ${data}
if ! perf report -i ${data} | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #3]"
err=1
return
fi
perf record -e task-clock:u -o ${data} ${prog}
if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #4]"
err=1
return
fi
perf record -e task-clock:u -o - ${prog} > ${data}
if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #5]"
err=1
return
fi
perf record -e task-clock:u -o - ${prog} > ${data}
perf inject ${inject_opt} -i ${data} -o ${data2}
if ! perf report -i ${data2} | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #6]"
err=1
return
fi
echo "Inject ${inject_opt} build-ids test [Success]"
}
test_record_report
test_inject_bids -B
test_inject_bids -b
test_inject_bids --buildid-all
test_inject_bids --mmap2-buildid-all
cleanup
exit $err