selftests: firmware: skip timeout checks for kernels without user mode helper
The CONFIG_FW_LOADER_USER_HELPER is mostly disabled these days, so skip timeout setting for these kernels. Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
71cf5aeeb8
commit
1d0fbb3467
|
@ -9,7 +9,15 @@ modprobe test_firmware
|
||||||
|
|
||||||
DIR=/sys/devices/virtual/misc/test_firmware
|
DIR=/sys/devices/virtual/misc/test_firmware
|
||||||
|
|
||||||
|
# CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/
|
||||||
|
# These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that
|
||||||
|
# as an indicator for CONFIG_FW_LOADER_USER_HELPER.
|
||||||
|
HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi)
|
||||||
|
|
||||||
|
if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
|
||||||
OLD_TIMEOUT=$(cat /sys/class/firmware/timeout)
|
OLD_TIMEOUT=$(cat /sys/class/firmware/timeout)
|
||||||
|
fi
|
||||||
|
|
||||||
OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path)
|
OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path)
|
||||||
|
|
||||||
FWPATH=$(mktemp -d)
|
FWPATH=$(mktemp -d)
|
||||||
|
@ -17,7 +25,9 @@ FW="$FWPATH/test-firmware.bin"
|
||||||
|
|
||||||
test_finish()
|
test_finish()
|
||||||
{
|
{
|
||||||
|
if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
|
||||||
echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout
|
echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout
|
||||||
|
fi
|
||||||
echo -n "$OLD_PATH" >/sys/module/firmware_class/parameters/path
|
echo -n "$OLD_PATH" >/sys/module/firmware_class/parameters/path
|
||||||
rm -f "$FW"
|
rm -f "$FW"
|
||||||
rmdir "$FWPATH"
|
rmdir "$FWPATH"
|
||||||
|
@ -25,8 +35,11 @@ test_finish()
|
||||||
|
|
||||||
trap "test_finish" EXIT
|
trap "test_finish" EXIT
|
||||||
|
|
||||||
|
if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
|
||||||
# Turn down the timeout so failures don't take so long.
|
# Turn down the timeout so failures don't take so long.
|
||||||
echo 1 >/sys/class/firmware/timeout
|
echo 1 >/sys/class/firmware/timeout
|
||||||
|
fi
|
||||||
|
|
||||||
# Set the kernel search path.
|
# Set the kernel search path.
|
||||||
echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path
|
echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path
|
||||||
|
|
||||||
|
@ -41,8 +54,10 @@ if diff -q "$FW" /dev/test_firmware >/dev/null ; then
|
||||||
echo "$0: firmware was not expected to match" >&2
|
echo "$0: firmware was not expected to match" >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
|
||||||
echo "$0: timeout works"
|
echo "$0: timeout works"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# This should succeed via kernel load or will fail after 1 second after
|
# This should succeed via kernel load or will fail after 1 second after
|
||||||
# being handed over to the user helper, which won't find the fw either.
|
# being handed over to the user helper, which won't find the fw either.
|
||||||
|
|
|
@ -9,7 +9,17 @@ modprobe test_firmware
|
||||||
|
|
||||||
DIR=/sys/devices/virtual/misc/test_firmware
|
DIR=/sys/devices/virtual/misc/test_firmware
|
||||||
|
|
||||||
|
# CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/
|
||||||
|
# These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that
|
||||||
|
# as an indicator for CONFIG_FW_LOADER_USER_HELPER.
|
||||||
|
HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi)
|
||||||
|
|
||||||
|
if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
|
||||||
OLD_TIMEOUT=$(cat /sys/class/firmware/timeout)
|
OLD_TIMEOUT=$(cat /sys/class/firmware/timeout)
|
||||||
|
else
|
||||||
|
echo "usermode helper disabled so ignoring test"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
FWPATH=$(mktemp -d)
|
FWPATH=$(mktemp -d)
|
||||||
FW="$FWPATH/test-firmware.bin"
|
FW="$FWPATH/test-firmware.bin"
|
||||||
|
|
Loading…
Reference in New Issue