aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2015-07-24 18:10:22 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-05 20:07:19 -0400
commit1d0fbb3467b5a82e33ab57f27b870c1b8275f45d (patch)
tree5a13e5a913b192f416e4b176e2af2bef9293e175
parent71cf5aeeb8e2154efda5f40be50c925f15057755 (diff)
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>
-rwxr-xr-xtools/testing/selftests/firmware/fw_filesystem.sh25
-rwxr-xr-xtools/testing/selftests/firmware/fw_userhelper.sh12
2 files changed, 31 insertions, 6 deletions
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
index 3fc6c10c2479..c4366dc74e01 100755
--- a/tools/testing/selftests/firmware/fw_filesystem.sh
+++ b/tools/testing/selftests/firmware/fw_filesystem.sh
@@ -9,7 +9,15 @@ modprobe test_firmware
9 9
10DIR=/sys/devices/virtual/misc/test_firmware 10DIR=/sys/devices/virtual/misc/test_firmware
11 11
12OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) 12# CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/
13# These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that
14# as an indicator for CONFIG_FW_LOADER_USER_HELPER.
15HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi)
16
17if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
18 OLD_TIMEOUT=$(cat /sys/class/firmware/timeout)
19fi
20
13OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path) 21OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path)
14 22
15FWPATH=$(mktemp -d) 23FWPATH=$(mktemp -d)
@@ -17,7 +25,9 @@ FW="$FWPATH/test-firmware.bin"
17 25
18test_finish() 26test_finish()
19{ 27{
20 echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout 28 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
29 echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout
30 fi
21 echo -n "$OLD_PATH" >/sys/module/firmware_class/parameters/path 31 echo -n "$OLD_PATH" >/sys/module/firmware_class/parameters/path
22 rm -f "$FW" 32 rm -f "$FW"
23 rmdir "$FWPATH" 33 rmdir "$FWPATH"
@@ -25,8 +35,11 @@ test_finish()
25 35
26trap "test_finish" EXIT 36trap "test_finish" EXIT
27 37
28# Turn down the timeout so failures don't take so long. 38if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
29echo 1 >/sys/class/firmware/timeout 39 # Turn down the timeout so failures don't take so long.
40 echo 1 >/sys/class/firmware/timeout
41fi
42
30# Set the kernel search path. 43# Set the kernel search path.
31echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path 44echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path
32 45
@@ -41,7 +54,9 @@ if diff -q "$FW" /dev/test_firmware >/dev/null ; then
41 echo "$0: firmware was not expected to match" >&2 54 echo "$0: firmware was not expected to match" >&2
42 exit 1 55 exit 1
43else 56else
44 echo "$0: timeout works" 57 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
58 echo "$0: timeout works"
59 fi
45fi 60fi
46 61
47# This should succeed via kernel load or will fail after 1 second after 62# This should succeed via kernel load or will fail after 1 second after
diff --git a/tools/testing/selftests/firmware/fw_userhelper.sh b/tools/testing/selftests/firmware/fw_userhelper.sh
index 6efbade12139..b9983f8e09f6 100755
--- a/tools/testing/selftests/firmware/fw_userhelper.sh
+++ b/tools/testing/selftests/firmware/fw_userhelper.sh
@@ -9,7 +9,17 @@ modprobe test_firmware
9 9
10DIR=/sys/devices/virtual/misc/test_firmware 10DIR=/sys/devices/virtual/misc/test_firmware
11 11
12OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) 12# CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/
13# These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that
14# as an indicator for CONFIG_FW_LOADER_USER_HELPER.
15HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi)
16
17if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
18 OLD_TIMEOUT=$(cat /sys/class/firmware/timeout)
19else
20 echo "usermode helper disabled so ignoring test"
21 exit 0
22fi
13 23
14FWPATH=$(mktemp -d) 24FWPATH=$(mktemp -d)
15FW="$FWPATH/test-firmware.bin" 25FW="$FWPATH/test-firmware.bin"