Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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=y
CONFIG_FW_LOADER=y
CONFIG_FW_LOADER_USER_HELPER=y
CONFIG_IKCONFIG=y
CONFIG_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

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Reviwed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

+6
+6
tools/testing/selftests/firmware/fw_lib.sh
··· 34 34 35 35 check_mods() 36 36 { 37 + local uid=$(id -u) 38 + if [ $uid -ne 0 ]; then 39 + echo "skip all tests: must be run as root" >&2 40 + exit $ksft_skip 41 + fi 42 + 37 43 trap "test_modprobe" EXIT 38 44 if [ ! -d $DIR ]; then 39 45 modprobe test_firmware