selftests: firmware: compare uploaded firmware through a pipe
Subsystems (2)
PATCH 1/1 selftests: firmware: compare uploaded firmware through a pipe
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.
---
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(-)
tools/testing/selftests/firmware/fw_upload.sh +1 -1
@@ -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
Signature · 1 line
2.56.0