diff options
author | Luis R. Rodriguez <mcgrof@suse.com> | 2015-07-24 18:10:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-08-05 20:07:19 -0400 |
commit | 1d0fbb3467b5a82e33ab57f27b870c1b8275f45d (patch) | |
tree | 5a13e5a913b192f416e4b176e2af2bef9293e175 | |
parent | 71cf5aeeb8e2154efda5f40be50c925f15057755 (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-x | tools/testing/selftests/firmware/fw_filesystem.sh | 25 | ||||
-rwxr-xr-x | tools/testing/selftests/firmware/fw_userhelper.sh | 12 |
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 | ||
10 | DIR=/sys/devices/virtual/misc/test_firmware | 10 | DIR=/sys/devices/virtual/misc/test_firmware |
11 | 11 | ||
12 | OLD_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. | ||
15 | HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi) | ||
16 | |||
17 | if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then | ||
18 | OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) | ||
19 | fi | ||
20 | |||
13 | OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path) | 21 | OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path) |
14 | 22 | ||
15 | FWPATH=$(mktemp -d) | 23 | FWPATH=$(mktemp -d) |
@@ -17,7 +25,9 @@ FW="$FWPATH/test-firmware.bin" | |||
17 | 25 | ||
18 | test_finish() | 26 | test_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 | ||
26 | trap "test_finish" EXIT | 36 | trap "test_finish" EXIT |
27 | 37 | ||
28 | # Turn down the timeout so failures don't take so long. | 38 | if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then |
29 | echo 1 >/sys/class/firmware/timeout | 39 | # Turn down the timeout so failures don't take so long. |
40 | echo 1 >/sys/class/firmware/timeout | ||
41 | fi | ||
42 | |||
30 | # Set the kernel search path. | 43 | # Set the kernel search path. |
31 | echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path | 44 | echo -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 |
43 | else | 56 | else |
44 | echo "$0: timeout works" | 57 | if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then |
58 | echo "$0: timeout works" | ||
59 | fi | ||
45 | fi | 60 | fi |
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 | ||
10 | DIR=/sys/devices/virtual/misc/test_firmware | 10 | DIR=/sys/devices/virtual/misc/test_firmware |
11 | 11 | ||
12 | OLD_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. | ||
15 | HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi) | ||
16 | |||
17 | if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then | ||
18 | OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) | ||
19 | else | ||
20 | echo "usermode helper disabled so ignoring test" | ||
21 | exit 0 | ||
22 | fi | ||
13 | 23 | ||
14 | FWPATH=$(mktemp -d) | 24 | FWPATH=$(mktemp -d) |
15 | FW="$FWPATH/test-firmware.bin" | 25 | FW="$FWPATH/test-firmware.bin" |