mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 12:13:51 -04:00
Introduce `perf_record_with_retry` and `perf_record_cleanup` in a shared library `tests/shell/lib/perf_record.sh` to prevent record test failures caused by transient recording or workload delays. Update `record.sh`, `record_lbr.sh`, `pipe_test.sh`, `kvm.sh`, and `stat_all_pfm.sh` to use this robust record retry logic. These tests now start with very short durations (e.g. 0.01 seconds) and scale up if the initial recording failed to capture samples, significantly improving test execution speed on success while remaining resilient to slow systems. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
128 lines
3.2 KiB
Bash
Executable File
128 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# perf pipe recording and injection test
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
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)
|
|
prog="perf test -w noploop 0.1"
|
|
[ "$(uname -m)" = "s390x" ] && prog="perf test -w noploop 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
|
|
|