Commit 1b1fe542 authored by Brian Norris's avatar Brian Norris Committed by Shuah Khan

selftests: firmware: add empty string and async tests

Now that we've added a 'trigger_async_request' knob to test the
request_firmware_nowait() API, let's use it. Also add tests for the
empty ("") string, since there have been a couple errors in that
handling already.

Since we now have real ways that the sysfs write might fail, let's add
the appropriate check on the 'echo' lines too.
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Acked-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
parent 715780ae
...@@ -48,8 +48,21 @@ echo "ABCD0123" >"$FW" ...@@ -48,8 +48,21 @@ echo "ABCD0123" >"$FW"
NAME=$(basename "$FW") NAME=$(basename "$FW")
if printf '\000' >"$DIR"/trigger_request; then
echo "$0: empty filename should not succeed" >&2
exit 1
fi
if printf '\000' >"$DIR"/trigger_async_request; then
echo "$0: empty filename should not succeed (async)" >&2
exit 1
fi
# Request a firmware that doesn't exist, it should fail. # Request a firmware that doesn't exist, it should fail.
echo -n "nope-$NAME" >"$DIR"/trigger_request if echo -n "nope-$NAME" >"$DIR"/trigger_request; then
echo "$0: firmware shouldn't have loaded" >&2
exit 1
fi
if diff -q "$FW" /dev/test_firmware >/dev/null ; then 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
...@@ -74,4 +87,18 @@ else ...@@ -74,4 +87,18 @@ else
echo "$0: filesystem loading works" echo "$0: filesystem loading works"
fi fi
# Try the asynchronous version too
if ! echo -n "$NAME" >"$DIR"/trigger_async_request ; then
echo "$0: could not trigger async request" >&2
exit 1
fi
# Verify the contents are what we expect.
if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
echo "$0: firmware was not loaded (async)" >&2
exit 1
else
echo "$0: async filesystem loading works"
fi
exit 0 exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment