selftests: firmware: Fix it to do root uid check and skip
Shuah Khan
maintainerPATCH 1/1 selftests: firmware: Fix it to do root uid check and skip
firmware attempts to load test modules that require root access and fail. Fix it to check for root uid and exit with skip code instead.
Before this fix:
selftests: firmware: fw_run_tests.sh
modprobe: ERROR: could not insert 'test_firmware': Operation not permitted You must have the following enabled in your kernel:CONFIG_TEST_FIRMWARE=yCONFIG_FW_LOADER=yCONFIG_FW_LOADER_USER_HELPER=yCONFIG_IKCONFIG=yCONFIG_IKCONFIG_PROC=y
not ok 1 selftests: firmware: fw_run_tests.sh # SKIP
With this fix:
selftests: firmware: fw_run_tests.sh
skip all tests: must be run as root
not ok 1 selftests: firmware: fw_run_tests.sh # SKIP
--- tools/testing/selftests/firmware/fw_lib.sh | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/firmware/fw_lib.sh +6 -0
@@ -34,6 +34,12 @@ test_modprobe() 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
Signature · 1 line
2.20.1
Quoted 47 lines · Shuah Khan
firmware attempts to load test modules that require root access and fail. Fix it to check for root uid and exit with skip code instead.
Before this fix:
selftests: firmware:
fw_run_tests.sh
modprobe: ERROR: could not insert 'test_firmware': Operation not permitted You must have the following enabled in your kernel:CONFIG_TEST_FIRMWARE=yCONFIG_FW_LOADER=yCONFIG_FW_LOADER_USER_HELPER=yCONFIG_IKCONFIG=yCONFIG_IKCONFIG_PROC=y
not ok 1 selftests: firmware:fw_run_tests.sh# SKIPWith this fix:
selftests: firmware:
fw_run_tests.sh
skip all tests: must be run as root
not ok 1 selftests: firmware:fw_run_tests.sh# SKIPSigned-off-by Shuah Khan <[email protected]>--- tools/testing/selftests/firmware/fw_lib.sh | 6 ++++++ 1 file changed, 6 insertions(+)tools/testing/selftests/firmware/fw_lib.sh +6
-0@@ -34,6 +34,12 @@ test_modprobe() 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_firmwareSignature · 1 line
2.20.1