public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
@ 2018-02-12 14:40 Cyril Hrubis
  0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2018-02-12 14:40 UTC (permalink / raw)
  To: ltp

Recently we had a problem when openQA (test automation framework) passed
wrong device path as LTP_BIG_DEV. It has been much more complicated to
debug because the error message from mkfs was not shown at all, since
the tst_mkfs uses ROD_SILENT to execute the mkfs command.

The best solution for ROD_SILENT is to store the command output into a
variable and print it only on failure which is done by this patch.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/lib/test.sh     | 3 ++-
 testcases/lib/tst_test.sh | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index 341c1f0f4..bce9893a9 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -225,8 +225,9 @@ tst_timeout()
 
 ROD_SILENT()
 {
-	$@ > /dev/null 2>&1
+	local tst_out=$($@ 2>&1)
 	if [ $? -ne 0 ]; then
+		echo "$tst_out"
 		tst_brkm TBROK "$@ failed"
 	fi
 }
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index d6b638549..48afb9cc4 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -118,8 +118,9 @@ tst_brk()
 
 ROD_SILENT()
 {
-	tst_rod $@ > /dev/null 2>&1
+	local tst_out=$(tst_rod $@ 2>&1)
 	if [ $? -ne 0 ]; then
+		echo "$tst_out"
 		tst_brk TBROK "$@ failed"
 	fi
 }
-- 
2.13.6


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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
@ 2018-02-12 15:03 Cyril Hrubis
  2018-02-21  9:12 ` Richard Palethorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2018-02-12 15:03 UTC (permalink / raw)
  To: ltp

Recently we had a problem when openQA (test automation framework) passed
wrong device path as LTP_BIG_DEV. It has been much more complicated to
debug because the error message from mkfs was not shown at all, since
the tst_mkfs uses ROD_SILENT to execute the mkfs command.

The best solution for ROD_SILENT is to store the command output into a
variable and print it only on failure which is done by this patch.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/lib/test.sh     | 3 ++-
 testcases/lib/tst_test.sh | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index 341c1f0f4..bce9893a9 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -225,8 +225,9 @@ tst_timeout()
 
 ROD_SILENT()
 {
-	$@ > /dev/null 2>&1
+	local tst_out=$($@ 2>&1)
 	if [ $? -ne 0 ]; then
+		echo "$tst_out"
 		tst_brkm TBROK "$@ failed"
 	fi
 }
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index d6b638549..48afb9cc4 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -118,8 +118,9 @@ tst_brk()
 
 ROD_SILENT()
 {
-	tst_rod $@ > /dev/null 2>&1
+	local tst_out=$(tst_rod $@ 2>&1)
 	if [ $? -ne 0 ]; then
+		echo "$tst_out"
 		tst_brk TBROK "$@ failed"
 	fi
 }
-- 
2.13.6


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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
  2018-02-12 15:03 [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure Cyril Hrubis
@ 2018-02-21  9:12 ` Richard Palethorpe
  2018-02-22  4:05   ` Li Wang
  2018-03-13 12:46   ` Cyril Hrubis
  0 siblings, 2 replies; 9+ messages in thread
From: Richard Palethorpe @ 2018-02-21  9:12 UTC (permalink / raw)
  To: ltp

Hello,

Cyril Hrubis writes:

