diff mbox series

[1/1] tst_test.sh: Fix check for $TST_DEVICE

Message ID 20180628122944.3373-1-pvorel@suse.cz
State Accepted
Delegated to: Petr Vorel
Headers show
Series [1/1] tst_test.sh: Fix check for $TST_DEVICE | expand

Commit Message

Petr Vorel June 28, 2018, 12:29 p.m. UTC
When tst_device acquire call fails, it outputs into stdout,
therefore the content is actually help message.
=> Check for file presence rather than variable not being empty.

Fixes: c5ac5d712 tst_test.sh: Make use of tst_device helper

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,

other option would be to check $?.

BTW found while testing on TMPDIR being tmpfs with small size (300M).
Test lib/newlib_tests/tst_device.c obviously fails.

Kind regards,
Petr
---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Stancek June 28, 2018, 7:59 p.m. UTC | #1
----- Original Message -----
> When tst_device acquire call fails, it outputs into stdout,
> therefore the content is actually help message.
> => Check for file presence rather than variable not being empty.
> 
> Fixes: c5ac5d712 tst_test.sh: Make use of tst_device helper
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>

Good find, ACK

> ---
> Hi,
> 
> other option would be to check $?.

Or both. Attach is very last call to ioctl(), so I think
we can't end up with valid block device and non-zero retcode.
Cyril Hrubis June 29, 2018, 1:49 p.m. UTC | #2
Hi!
> When tst_device acquire call fails, it outputs into stdout,
> therefore the content is actually help message.
> => Check for file presence rather than variable not being empty.
> 
> Fixes: c5ac5d712 tst_test.sh: Make use of tst_device helper

Good catch, I guess that it also wouldn't harm if we changed the helper
to print the help message to stderr as well.
Petr Vorel June 29, 2018, 2:58 p.m. UTC | #3
Hi,

> When tst_device acquire call fails, it outputs into stdout,
> therefore the content is actually help message.
> => Check for file presence rather than variable not being empty.

> Fixes: c5ac5d712 tst_test.sh: Make use of tst_device helper

> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,

> other option would be to check $?.

> BTW found while testing on TMPDIR being tmpfs with small size (300M).
> Test lib/newlib_tests/tst_device.c obviously fails.

> Kind regards,
> Petr
> ---
>  testcases/lib/tst_test.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index d27b4afd6..799045b03 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -364,7 +364,7 @@ tst_run()

>  		TST_DEVICE=$(tst_device acquire)

> -		if [ -z "$TST_DEVICE" ]; then
> +		if [ ! -b "$TST_DEVICE" ]; then
>  			tst_brk TBROK "Failed to acquire device"
>  		fi
Pushed with Jan's ack and as 
-               if [ -z "$TST_DEVICE" ]; then
+               if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then


Kind regards,
Petr
Petr Vorel June 29, 2018, 3:22 p.m. UTC | #4
Hi, 
> Hi!
> > When tst_device acquire call fails, it outputs into stdout,
> > therefore the content is actually help message.
> > => Check for file presence rather than variable not being empty.

> > Fixes: c5ac5d712 tst_test.sh: Make use of tst_device helper

> Good catch, I guess that it also wouldn't harm if we changed the helper
> to print the help message to stderr as well.

Pushed, with your Suggested-by:


Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index d27b4afd6..799045b03 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -364,7 +364,7 @@  tst_run()
 
 		TST_DEVICE=$(tst_device acquire)
 
-		if [ -z "$TST_DEVICE" ]; then
+		if [ ! -b "$TST_DEVICE" ]; then
 			tst_brk TBROK "Failed to acquire device"
 		fi