Commit 9952db75 authored by Luis R. Rodriguez's avatar Luis R. Rodriguez Committed by Greg Kroah-Hartman

test_firmware: modify custom fallback tests to use unique files

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: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3194d06a
...@@ -238,8 +238,10 @@ run_sysfs_main_tests() ...@@ -238,8 +238,10 @@ run_sysfs_main_tests()
run_sysfs_custom_load_tests() run_sysfs_custom_load_tests()
{ {
if load_fw_custom "$NAME" "$FW" ; then RANDOM_FILE_PATH=$(setup_random_file)
if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then 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 echo "$0: firmware was not loaded" >&2
exit 1 exit 1
else else
...@@ -247,8 +249,10 @@ run_sysfs_custom_load_tests() ...@@ -247,8 +249,10 @@ run_sysfs_custom_load_tests()
fi fi
fi fi
if load_fw_custom "$NAME" "$FW" ; then RANDOM_FILE_PATH=$(setup_random_file)
if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then 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 echo "$0: firmware was not loaded" >&2
exit 1 exit 1
else else
...@@ -256,8 +260,12 @@ run_sysfs_custom_load_tests() ...@@ -256,8 +260,12 @@ run_sysfs_custom_load_tests()
fi fi
fi fi
if load_fw_custom_cancel "nope-$NAME" "$FW" ; then RANDOM_FILE_REAL="$RANDOM_FILE_PATH"
if diff -q "$FW" /dev/test_firmware >/dev/null ; then 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 echo "$0: firmware was expected to be cancelled" >&2
exit 1 exit 1
else else
......
...@@ -230,10 +230,13 @@ test_wait_and_cancel_custom_load() ...@@ -230,10 +230,13 @@ test_wait_and_cancel_custom_load()
test_request_firmware_nowait_custom_nofile() test_request_firmware_nowait_custom_nofile()
{ {
echo -n "Batched request_firmware_nowait(uevent=false) nofile try #$1: " echo -n "Batched request_firmware_nowait(uevent=false) nofile try #$1: "
config_reset
config_unset_uevent 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 & config_trigger_async &
test_wait_and_cancel_custom_load nope-test-firmware.bin test_wait_and_cancel_custom_load $RANDOM_FILE
wait wait
release_all_firmware release_all_firmware
echo "OK" echo "OK"
...@@ -271,7 +274,11 @@ test_request_firmware_nowait_uevent() ...@@ -271,7 +274,11 @@ test_request_firmware_nowait_uevent()
test_request_firmware_nowait_custom() test_request_firmware_nowait_custom()
{ {
echo -n "Batched request_firmware_nowait(uevent=false) try #$1: " echo -n "Batched request_firmware_nowait(uevent=false) try #$1: "
config_reset
config_unset_uevent config_unset_uevent
RANDOM_FILE_PATH=$(setup_random_file)
RANDOM_FILE="$(basename $RANDOM_FILE_PATH)"
config_set_name $RANDOM_FILE
config_trigger_async config_trigger_async
release_all_firmware release_all_firmware
echo "OK" echo "OK"
......
...@@ -104,6 +104,29 @@ setup_tmp_file() ...@@ -104,6 +104,29 @@ setup_tmp_file()
fi 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() proc_set_force_sysfs_fallback()
{ {
if [ -f $FW_FORCE_SYSFS_FALLBACK ]; then if [ -f $FW_FORCE_SYSFS_FALLBACK ]; then
......
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