1
0
Fork 0

selftests: firmware: Fix it to do root uid check and skip

[ Upstream commit c65e41538b ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5.4-rM2-2.2.x-imx-squashed
Shuah Khan 2019-12-12 18:56:06 -07:00 committed by Greg Kroah-Hartman
parent 434de487e0
commit d9afe243a9
1 changed files with 6 additions and 0 deletions

View File

@ -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