tools/perf/tests/shell/trace_btf_general.sh
Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/trace_btf_general.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/shell/trace_btf_general.sh- Extension
.sh- Size
- 2289 bytes
- Lines
- 95
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function check_vmlinux
Annotated Snippet
#!/bin/bash
# perf trace BTF general tests (exclusive)
# SPDX-License-Identifier: GPL-2.0
err=0
# shellcheck source=lib/probe.sh
. "$(dirname $0)"/lib/probe.sh
file1=$(mktemp /tmp/file1_XXXX)
file2=$(echo $file1 | sed 's/file1/file2/g')
buffer="buffer content"
perf_config_tmp=$(mktemp /tmp/.perfconfig_XXXXX)
trap cleanup EXIT TERM INT HUP
check_vmlinux() {
echo "Checking if vmlinux BTF exists"
if [ ! -f /sys/kernel/btf/vmlinux ]
then
echo "Skipped due to missing vmlinux BTF"
return 2
fi
return 0
}
trace_test_string() {
echo "Testing perf trace's string augmentation"
output="$(perf trace --sort-events -e renameat* --max-events=1 -- mv ${file1} ${file2} 2>&1)"
if ! echo "$output" | grep -q -E "^mv/[0-9]+ renameat(2)?\(.*, \"${file1}\", .*, \"${file2}\", .*\) += +[0-9]+$"
then
printf "String augmentation test failed, output:\n$output\n"
err=1
fi
}
trace_test_buffer() {
echo "Testing perf trace's buffer augmentation"
# echo will insert a newline (\10) at the end of the buffer
output="$(perf trace --sort-events -e write --max-events=1 -- echo "${buffer}" 2>&1)"
if ! echo "$output" | grep -q -E "^echo/[0-9]+ write\([0-9]+, ${buffer}.*, [0-9]+\) += +[0-9]+$"
then
printf "Buffer augmentation test failed, output:\n$output\n"
err=1
fi
}
trace_test_struct_btf() {
echo "Testing perf trace's struct augmentation"
output="$(perf trace --sort-events -e clock_nanosleep --force-btf --max-events=1 -- sleep 1 2>&1)"
if ! echo "$output" | grep -q -E "^sleep/[0-9]+ clock_nanosleep\(0, 0, \{1,.*\}, 0x[0-9a-f]+\) += +[0-9]+$"
then
printf "BTF struct augmentation test failed, output:\n$output\n"
err=1
fi
}
cleanup() {
rm -rf ${file1} ${file2} ${perf_config_tmp}
}
trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
# don't overwrite user's perf config
trace_config() {
Annotation
- Detected declarations: `function check_vmlinux`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.