From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [RFC] [PATCH] shell: ROD_SILENT: Print std{out, err} on failure
Date: Wed, 21 Feb 2018 10:12:29 +0100 [thread overview]
Message-ID: <87efle670i.fsf@rpws.prws.suse.cz> (raw)
In-Reply-To: <20180212150302.23347-1-chrubis@suse.cz>
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.
next prev parent reply other threads:[~2018-02-21 9:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efle670i.fsf@rpws.prws.suse.cz \
--to=rpalethorpe@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox