tools/tracing/rtla/tests/engine.sh
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/tests/engine.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/tests/engine.sh- Extension
.sh- Size
- 4358 bytes
- Lines
- 167
- 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.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
test_begin() {
# Count tests to allow the test harness to double-check if all were
# included correctly.
ctr=0
# Set test directory to the directory of the script
scriptfile=$(realpath "$0")
testdir=$(dirname "$scriptfile")
[ -z "$RTLA" ] && RTLA="./rtla"
[ -n "$TEST_COUNT" ] && echo "1..$TEST_COUNT"
}
reset_osnoise() {
# Reset osnoise options to default and remove any dangling instances created
# by improperly exited rtla runs.
pushd /sys/kernel/tracing >/dev/null || return 1
# Remove dangling instances created by previous rtla run
echo 0 > tracing_thresh
cd instances
for i in osnoise_top osnoise_hist timerlat_top timerlat_hist
do
[ ! -d "$i" ] && continue
rmdir "$i"
done
# Reset options to default
# Note: those are copied from the default values of osnoise_data
# in kernel/trace/trace_osnoise.c
cd ../osnoise
echo all > cpus
echo DEFAULTS > options
echo 1000000 > period_us
echo 0 > print_stack
echo 1000000 > runtime_us
echo 0 > stop_tracing_total_us
echo 0 > stop_tracing_us
echo 1000 > timerlat_period_us
popd >/dev/null
}
check() {
test_name=$0
tested_command=$1
expected_exitcode=${3:-0}
expected_output=$4
unexpected_output=$5
# Simple check: run rtla with given arguments and test exit code.
# If TEST_COUNT is set, run the test. Otherwise, just count.
ctr=$(($ctr + 1))
if [ -n "$TEST_COUNT" ]
then
# Reset osnoise options before running test.
[ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise
# Create a temporary directory to contain rtla output
tmpdir=$(mktemp -d)
pushd $tmpdir >/dev/null
# Run rtla; in case of failure, include its output as comment
# in the test results.
result=$(eval stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$?
failbuf=''
fail=0
# Test if the results matches if requested
if [ -n "$expected_output" ] && ! grep -qE "$expected_output" <<< "$result"
then
Annotation
- 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.