Commit 17980459 authored by Scott Branden's avatar Scott Branden Committed by Greg Kroah-Hartman

selftests: firmware: Add request_firmware_into_buf tests

Add tests cases for checking request_firmware_into_buf api.
API was introduced into kernel with no testing present previously.
Signed-off-by: default avatarScott Branden <scott.branden@broadcom.com>
Acked-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20190822184005.901-3-scott.branden@broadcom.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7feebfa4
...@@ -116,6 +116,16 @@ config_set_name() ...@@ -116,6 +116,16 @@ config_set_name()
echo -n $1 > $DIR/config_name echo -n $1 > $DIR/config_name
} }
config_set_into_buf()
{
echo 1 > $DIR/config_into_buf
}
config_unset_into_buf()
{
echo 0 > $DIR/config_into_buf
}
config_set_sync_direct() config_set_sync_direct()
{ {
echo 1 > $DIR/config_sync_direct echo 1 > $DIR/config_sync_direct
...@@ -153,11 +163,14 @@ config_set_read_fw_idx() ...@@ -153,11 +163,14 @@ config_set_read_fw_idx()
read_firmwares() read_firmwares()
{ {
if [ "$1" = "xzonly" ]; then if [ "$(cat $DIR/config_into_buf)" == "1" ]; then
fwfile="${FW}-orig" fwfile="$FW_INTO_BUF"
else else
fwfile="$FW" fwfile="$FW"
fi fi
if [ "$1" = "xzonly" ]; then
fwfile="${fwfile}-orig"
fi
for i in $(seq 0 3); do for i in $(seq 0 3); do
config_set_read_fw_idx $i config_set_read_fw_idx $i
# Verify the contents are what we expect. # Verify the contents are what we expect.
...@@ -194,6 +207,18 @@ test_batched_request_firmware_nofile() ...@@ -194,6 +207,18 @@ test_batched_request_firmware_nofile()
echo "OK" echo "OK"
} }
test_batched_request_firmware_into_buf_nofile()
{
echo -n "Batched request_firmware_into_buf() nofile try #$1: "
config_reset
config_set_name nope-test-firmware.bin
config_set_into_buf
config_trigger_sync
read_firmwares_expect_nofile
release_all_firmware
echo "OK"
}
test_batched_request_firmware_direct_nofile() test_batched_request_firmware_direct_nofile()
{ {
echo -n "Batched request_firmware_direct() nofile try #$1: " echo -n "Batched request_firmware_direct() nofile try #$1: "
...@@ -259,6 +284,18 @@ test_batched_request_firmware() ...@@ -259,6 +284,18 @@ test_batched_request_firmware()
echo "OK" echo "OK"
} }
test_batched_request_firmware_into_buf()
{
echo -n "Batched request_firmware_into_buf() $2 try #$1: "
config_reset
config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME
config_set_into_buf
config_trigger_sync
read_firmwares $2
release_all_firmware
echo "OK"
}
test_batched_request_firmware_direct() test_batched_request_firmware_direct()
{ {
echo -n "Batched request_firmware_direct() $2 try #$1: " echo -n "Batched request_firmware_direct() $2 try #$1: "
...@@ -307,6 +344,10 @@ for i in $(seq 1 5); do ...@@ -307,6 +344,10 @@ for i in $(seq 1 5); do
test_batched_request_firmware $i normal test_batched_request_firmware $i normal
done done
for i in $(seq 1 5); do
test_batched_request_firmware_into_buf $i normal
done
for i in $(seq 1 5); do for i in $(seq 1 5); do
test_batched_request_firmware_direct $i normal test_batched_request_firmware_direct $i normal
done done
...@@ -327,6 +368,10 @@ for i in $(seq 1 5); do ...@@ -327,6 +368,10 @@ for i in $(seq 1 5); do
test_batched_request_firmware_nofile $i test_batched_request_firmware_nofile $i
done done
for i in $(seq 1 5); do
test_batched_request_firmware_into_buf_nofile $i
done
for i in $(seq 1 5); do for i in $(seq 1 5); do
test_batched_request_firmware_direct_nofile $i test_batched_request_firmware_direct_nofile $i
done done
...@@ -350,6 +395,10 @@ for i in $(seq 1 5); do ...@@ -350,6 +395,10 @@ for i in $(seq 1 5); do
test_batched_request_firmware $i both test_batched_request_firmware $i both
done done
for i in $(seq 1 5); do
test_batched_request_firmware_into_buf $i both
done
for i in $(seq 1 5); do for i in $(seq 1 5); do
test_batched_request_firmware_direct $i both test_batched_request_firmware_direct $i both
done done
...@@ -370,6 +419,10 @@ for i in $(seq 1 5); do ...@@ -370,6 +419,10 @@ for i in $(seq 1 5); do
test_batched_request_firmware $i xzonly test_batched_request_firmware $i xzonly
done done
for i in $(seq 1 5); do
test_batched_request_firmware_into_buf $i xzonly
done
for i in $(seq 1 5); do for i in $(seq 1 5); do
test_batched_request_firmware_direct $i xzonly test_batched_request_firmware_direct $i xzonly
done done
......
...@@ -9,6 +9,12 @@ DIR=/sys/devices/virtual/misc/test_firmware ...@@ -9,6 +9,12 @@ DIR=/sys/devices/virtual/misc/test_firmware
PROC_CONFIG="/proc/config.gz" PROC_CONFIG="/proc/config.gz"
TEST_DIR=$(dirname $0) TEST_DIR=$(dirname $0)
# We need to load a different file to test request_firmware_into_buf
# I believe the issue is firmware loaded cached vs. non-cached
# with same filename is bungled.
# To reproduce rename this to test-firmware.bin
TEST_FIRMWARE_INTO_BUF_FILENAME=test-firmware-into-buf.bin
# Kselftest framework requirement - SKIP code is 4. # Kselftest framework requirement - SKIP code is 4.
ksft_skip=4 ksft_skip=4
...@@ -108,6 +114,8 @@ setup_tmp_file() ...@@ -108,6 +114,8 @@ setup_tmp_file()
FWPATH=$(mktemp -d) FWPATH=$(mktemp -d)
FW="$FWPATH/test-firmware.bin" FW="$FWPATH/test-firmware.bin"
echo "ABCD0123" >"$FW" echo "ABCD0123" >"$FW"
FW_INTO_BUF="$FWPATH/$TEST_FIRMWARE_INTO_BUF_FILENAME"
echo "EFGH4567" >"$FW_INTO_BUF"
NAME=$(basename "$FW") NAME=$(basename "$FW")
if [ "$TEST_REQS_FW_SET_CUSTOM_PATH" = "yes" ]; then if [ "$TEST_REQS_FW_SET_CUSTOM_PATH" = "yes" ]; then
echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path
...@@ -175,6 +183,9 @@ test_finish() ...@@ -175,6 +183,9 @@ test_finish()
if [ -f $FW ]; then if [ -f $FW ]; then
rm -f "$FW" rm -f "$FW"
fi fi
if [ -f $FW_INTO_BUF ]; then
rm -f "$FW_INTO_BUF"
fi
if [ -d $FWPATH ]; then if [ -d $FWPATH ]; then
rm -rf "$FWPATH" rm -rf "$FWPATH"
fi fi
......
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