All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib/tst_test.sh: fix ROD_SILENT command return status check
@ 2021-08-19 15:21 Alexey Kodanev
  2021-08-19 16:03 ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kodanev @ 2021-08-19 15:21 UTC (permalink / raw)
  To: ltp

"local tst_out=$(some_command)" always returns status 0, i.e.
not the return status of the command in the assignment, but the
status for 'local' builtin command, which creates a new local
variable inside the function.

As a result, the library calls and tests that invoke ROD_SILENT
don't actually check the return status of commands passed to it.

The old API library function is also fixed.

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
 testcases/lib/test.sh     | 4 +++-
 testcases/lib/tst_test.sh | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index 92278d7aa..8947f47c1 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -233,7 +233,9 @@ tst_timeout()
 
 ROD_SILENT()
 {
-	local tst_out="$($@ 2>&1)"
+	local tst_out
+
+	tst_out="$($@ 2>&1)"
 	if [ $? -ne 0 ]; then
 		echo "$tst_out"
 		tst_brkm TBROK "$@ failed"
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index c6aa2c487..3710c857e 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -126,7 +126,9 @@ tst_brk()
 
 ROD_SILENT()
 {
-	local tst_out="$(tst_rod $@ 2>&1)"
+	local tst_out
+
+	tst_out="$(tst_rod $@ 2>&1)"
 	if [ $? -ne 0 ]; then
 		echo "$tst_out"
 		tst_brk TBROK "$@ failed"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] lib/tst_test.sh: fix ROD_SILENT command return status check
  2021-08-19 15:21 [LTP] [PATCH] lib/tst_test.sh: fix ROD_SILENT command return status check Alexey Kodanev
@ 2021-08-19 16:03 ` Petr Vorel
  2021-08-20  9:00   ` Alexey Kodanev
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2021-08-19 16:03 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> "local tst_out=$(some_command)" always returns status 0, i.e.
> not the return status of the command in the assignment, but the
> status for 'local' builtin command, which creates a new local
> variable inside the function.

> As a result, the library calls and tests that invoke ROD_SILENT
> don't actually check the return status of commands passed to it.

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Very good catch, thanks!

Tested-by: Petr Vorel <pvorel@suse.cz>
Working the same in: bash, dash, busybox sh, mksh (android).

> The old API library function is also fixed.
+1

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] lib/tst_test.sh: fix ROD_SILENT command return status check
  2021-08-19 16:03 ` Petr Vorel
@ 2021-08-20  9:00   ` Alexey Kodanev
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Kodanev @ 2021-08-20  9:00 UTC (permalink / raw)
  To: ltp

On 19.08.2021 19:03, Petr Vorel wrote:
> Hi Alexey,
> 
>> "local tst_out=$(some_command)" always returns status 0, i.e.
>> not the return status of the command in the assignment, but the
>> status for 'local' builtin command, which creates a new local
>> variable inside the function.
> 
>> As a result, the library calls and tests that invoke ROD_SILENT
>> don't actually check the return status of commands passed to it.
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Very good catch, thanks!
> 
> Tested-by: Petr Vorel <pvorel@suse.cz>
> Working the same in: bash, dash, busybox sh, mksh (android).
> 
>> The old API library function is also fixed.
> +1
> 

Applied. Thanks Petr!



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-20  9:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 15:21 [LTP] [PATCH] lib/tst_test.sh: fix ROD_SILENT command return status check Alexey Kodanev
2021-08-19 16:03 ` Petr Vorel
2021-08-20  9:00   ` Alexey Kodanev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.