2 # This validates that the kernel will load firmware out of its list of
3 # firmware locations on disk. Since the user helper does similar work,
4 # we reset the custom load directory to a location the user helper doesn't
5 # know so we can be sure we're not accidentally testing the user helper.
10 DIR
=/sys
/devices
/virtual
/misc
/test_firmware
12 OLD_TIMEOUT
=$
(cat /sys
/class
/firmware
/timeout
)
13 OLD_FWPATH
=$
(cat /sys
/module
/firmware_class
/parameters
/path
)
16 FW
="$FWPATH/test-firmware.bin"
20 echo "$OLD_TIMEOUT" >/sys
/class
/firmware
/timeout
21 echo -n "$OLD_PATH" >/sys
/module
/firmware_class
/parameters
/path
26 trap "test_finish" EXIT
28 # Turn down the timeout so failures don't take so long.
29 echo 1 >/sys
/class
/firmware
/timeout
30 # Set the kernel search path.
31 echo -n "$FWPATH" >/sys
/module
/firmware_class
/parameters
/path
33 # This is an unlikely real-world firmware content. :)
34 echo "ABCD0123" >"$FW"
36 NAME
=$
(basename "$FW")
38 # Request a firmware that doesn't exist, it should fail.
39 echo -n "nope-$NAME" >"$DIR"/trigger_request
40 if diff -q "$FW" /dev
/test_firmware
>/dev
/null
; then
41 echo "$0: firmware was not expected to match" >&2
44 echo "$0: timeout works"
47 # This should succeed via kernel load or will fail after 1 second after
48 # being handed over to the user helper, which won't find the fw either.
49 if ! echo -n "$NAME" >"$DIR"/trigger_request
; then
50 echo "$0: could not trigger request" >&2
54 # Verify the contents are what we expect.
55 if ! diff -q "$FW" /dev
/test_firmware
>/dev
/null
; then
56 echo "$0: firmware was not loaded" >&2
59 echo "$0: filesystem loading works"