diff mbox series

[1/2] selftests: firmware: remove use of non-standard diff -Z option

Message ID 20181127031218.24419-2-dan.rue@linaro.org (mailing list archive)
State New
Headers show
Series selftests: firmware: fw_filesystem fix for busybox | expand

Commit Message

Dan Rue Nov. 27, 2018, 3:12 a.m. UTC

Comments

Kees Cook Nov. 27, 2018, 5:56 p.m. UTC | #1
On Mon, Nov 26, 2018 at 7:12 PM, Dan Rue <dan.rue@linaro.org> wrote:
> diff -Z is used to trim the trailing whitespace when comparing the
> loaded firmware file with the source firmware file. However, per the
> comment in the source code, -Z should not be necessary. In testing, the
> input and output files are identical.
>
> Additionally, -Z is not a standard option and is not available in
> environments such as busybox. When -Z is not supported, diff fails with
> a usage error, which is suppressed, but then causes read_firmwares() to
> exit with a false failure message.
>
> Signed-off-by: Dan Rue <dan.rue@linaro.org>

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  tools/testing/selftests/firmware/fw_filesystem.sh | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
> index a4320c4b44dc..466cf2f91ba0 100755
> --- a/tools/testing/selftests/firmware/fw_filesystem.sh
> +++ b/tools/testing/selftests/firmware/fw_filesystem.sh
> @@ -155,11 +155,8 @@ read_firmwares()
>  {
>         for i in $(seq 0 3); do
>                 config_set_read_fw_idx $i
> -               # Verify the contents are what we expect.
> -               # -Z required for now -- check for yourself, md5sum
> -               # on $FW and DIR/read_firmware will yield the same. Even
> -               # cmp agrees, so something is off.
> -               if ! diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then
> +               # Verify the contents match
> +               if ! diff -q "$FW" $DIR/read_firmware 2>/dev/null ; then
>                         echo "request #$i: firmware was not loaded" >&2
>                         exit 1
>                 fi
> @@ -171,7 +168,7 @@ read_firmwares_expect_nofile()
>         for i in $(seq 0 3); do
>                 config_set_read_fw_idx $i
>                 # Ensures contents differ
> -               if diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then
> +               if diff -q "$FW" $DIR/read_firmware 2>/dev/null ; then
>                         echo "request $i: file was not expected to match" >&2
>                         exit 1
>                 fi
> --
> 2.19.1
>
Luis Chamberlain Nov. 30, 2018, 2:37 a.m. UTC | #2
On Mon, Nov 26, 2018 at 09:12:15PM -0600, Dan Rue wrote:
> diff -Z is used to trim the trailing whitespace when comparing the
> loaded firmware file with the source firmware file. However, per the
> comment in the source code, -Z should not be necessary. In testing, the
> input and output files are identical.
> 
> Additionally, -Z is not a standard option and is not available in
> environments such as busybox. When -Z is not supported, diff fails with
> a usage error, which is suppressed, but then causes read_firmwares() to
> exit with a false failure message.

NACK -- this breaks testing on debian:

Testing with the file present...
Batched request_firmware() try #1: Files
/tmp/tmp.8GWkoSo5jZ/test-firmware.bin and
/sys/devices/virtual/misc/test_firmware/read_firmware differ
request #0: firmware was not loaded

Please add a quirks check, enable it by default, and remove it for
Busybox.

   Luis
Dan Rue Dec. 5, 2018, 8:43 p.m. UTC | #3
On Thu, Nov 29, 2018 at 06:37:32PM -0800, Luis Chamberlain wrote:
> On Mon, Nov 26, 2018 at 09:12:15PM -0600, Dan Rue wrote:
> > diff -Z is used to trim the trailing whitespace when comparing the
> > loaded firmware file with the source firmware file. However, per the
> > comment in the source code, -Z should not be necessary. In testing, the
> > input and output files are identical.
> > 
> > Additionally, -Z is not a standard option and is not available in
> > environments such as busybox. When -Z is not supported, diff fails with
> > a usage error, which is suppressed, but then causes read_firmwares() to
> > exit with a false failure message.
> 
> NACK -- this breaks testing on debian:
> 
> Testing with the file present...
> Batched request_firmware() try #1: Files
> /tmp/tmp.8GWkoSo5jZ/test-firmware.bin and
> /sys/devices/virtual/misc/test_firmware/read_firmware differ
> request #0: firmware was not loaded
> 
> Please add a quirks check, enable it by default, and remove it for
> Busybox.

Thanks for the review. Shuah, can you please drop this one?

Dan
Luis Chamberlain Feb. 7, 2019, 6:20 p.m. UTC | #4
On Wed, Dec 5, 2018 at 2:43 PM Dan Rue <dan.rue@linaro.org> wrote:
>
> On Thu, Nov 29, 2018 at 06:37:32PM -0800, Luis Chamberlain wrote:
> > On Mon, Nov 26, 2018 at 09:12:15PM -0600, Dan Rue wrote:
> > > diff -Z is used to trim the trailing whitespace when comparing the
> > > loaded firmware file with the source firmware file. However, per the
> > > comment in the source code, -Z should not be necessary. In testing, the
> > > input and output files are identical.
> > >
> > > Additionally, -Z is not a standard option and is not available in
> > > environments such as busybox. When -Z is not supported, diff fails with
> > > a usage error, which is suppressed, but then causes read_firmwares() to
> > > exit with a false failure message.
> >
> > NACK -- this breaks testing on debian:
> >
> > Testing with the file present...
> > Batched request_firmware() try #1: Files
> > /tmp/tmp.8GWkoSo5jZ/test-firmware.bin and
> > /sys/devices/virtual/misc/test_firmware/read_firmware differ
> > request #0: firmware was not loaded
> >
> > Please add a quirks check, enable it by default, and remove it for
> > Busybox.
>
> Thanks for the review. Shuah, can you please drop this one?

So much for review. This patch was still merged. I'll have to request
this to be reverted now too.

  Luis
Shuah Feb. 8, 2019, 5:53 p.m. UTC | #5
On 2/7/19 11:20 AM, Luis Chamberlain wrote:
> On Wed, Dec 5, 2018 at 2:43 PM Dan Rue <dan.rue@linaro.org> wrote:
>>
>> On Thu, Nov 29, 2018 at 06:37:32PM -0800, Luis Chamberlain wrote:
>>> On Mon, Nov 26, 2018 at 09:12:15PM -0600, Dan Rue wrote:
>>>> diff -Z is used to trim the trailing whitespace when comparing the
>>>> loaded firmware file with the source firmware file. However, per the
>>>> comment in the source code, -Z should not be necessary. In testing, the
>>>> input and output files are identical.
>>>>
>>>> Additionally, -Z is not a standard option and is not available in
>>>> environments such as busybox. When -Z is not supported, diff fails with
>>>> a usage error, which is suppressed, but then causes read_firmwares() to
>>>> exit with a false failure message.
>>>
>>> NACK -- this breaks testing on debian:
>>>
>>> Testing with the file present...
>>> Batched request_firmware() try #1: Files
>>> /tmp/tmp.8GWkoSo5jZ/test-firmware.bin and
>>> /sys/devices/virtual/misc/test_firmware/read_firmware differ
>>> request #0: firmware was not loaded
>>>
>>> Please add a quirks check, enable it by default, and remove it for
>>> Busybox.
>>
>> Thanks for the review. Shuah, can you please drop this one?
> 
> So much for review. This patch was still merged. I'll have to request
> this to be reverted now too.
> 
>    Luis
> 

Sorry about this. I will pull the reverts in.

thanks,
-- Shuah
diff mbox series

Patch

diff -Z is used to trim the trailing whitespace when comparing the
loaded firmware file with the source firmware file. However, per the
comment in the source code, -Z should not be necessary. In testing, the
input and output files are identical.

Additionally, -Z is not a standard option and is not available in
environments such as busybox. When -Z is not supported, diff fails with
a usage error, which is suppressed, but then causes read_firmwares() to
exit with a false failure message.

Signed-off-by: Dan Rue <dan.rue@linaro.org>
---
 tools/testing/selftests/firmware/fw_filesystem.sh | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
index a4320c4b44dc..466cf2f91ba0 100755
--- a/tools/testing/selftests/firmware/fw_filesystem.sh
+++ b/tools/testing/selftests/firmware/fw_filesystem.sh
@@ -155,11 +155,8 @@  read_firmwares()
 {
 	for i in $(seq 0 3); do
 		config_set_read_fw_idx $i
-		# Verify the contents are what we expect.
-		# -Z required for now -- check for yourself, md5sum
-		# on $FW and DIR/read_firmware will yield the same. Even
-		# cmp agrees, so something is off.
-		if ! diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then
+		# Verify the contents match
+		if ! diff -q "$FW" $DIR/read_firmware 2>/dev/null ; then
 			echo "request #$i: firmware was not loaded" >&2
 			exit 1
 		fi
@@ -171,7 +168,7 @@  read_firmwares_expect_nofile()
 	for i in $(seq 0 3); do
 		config_set_read_fw_idx $i
 		# Ensures contents differ
-		if diff -q -Z "$FW" $DIR/read_firmware 2>/dev/null ; then
+		if diff -q "$FW" $DIR/read_firmware 2>/dev/null ; then
 			echo "request $i: file was not expected to match" >&2
 			exit 1
 		fi