Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1287021

[PATCH 4/4] selftests: firmware: add empty string and async tests

From Brian Norris <computersforpeace@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 4/4] selftests: firmware: add empty string and async tests
Date 2015-12-09 03:40 +0100
Message-ID <qDCPD-2c5-17@gated-at.bofh.it> (permalink)
References <qDCPD-2c5-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 know have real wasy 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>
---
 tools/testing/selftests/firmware/fw_filesystem.sh | 29 ++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
index c4366dc74e01..e12210e1317c 100755
--- a/tools/testing/selftests/firmware/fw_filesystem.sh
+++ b/tools/testing/selftests/firmware/fw_filesystem.sh
@@ -48,8 +48,21 @@ echo "ABCD0123" >"$FW"
 
 NAME=$(basename "$FW")
 
+if printf '\x00' >"$DIR"/trigger_request; then
+	echo "$0: empty filename should not succeed" >&2
+	exit 1
+fi
+
+if printf '\x00' >"$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.
-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
@@ -74,4 +87,18 @@ else
 	echo "$0: filesystem loading works"
 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
-- 
2.6.0.rc2.230.g3dd15c0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/4] test: firmware_class: report errors properly on failure Brian Norris <computersforpeace@gmail.com> - 2015-12-09 03:40 +0100
  [PATCH 4/4] selftests: firmware: add empty string and async tests Brian Norris <computersforpeace@gmail.com> - 2015-12-09 03:40 +0100
    Re: [PATCH 4/4] selftests: firmware: add empty string and async tests Kees Cook <keescook@chromium.org> - 2015-12-09 22:20 +0100
  [PATCH 3/4] firmware: actually return NULL on failed request_firmware_nowait() Brian Norris <computersforpeace@gmail.com> - 2015-12-09 03:50 +0100
    Re: [PATCH 3/4] firmware: actually return NULL on failed request_firmware_nowait() Ming Lei <ming.lei@canonical.com> - 2015-12-09 05:10 +0100
    Re: [PATCH 3/4] firmware: actually return NULL on failed request_firmware_nowait() Kees Cook <keescook@chromium.org> - 2015-12-09 22:20 +0100
  [PATCH 2/4] test: firmware_class: add asynchronous request trigger Brian Norris <computersforpeace@gmail.com> - 2015-12-09 03:50 +0100
    Re: [PATCH 2/4] test: firmware_class: add asynchronous request trigger Kees Cook <keescook@chromium.org> - 2015-12-09 22:10 +0100
      Re: [PATCH 2/4] test: firmware_class: add asynchronous request  trigger Brian Norris <computersforpeace@gmail.com> - 2015-12-09 22:50 +0100
        Re: [PATCH 2/4] test: firmware_class: add asynchronous request trigger Kees Cook <keescook@chromium.org> - 2015-12-09 23:10 +0100
          Re: [PATCH 2/4] test: firmware_class: add asynchronous request  trigger Brian Norris <computersforpeace@gmail.com> - 2015-12-09 23:20 +0100
  Re: [PATCH 1/4] test: firmware_class: report errors properly on failure Kees Cook <keescook@chromium.org> - 2015-12-09 22:20 +0100

csiph-web