linux/tools/perf/tests/shell/header.sh
Ian Rogers 6c21316e52 perf header: Fix pipe mode header dumping
The pipe mode header dumping was accidentally removed when tracing of
header feature events in pipe mode was added.

Minor spelling tweak to header test failure message.

Fixes: 61051f9a84 ("perf header: In pipe mode dump features without --header/-I")
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20250703042000.2740640-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2025-07-03 11:22:17 -07:00

75 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# perf header tests
# SPDX-License-Identifier: GPL-2.0
set -e
err=0
perfdata=$(mktemp /tmp/__perf_test_header.perf.data.XXXXX)
script_output=$(mktemp /tmp/__perf_test_header.perf.data.XXXXX.script)
cleanup() {
rm -f "${perfdata}"
rm -f "${perfdata}".old
rm -f "${script_output}"
trap - EXIT TERM INT
}
trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
check_header_output() {
declare -a fields=(
"captured"
"hostname"
"os release"
"arch"
"cpuid"
"nrcpus"
"event"
"cmdline"
"perf version"
"sibling (cores|dies|threads)"
"sibling threads"
"total memory"
)
for i in "${fields[@]}"
do
if ! grep -q -E "$i" "${script_output}"
then
echo "Failed to find expected $i in output"
err=1
fi
done
}
test_file() {
echo "Test perf header file"
perf record -o "${perfdata}" -- perf test -w noploop
perf report --header-only -I -i "${perfdata}" > "${script_output}"
check_header_output
echo "Test perf header file [Done]"
}
test_pipe() {
echo "Test perf header pipe"
perf record -o - -- perf test -w noploop | perf report --header-only -I -i - > "${script_output}"
check_header_output
echo "Test perf header pipe [Done]"
}
test_file
test_pipe
cleanup
exit $err