tools/testing/selftests/firmware/fw_lib.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/firmware/fw_lib.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/firmware/fw_lib.sh- Extension
.sh- Size
- 5505 bytes
- Lines
- 237
- 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
# Library of helpers for test scripts.
set -e
DIR=/sys/devices/virtual/misc/test_firmware
PROC_CONFIG="/proc/config.gz"
TEST_DIR=$(dirname $0)
# We need to load a different file to test request_firmware_into_buf
# I believe the issue is firmware loaded cached vs. non-cached
# with same filename is bungled.
# To reproduce rename this to test-firmware.bin
TEST_FIRMWARE_INTO_BUF_FILENAME=test-firmware-into-buf.bin
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
print_reqs_exit()
{
echo "You must have the following enabled in your kernel:" >&2
cat $TEST_DIR/config >&2
exit $ksft_skip
}
test_modprobe()
{
if [ ! -d $DIR ]; then
print_reqs_exit
fi
}
check_mods()
{
local uid=$(id -u)
if [ $uid -ne 0 ]; then
echo "skip all tests: must be run as root" >&2
exit $ksft_skip
fi
trap "test_modprobe" EXIT
if [ ! -d $DIR ]; then
modprobe test_firmware
fi
if [ ! -f $PROC_CONFIG ]; then
if modprobe configs 2>/dev/null; then
echo "Loaded configs module"
if [ ! -f $PROC_CONFIG ]; then
echo "You must have the following enabled in your kernel:" >&2
cat $TEST_DIR/config >&2
echo "Resorting to old heuristics" >&2
fi
else
echo "Failed to load configs module, using old heuristics" >&2
fi
fi
}
check_setup()
{
HAS_FW_LOADER_USER_HELPER="$(kconfig_has CONFIG_FW_LOADER_USER_HELPER=y)"
HAS_FW_LOADER_USER_HELPER_FALLBACK="$(kconfig_has CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y)"
HAS_FW_LOADER_COMPRESS_XZ="$(kconfig_has CONFIG_FW_LOADER_COMPRESS_XZ=y)"
HAS_FW_LOADER_COMPRESS_ZSTD="$(kconfig_has CONFIG_FW_LOADER_COMPRESS_ZSTD=y)"
HAS_FW_UPLOAD="$(kconfig_has CONFIG_FW_UPLOAD=y)"
PROC_FW_IGNORE_SYSFS_FALLBACK="0"
PROC_FW_FORCE_SYSFS_FALLBACK="0"
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.