From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753992AbbLIWvM (ORCPT ); Wed, 9 Dec 2015 17:51:12 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:34873 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753935AbbLIWu6 (ORCPT ); Wed, 9 Dec 2015 17:50:58 -0500 From: Brian Norris To: Shuah Khan , Greg Kroah-Hartman , Ming Lei Cc: Kees Cook , Brian Norris , , , "Luis R. Rodriguez" Subject: [PATCH v2 5/5] selftests: firmware: add empty string and async tests Date: Wed, 9 Dec 2015 14:50:29 -0800 Message-Id: <1449701429-121423-5-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> References: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Kees Cook --- v2: * fix some spelling in commit message (wow, I wrote an atrocious sentence!) * use octal notation for printf, since the hex is non-POSIX and doesn't work in dash 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..5c495ad7958a 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 '\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. -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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Norris Subject: [PATCH v2 5/5] selftests: firmware: add empty string and async tests Date: Wed, 9 Dec 2015 14:50:29 -0800 Message-ID: <1449701429-121423-5-git-send-email-computersforpeace@gmail.com> References: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> Return-path: In-Reply-To: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: Shuah Khan , Greg Kroah-Hartman , Ming Lei Cc: Kees Cook , Brian Norris , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, "Luis R. Rodriguez" List-Id: linux-api@vger.kernel.org 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 Acked-by: Kees Cook --- v2: * fix some spelling in commit message (wow, I wrote an atrocious sentence!) * use octal notation for printf, since the hex is non-POSIX and doesn't work in dash 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..5c495ad7958a 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 '\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. -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