tools/testing/selftests/livepatch/functions.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/livepatch/functions.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/livepatch/functions.sh- Extension
.sh- Size
- 11397 bytes
- Lines
- 420
- 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
function logfunction has_kdirfunction diefunction set_dynamic_debugfunction cleanupfunction is_livepatch_modfunction __load_modfunction load_modfunction load_lp_nowaitfunction load_lpfunction load_failing_modfunction unload_modfunction unload_lpfunction does_sysfs_existfunction check_sysfs_rightsfunction check_sysfs_valuefunction cleanup_tracingfunction check_traced_functions
Annotated Snippet
function log() {
echo "$1" > /dev/kmsg
}
# skip(msg) - testing can't proceed
# msg - explanation
function skip() {
log "SKIP: $1"
echo "SKIP: $1" >&2
exit $ksft_skip
}
# root test
function is_root() {
uid=$(id -u)
if [ $uid -ne 0 ]; then
echo "skip all tests: must be run as root" >&2
exit $ksft_skip
fi
}
# Check if we can compile the modules before loading them
function has_kdir() {
if [ -z "$KDIR" ]; then
KDIR="/lib/modules/$(uname -r)/build"
fi
if [ ! -d "$KDIR" ]; then
echo "skip all tests: KDIR ($KDIR) not available to compile modules."
exit $ksft_skip
fi
}
# die(msg) - game over, man
# msg - dying words
function die() {
log "ERROR: $1"
echo "ERROR: $1" >&2
exit 1
}
function push_config() {
DYNAMIC_DEBUG=$(grep '^kernel/livepatch' "$SYSFS_DEBUG_DIR/dynamic_debug/control" | \
awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}')
FTRACE_ENABLED=$(sysctl --values kernel.ftrace_enabled)
KPROBE_ENABLED=$(cat "$SYSFS_KPROBES_DIR/enabled")
TRACING_ON=$(cat "$SYSFS_TRACING_DIR/tracing_on")
CURRENT_TRACER=$(cat "$SYSFS_TRACING_DIR/current_tracer")
FTRACE_FILTER=$(cat "$SYSFS_TRACING_DIR/set_ftrace_filter")
}
function pop_config() {
if [[ -n "$DYNAMIC_DEBUG" ]]; then
echo -n "$DYNAMIC_DEBUG" > "$SYSFS_DEBUG_DIR/dynamic_debug/control"
fi
if [[ -n "$FTRACE_ENABLED" ]]; then
sysctl kernel.ftrace_enabled="$FTRACE_ENABLED" &> /dev/null
fi
if [[ -n "$KPROBE_ENABLED" ]]; then
echo "$KPROBE_ENABLED" > "$SYSFS_KPROBES_DIR/enabled"
fi
if [[ -n "$TRACING_ON" ]]; then
echo "$TRACING_ON" > "$SYSFS_TRACING_DIR/tracing_on"
fi
if [[ -n "$CURRENT_TRACER" ]]; then
echo "$CURRENT_TRACER" > "$SYSFS_TRACING_DIR/current_tracer"
fi
if [[ -n "$FTRACE_FILTER" ]]; then
echo "$FTRACE_FILTER" \
| sed -e "/#### all functions enabled ####/d" \
Annotation
- Detected declarations: `function log`, `function has_kdir`, `function die`, `function set_dynamic_debug`, `function cleanup`, `function is_livepatch_mod`, `function __load_mod`, `function load_mod`, `function load_lp_nowait`, `function load_lp`.
- 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.