lib/Kernel/utils.pm

is_debugfs_mounted

is_debugfs_mounted();

Checks whether debugfs is mounted at /sys/kernel/debug, same check as blktests' _have_debugfs(). Returns true/false.

get_mount_info

my $mount = get_mount_info($path);

Returns a hash reference with target, source, fstype and options of the file system that $path is on, from findmnt -T. For example, target /var, source /dev/sda2[/@/var], fstype btrfs. Dies if $path is on no mounted file system.

enable_debugfs

enable_debugfs();

Mounts debugfs at /sys/kernel/debug (e.g. on SLE 16.1+, where it is disabled by default per PED-8812).

get_kernel_config

get_kernel_config();

Locates the running kernel's config file (/boot/config-$(uname -r), falling back to /usr/lib/modules/$(uname -r)/config and then /proc/config.gz) and records its full contents via record_info(), prefixed with a comment naming the source file (as done in LTP::utils::log_versions).

get_verified_shallow_tar

get_verified_shallow_tar(tree => 'stable', branch => 'linux-6.12.y', commit => '...');

Downloads the kernel.org shallow-clone tarball for the given tree and branch, verifies it via the signed checksums, and checks out commit into ./linux. commit should always be supplied in CI; omitting it checks out the current tip (the bundle is published nightly).

See https://people.kernel.org/monsieuricon/using-shallow-git-tarballs-for-ci.

start_trace_events

start_trace_events(\@events);
start_trace_events(\@events, filters => {$event => $filter}, buffer_kb => $kb);

Enable kernel tracepoints in tracefs and start to trace. Each event is system/event, a shell glob selects several events, e.g. nfs4/pnfs_*. Events that the kernel does not provide are skipped.

The events go to the trace ring buffer, which keeps the newest events when it is full. Thus the trace can run for a long time without filling the disk. save_trace saves it.

If the first event is enabled already, e.g. by an earlier call before each subtest, only clear the trace. This keeps repeated calls short. After a reboot the events are enabled again.

Arguments: \@events - Events to enable filters - Optional event filters, e.g. 'dev == 7340033' buffer_kb - Optional ring buffer size per CPU in KiB (default: 8192)

save_trace

save_trace($file);

Save the trace started by start_trace_events to $file.

install_fio_debug_wrapper

install_fio_debug_wrapper($dir);

Install a wrapper as /usr/local/bin/fio, so that tests which call fio from PATH run it with --debug=file,mem and strace of the failed syscalls. For each fio run the wrapper keeps the job file, the command line, the debug output and the strace output in $dir, named by the pid of the wrapper.

Only fio runs that write the results to a file with --output= are changed, else the debug output would change the output of the test. The debug output is kept out of the --output file too, tests often copy this file to their logs.

Without strace 5.2 or newer (for -Z) fio runs without strace.