> Recently we had a problem when openQA (test automation framework) passed
> wrong device path as LTP_BIG_DEV. It has been much more complicated to
> debug because the error message from mkfs was not shown at all, since
> the tst_mkfs uses ROD_SILENT to execute the mkfs command.
>
> The best solution for ROD_SILENT is to store the command output into a
> variable and print it only on failure which is done by this patch.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  testcases/lib/test.sh     | 3 ++-
>  testcases/lib/tst_test.sh | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
> index 341c1f0f4..bce9893a9 100644
> --- a/testcases/lib/test.sh
> +++ b/testcases/lib/test.sh
> @@ -225,8 +225,9 @@ tst_timeout()
>  
>  ROD_SILENT()
>  {
> -	$@ > /dev/null 2>&1
> +	local tst_out=$($@ 2>&1)
>  	if [ $? -ne 0 ]; then
> +		echo "$tst_out"
>  		tst_brkm TBROK "$@ failed"
>  	fi
>  }
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index d6b638549..48afb9cc4 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -118,8 +118,9 @@ tst_brk()
>  
>  ROD_SILENT()
>  {
> -	tst_rod $@ > /dev/null 2>&1
> +	local tst_out=$(tst_rod $@ 2>&1)
>  	if [ $? -ne 0 ]; then
> +		echo "$tst_out"
>  		tst_brk TBROK "$@ failed"
>  	fi
>  }
> -- 
> 2.13.6

LGTM except that you could maybe use ${ } instead of $( ) as a small
optimisation.

-- 
Thank you,
Richard.

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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
  2018-02-21  9:12 ` Richard Palethorpe
@ 2018-02-22  4:05   ` Li Wang
  2018-03-13 12:46   ` Cyril Hrubis
  1 sibling, 0 replies; 9+ messages in thread
From: Li Wang @ 2018-02-22  4:05 UTC (permalink / raw)
  To: ltp

On Wed, Feb 21, 2018 at 5:12 PM, Richard Palethorpe <rpalethorpe@suse.de>
wrote:

> Hello,
>
> Cyril Hrubis writes:
>
> > Recently we had a problem when openQA (test automation framework) passed
> > wrong device path as LTP_BIG_DEV. It has been much more complicated to
> > debug because the error message from mkfs was not shown at all, since
> > the tst_mkfs uses ROD_SILENT to execute the mkfs command.
> >
> > The best solution for ROD_SILENT is to store the command output into a
> > variable and print it only on failure which is done by this patch.
> >
> > Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> > ---
> >  testcases/lib/test.sh     | 3 ++-
> >  testcases/lib/tst_test.sh | 3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
> > index 341c1f0f4..bce9893a9 100644
> > --- a/testcases/lib/test.sh
> > +++ b/testcases/lib/test.sh
> > @@ -225,8 +225,9 @@ tst_timeout()
> >
> >  ROD_SILENT()
> >  {
> > -     $@ > /dev/null 2>&1
> > +     local tst_out=$($@ 2>&1)
> >       if [ $? -ne 0 ]; then
> > +             echo "$tst_out"
> >               tst_brkm TBROK "$@ failed"
> >       fi
> >  }
> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> > index d6b638549..48afb9cc4 100644
> > --- a/testcases/lib/tst_test.sh
> > +++ b/testcases/lib/tst_test.sh
> > @@ -118,8 +118,9 @@ tst_brk()
> >
> >  ROD_SILENT()
> >  {
> > -     tst_rod $@ > /dev/null 2>&1
> > +     local tst_out=$(tst_rod $@ 2>&1)
> >       if [ $? -ne 0 ]; then
> > +             echo "$tst_out"
> >               tst_brk TBROK "$@ failed"
> >       fi
> >  }
> > --
> > 2.13.6
>
> LGTM except that you could maybe use ${ } instead of $( ) as a small
> optimisation.
>

​For ​
what optimisation?

$(command) runs the command and captures its output in separate shell.
${parameter} the value of parameter is substituted.


​Here the purpose is to hide the output in sub shell I guess, shouldn't use
$()?


-- 
Li Wang
liwang@redhat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180222/36cdf716/attachment.html>

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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
  2018-02-21  9:12 ` Richard Palethorpe
  2018-02-22  4:05   ` Li Wang
@ 2018-03-13 12:46   ` Cyril Hrubis
  2018-03-13 13:01     ` Richard Palethorpe
  1 sibling, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2018-03-13 12:46 UTC (permalink / raw)
  To: ltp

Hi!
> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> > index d6b638549..48afb9cc4 100644
> > --- a/testcases/lib/tst_test.sh
> > +++ b/testcases/lib/tst_test.sh
> > @@ -118,8 +118,9 @@ tst_brk()
> >  
> >  ROD_SILENT()
> >  {
> > -	tst_rod $@ > /dev/null 2>&1
> > +	local tst_out=$(tst_rod $@ 2>&1)
> >  	if [ $? -ne 0 ]; then
> > +		echo "$tst_out"
> >  		tst_brk TBROK "$@ failed"
> >  	fi
> >  }
> > -- 
> > 2.13.6
> 
> LGTM except that you could maybe use ${ } instead of $( ) as a small
> optimisation.

I do not get it either. Where should I put the ${} insetad of $()?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
  2018-03-13 12:46   ` Cyril Hrubis
