shell: ROD_SILENT: Print std{out, err} on failure
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure
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.
--- testcases/lib/test.sh | 3 ++- testcases/lib/tst_test.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
testcases/lib/test.sh +2 -1
@@ -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 }
testcases/lib/tst_test.sh +2 -1
@@ -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 }
Signature · 1 line
2.13.6
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure
Hello,
Quoted 46 lines · Cyril Hrubis
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 thetst_mkfsusesROD_SILENTto execute the mkfs command.The best solution for
ROD_SILENTis 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 <[email protected]>--- testcases/lib/test.sh | 3 ++- testcases/lib/tst_test.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)testcases/lib/test.sh +2
-1@@ -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 }testcases/lib/tst_test.sh +2
-1@@ -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 }Signature · 1 line
2.13.6
LGTM except that you could maybe use ${ } instead of $( ) as a small optimisation.
Signature · 2 lines
Thank you, Richard.
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure
Quoted 39 lines · Richard Palethorpe
Hello,
Quoted 35 lines · Cyril Hrubis
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 thetst_mkfsusesROD_SILENTto execute the mkfs command.The best solution for
ROD_SILENTis 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 <[email protected]>--- testcases/lib/test.sh | 3 ++- testcases/lib/tst_test.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)testcases/lib/test.sh +2
-1@@ -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 }testcases/lib/tst_test.sh +0
-0@@ -118,8 +118,9 @@ tst_brk()
Quoted 15 lines
Quoted 11 lines
testcases/lib/tst_test.sh +2
-2ROD_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 $()?
Signature · 5 lines
Li Wang [email protected] -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20180222/36cdf716/attachment.html>
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure
In reply to Richard PalethorpeHi!
Quoted 6 lines
Quoted 6 lines
testcases/lib/tst_test.sh +0
-0@@ -118,8 +118,9 @@ tst_brk()
Quoted 14 lines
Quoted 11 lines
testcases/lib/tst_test.sh +2
-1ROD_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 }Signature · 1 line
2.13.6LGTM 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 $()?
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure
Hello,
Quoted 22 lines · Cyril Hrubis
Hi!
Quoted 6 lines
Quoted 6 lines
testcases/lib/tst_test.sh +0
-0@@ -118,8 +118,9 @@ tst_brk()Quoted 14 lines
Quoted 11 lines
testcases/lib/tst_test.sh +2
-2ROD_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.
Quoted 1 line
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.
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure
Hi!
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
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?
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure
Quoted 11 lines · Cyril Hrubis
Hi!
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
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.
Signature · 2 lines
Thank you, Richard.
RFC PATCH 1/1 shell: ROD_SILENT: Print std{out, err} on failure