linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: gregkh@linuxfoundation.org
Cc: akpm@linux-foundation.org, cantabile.desu@gmail.com,
	kubakici@wp.pl, linux-wireless@vger.kernel.org,
	keescook@chromium.org, shuah@kernel.org, mfuzzey@parkeon.com,
	zohar@linux.vnet.ibm.com, dhowells@redhat.com,
	pali.rohar@gmail.com, tiwai@suse.de,
	arend.vanspriel@broadcom.com, zajec5@gmail.com, nbroeking@me.com,
	markivx@codeaurora.org, broonie@kernel.org,
	dmitry.torokhov@gmail.com, dwmw2@infradead.org,
	torvalds@linux-foundation.org, Abhay_Salunke@dell.com,
	bjorn.andersson@linaro.org, jewalt@lgsinnovations.com,
	oneukum@suse.com, ast@fb.com, andresx7@gmail.com,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	"Luis R. Rodriguez" <mcgrof@kernel.org>
Subject: [PATCH v3 17/20] test_firmware: modify custom fallback tests to use unique files
Date: Sat, 10 Mar 2018 06:14:58 -0800	[thread overview]
Message-ID: <20180310141501.2214-18-mcgrof@kernel.org> (raw)
In-Reply-To: <20180310141501.2214-1-mcgrof@kernel.org>

Users of the custom firmware fallback interface is are not supposed to
use the firmware cache interface, this can happen if for instance the
one of the APIs which use the firmware cache is used first with one
firmware file and then the request_firmware_nowait(uevent=false) API
is used with the same file.

We'll soon become strict about this on the firmware interface to reject
such calls later, so correct the test scripts to avoid such uses as well.
We address this on the tests scripts by simply using unique names when
testing the custom fallback interface.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 tools/testing/selftests/firmware/fw_fallback.sh   | 20 ++++++++++++++------
 tools/testing/selftests/firmware/fw_filesystem.sh | 11 +++++++++--
 tools/testing/selftests/firmware/fw_lib.sh        | 23 +++++++++++++++++++++++
 3 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/firmware/fw_fallback.sh b/tools/testing/selftests/firmware/fw_fallback.sh
index 9337a0328627..8e2e34a2ca69 100755
--- a/tools/testing/selftests/firmware/fw_fallback.sh
+++ b/tools/testing/selftests/firmware/fw_fallback.sh
@@ -238,8 +238,10 @@ run_sysfs_main_tests()
 
 run_sysfs_custom_load_tests()
 {
-	if load_fw_custom "$NAME" "$FW" ; then
-		if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
+	RANDOM_FILE_PATH=$(setup_random_file)
+	RANDOM_FILE="$(basename $RANDOM_FILE_PATH)"
+	if load_fw_custom "$RANDOM_FILE" "$RANDOM_FILE_PATH" ; then
+		if ! diff -q "$RANDOM_FILE_PATH" /dev/test_firmware >/dev/null ; then
 			echo "$0: firmware was not loaded" >&2
 			exit 1
 		else
@@ -247,8 +249,10 @@ run_sysfs_custom_load_tests()
 		fi
 	fi
 
-	if load_fw_custom "$NAME" "$FW" ; then
-		if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
+	RANDOM_FILE_PATH=$(setup_random_file)
+	RANDOM_FILE="$(basename $RANDOM_FILE_PATH)"
+	if load_fw_custom "$RANDOM_FILE" "$RANDOM_FILE_PATH" ; then
+		if ! diff -q "$RANDOM_FILE_PATH" /dev/test_firmware >/dev/null ; then
 			echo "$0: firmware was not loaded" >&2
 			exit 1
 		else
@@ -256,8 +260,12 @@ run_sysfs_custom_load_tests()
 		fi
 	fi
 
-	if load_fw_custom_cancel "nope-$NAME" "$FW" ; then
-		if diff -q "$FW" /dev/test_firmware >/dev/null ; then
+	RANDOM_FILE_REAL="$RANDOM_FILE_PATH"
+	FAKE_RANDOM_FILE_PATH=$(setup_random_file_fake)
+	FAKE_RANDOM_FILE="$(basename $FAKE_RANDOM_FILE_PATH)"
+
+	if load_fw_custom_cancel "$FAKE_RANDOM_FILE" "$RANDOM_FILE_REAL" ; then
+		if diff -q "$RANDOM_FILE_PATH" /dev/test_firmware >/dev/null ; then
 			echo "$0: firmware was expected to be cancelled" >&2
 			exit 1
 		else
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
index 7f47877fa7fa..6452d2129cd9 100755
--- a/tools/testing/selftests/firmware/fw_filesystem.sh
+++ b/tools/testing/selftests/firmware/fw_filesystem.sh
@@ -230,10 +230,13 @@ test_wait_and_cancel_custom_load()
 test_request_firmware_nowait_custom_nofile()
 {
 	echo -n "Batched request_firmware_nowait(uevent=false) nofile try #$1: "
+	config_reset
 	config_unset_uevent
-	config_set_name nope-test-firmware.bin
+	RANDOM_FILE_PATH=$(setup_random_file_fake)
+	RANDOM_FILE="$(basename $RANDOM_FILE_PATH)"
+	config_set_name $RANDOM_FILE
 	config_trigger_async &
-	test_wait_and_cancel_custom_load nope-test-firmware.bin
+	test_wait_and_cancel_custom_load $RANDOM_FILE
 	wait
 	release_all_firmware
 	echo "OK"
@@ -271,7 +274,11 @@ test_request_firmware_nowait_uevent()
 test_request_firmware_nowait_custom()
 {
 	echo -n "Batched request_firmware_nowait(uevent=false) try #$1: "
+	config_reset
 	config_unset_uevent
+	RANDOM_FILE_PATH=$(setup_random_file)
+	RANDOM_FILE="$(basename $RANDOM_FILE_PATH)"
+	config_set_name $RANDOM_FILE
 	config_trigger_async
 	release_all_firmware
 	echo "OK"
diff --git a/tools/testing/selftests/firmware/fw_lib.sh b/tools/testing/selftests/firmware/fw_lib.sh
index 98dceb847ba0..9ea31b57d71a 100755
--- a/tools/testing/selftests/firmware/fw_lib.sh
+++ b/tools/testing/selftests/firmware/fw_lib.sh
@@ -104,6 +104,29 @@ setup_tmp_file()
 	fi
 }
 
+__setup_random_file()
+{
+	RANDOM_FILE_PATH="$(mktemp -p $FWPATH)"
+	# mktemp says dry-run -n is unsafe, so...
+	if [[ "$1" = "fake" ]]; then
+		rm -rf $RANDOM_FILE_PATH
+		sync
+	else
+		echo "ABCD0123" >"$RANDOM_FILE_PATH"
+	fi
+	echo $RANDOM_FILE_PATH
+}
+
+setup_random_file()
+{
+	echo $(__setup_random_file)
+}
+
+setup_random_file_fake()
+{
+	echo $(__setup_random_file fake)
+}
+
 proc_set_force_sysfs_fallback()
 {
 	if [ -f $FW_FORCE_SYSFS_FALLBACK ]; then
-- 
2.16.2

  parent reply	other threads:[~2018-03-10 14:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-10 14:14 [PATCH v3 00/20] firmware: development for v4.17 Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 01/20] test_firmware: add simple firmware firmware test library Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 02/20] test_firmware: enable custom fallback testing on limited kernel configs Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 03/20] test_firmware: replace syfs fallback check with kconfig_has helper Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 04/20] firmware: enable to split firmware_class into separate target files Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 05/20] firmware: simplify CONFIG_FW_LOADER_USER_HELPER_FALLBACK further Luis R. Rodriguez
2018-03-14 18:53   ` Greg KH
2018-03-14 22:36     ` Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 06/20] firmware: use helpers for setting up a temporary cache timeout Luis R. Rodriguez
2018-03-14 18:55   ` Greg KH
2018-03-10 14:14 ` [PATCH v3 07/20] firmware: move loading timeout under struct firmware_fallback_config Luis R. Rodriguez
2018-03-14 18:56   ` Greg KH
2018-03-14 22:33     ` Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 08/20] firmware: split firmware fallback functionality into its own file Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 09/20] firmware: move firmware loader into its own directory Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 10/20] firmware: enable run time change of forcing fallback loader Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 11/20] firmware: enable to force disable the fallback mechanism at run time Luis R. Rodriguez
2018-03-14 19:00   ` Greg KH
2018-03-18 20:20     ` Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 12/20] test_firmware: expand on library with shared helpers Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 13/20] test_firmware: test three firmware kernel configs using a proc knob Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 14/20] rename: _request_firmware_load() fw_load_sysfs_fallback() Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 15/20] firmware: fix checking for return values for fw_add_devm_name() Luis R. Rodriguez
2018-03-10 14:14 ` [PATCH v3 16/20] firmware: add helper to check to see if fw cache is setup Luis R. Rodriguez
2018-03-10 14:14 ` Luis R. Rodriguez [this message]
2018-03-10 14:14 ` [PATCH v3 18/20] firmware: ensure the firmware cache is not used on incompatible calls Luis R. Rodriguez
2018-03-10 14:15 ` [PATCH v3 19/20] firmware: add request_firmware_cache() to help with cache on reboot Luis R. Rodriguez
2018-03-20  8:30   ` Greg KH
2018-03-20 17:34     ` Luis R. Rodriguez
2018-03-20 17:38       ` Greg KH
2018-03-20 18:24         ` Luis R. Rodriguez
2018-03-20 18:54           ` Konstantin Ryabitsev
2018-03-20 19:51             ` Luis R. Rodriguez
2018-03-21 10:04           ` Greg KH
2018-03-10 14:15 ` [PATCH v3 20/20] mt7601u: use request_firmware_cache() to address " Luis R. Rodriguez
2018-03-13  4:43   ` Jakub Kicinski
2018-03-10 17:16 ` [PATCH v3 00/20] firmware: development for v4.17 Kees Cook
2018-03-14 17:44   ` Luis R. Rodriguez
2018-03-14 17:58     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180310141501.2214-18-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=Abhay_Salunke@dell.com \
    --cc=akpm@linux-foundation.org \
    --cc=andresx7@gmail.com \
    --cc=arend.vanspriel@broadcom.com \
    --cc=ast@fb.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=cantabile.desu@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jewalt@lgsinnovations.com \
    --cc=keescook@chromium.org \
    --cc=kubakici@wp.pl \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=markivx@codeaurora.org \
    --cc=mfuzzey@parkeon.com \
    --cc=nbroeking@me.com \
    --cc=oneukum@suse.com \
    --cc=pali.rohar@gmail.com \
    --cc=shuah@kernel.org \
    --cc=tiwai@suse.de \
    --cc=torvalds@linux-foundation.org \
    --cc=zajec5@gmail.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).