@ 2018-03-13 13:01     ` Richard Palethorpe
  2018-03-13 13:30       ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Palethorpe @ 2018-03-13 13:01 UTC (permalink / raw)
  To: ltp

Hello,

Cyril Hrubis writes:

> Hi!
>> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
>> > index d6b638549..48afb9cc4 100644
>> > --- a/testcases/lib/tst_test.sh
>> > +++ b/testcases/lib/tst_test.sh
>> > @@ -118,8 +118,9 @@ tst_brk()
>> >
>> >  ROD_SILENT()
>> >  {
>> > -	tst_rod $@ > /dev/null 2>&1
>> > +	local tst_out=$(tst_rod $@ 2>&1)
>> >  	if [ $? -ne 0 ]; then
>> > +		echo "$tst_out"
>> >  		tst_brk TBROK "$@ failed"
>> >  	fi
>> >  }
>> > --
>> > 2.13.6
>>
>> LGTM except that you could maybe use ${ } instead of $( ) as a small
>> optimisation.
>
> I do not get it either. Where should I put the ${} insetad of $()?

Sorry I was probably wrong, unless you can somehow change from variable
substitution to redirecting from a group (that is {} > $var not
var=${}).

--
Thank you,
Richard.

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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
  2018-03-13 13:01     ` Richard Palethorpe
@ 2018-03-13 13:30       ` Cyril Hrubis
  2018-03-13 15:16         ` Richard Palethorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2018-03-13 13:30 UTC (permalink / raw)
  To: ltp

Hi!
> >> LGTM except that you could maybe use ${ } instead of $( ) as a small
> >> optimisation.
> >
> > I do not get it either. Where should I put the ${} insetad of $()?
> 
> Sorry I was probably wrong, unless you can somehow change from variable
> substitution to redirecting from a group (that is {} > $var not
> var=${}).

So can I consider the original patch acked?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
  2018-03-13 13:30       ` Cyril Hrubis
@ 2018-03-13 15:16         ` Richard Palethorpe
  2018-03-14 13:58           ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Palethorpe @ 2018-03-13 15:16 UTC (permalink / raw)
  To: ltp

Cyril Hrubis writes:

> Hi!
>> >> LGTM except that you could maybe use ${ } instead of $( ) as a small
>> >> optimisation.
>> >
>> > I do not get it either. Where should I put the ${} insetad of $()?
>> 
>> Sorry I was probably wrong, unless you can somehow change from variable
>> substitution to redirecting from a group (that is {} > $var not
>> var=${}).
>
> So can I consider the original patch acked?

Yes.

-- 
Thank you,
Richard.

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

* [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
  2018-03-13 15:16         ` Richard Palethorpe
@ 2018-03-14 13:58           ` Cyril Hrubis
  0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2018-03-14 13:58 UTC (permalink / raw)
  To: ltp

Hi!
> Yes.

Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2018-03-14 13:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-12 15:03 [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure Cyril Hrubis
2018-02-21  9:12 ` Richard Palethorpe
2018-02-22  4:05   ` Li Wang
2018-03-13 12:46   ` Cyril Hrubis
2018-03-13 13:01     ` Richard Palethorpe
2018-03-13 13:30       ` Cyril Hrubis
2018-03-13 15:16         ` Richard Palethorpe
2018-03-14 13:58           ` Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2018-02-12 14:40 Cyril Hrubis

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