]> git.hungrycats.org Git - linux/commitdiff
selftests: firmware: add empty string and async tests
authorBrian Norris <computersforpeace@gmail.com>
Wed, 9 Dec 2015 22:50:29 +0000 (14:50 -0800)
committerSasha Levin <alexander.levin@verizon.com>
Thu, 7 Dec 2017 02:20:02 +0000 (21:20 -0500)
[ Upstream commit 1b1fe542b6f010cf6bc7e1c92805e1c0e133e007 ]

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: Brian Norris <computersforpeace@gmail.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
tools/testing/selftests/firmware/fw_filesystem.sh

index 3fc6c10c2479c7ce4a61ebd197e84d9c917db198..b403291f47fc62a81ed64e17cd4c9e6f199214f9 100755 (executable)
@@ -35,8 +35,16 @@ echo "ABCD0123" >"$FW"
 
 NAME=$(basename "$FW")
 
+if printf '\000' >"$DIR"/trigger_request; then
+       echo "$0: empty filename should not succeed" >&2
+       exit 1
+fi
+
 # 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
        echo "$0: firmware was not expected to match" >&2
        exit 1