mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests: firmware: compare uploaded firmware through a pipe
@ 2026-10-28 20:15 Danish Khateeb
  0 siblings, 0 replies; only message in thread
From: Danish Khateeb @ 2026-10-28 20:15 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Luis Chamberlain, Danilo Krummrich, Russ Weight, driver-core,
	linux-kselftest, linux-kernel, Danish Khateeb

verify_fw() checks the data read back from the upload_read sysfs file
with cmp, sending its output to /dev/null. When the output goes to
/dev/null, GNU cmp only needs the exit status and treats regular files
of different sizes as different without reading them. Sysfs attributes
report a size of 4096, so the check fails although the data matches, and
the test stops at the first upload:

  ./fw_upload.sh: firmware compare for fw1 did not match

Feed the sysfs file to cmp through a pipe, so that its contents are
compared.

Fixes: a37ddddd8603 ("selftests: firmware: Add firmware upload selftests")
Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
---

Notes:
    Seen with GNU diffutils 3.12. Tested under virtme-ng on mainline
    62c457528529 with CONFIG_TEST_FIRMWARE and CONFIG_FW_UPLOAD: without
    this patch fw_upload.sh fails at the first compare, with it the test
    passes in 3 of 3 runs. A copy of a sysfs file that differs in one byte
    is still reported as different.
    
    An LLM was used to help with this patch.

 tools/testing/selftests/firmware/fw_upload.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/firmware/fw_upload.sh b/tools/testing/selftests/firmware/fw_upload.sh
index c7a6f06c9adb..1b234632b611 100755
--- a/tools/testing/selftests/firmware/fw_upload.sh
+++ b/tools/testing/selftests/firmware/fw_upload.sh
@@ -53,7 +53,7 @@ verify_fw() {
 	local file="$2"
 
 	echo -n "$name" > "$DIR"/config_upload_name
-	if ! cmp "$file" "$DIR"/upload_read > /dev/null 2>&1; then
+	if ! cat "$DIR"/upload_read | cmp "$file" - > /dev/null 2>&1; then
 		echo "$0: firmware compare for $name did not match" >&2
 		exit 1
 	fi

base-commit: 62c457528529cdcfa32bc52b331ceca10f3937b6
-- 
2.56.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-28 20:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 20:15 [PATCH] selftests: firmware: compare uploaded firmware through a pipe Danish Khateeb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®