Skip to contentSkip to conversation

tst_test.sh: Print tst_{res, brk} into stdout

RFC PATCH New Petr Vorel 4 participants 5 messages Jun 19, 2020 – Jun 22, 2020

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

RFC PATCH 1/1 tst_test.sh: Print tst_{res, brk} into stdout

This allows printing messages on functions which output is redirected into variable or used in eval. Also this change unifies the behavior with C new API, which printed into stderr from the beginning.

Hope this change does not bring any regression.

Legacy API kept printing into stdout (legacy C API also prints to stdout).

---
Hi,

some examples:

Before:
/opt/ltp/testcases/bin/tst_net.sh: line 885: 33mTCONF:: command not found
/opt/ltp/testcases/bin/tst_net.sh: eval: line 888: syntax error near unexpected token `('
/opt/ltp/testcases/bin/tst_net.sh: eval: line 888: `tst_rhost_run 1 TCONF: 'rsh' not found tst_rhost_run 1 TINFO: AppArmor enabled, this may affect test results tst_rhost_run 1 TINFO: it can be disabled with TST_DISABLE_APPARMOR=1 (requires super/root) tst_rhost_run 1 TINFO: loaded AppArmor profiles: none Summary: passed 0 failed 0 skipped 1 warnings 1'

With this patch:
tst_rhost_run 1 TCONF: 'rsh' not found /opt/ltp/testcases/bin/tst_net.sh: line 885: Summary:: command not found tst_rhost_run 1 TCONF: 'rsh' not found /opt/ltp/testcases/bin/tst_net.sh: line 888: Summary:: command not found tst_rhost_run 1 TINFO: Network config (local -- remote):
tst_rhost_run 1 TINFO: ltp_ns_veth2 --
tst_rhost_run 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24 tst_rhost_run 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64 tst_rhost_run 1 TCONF: 'rsh' not found
tst_rhost_run 1 TINFO: timeout per run is 0h 5m 0s tst_rhost_run 1 TCONF: 'rsh' not found

Kind regards,
Petr

 testcases/lib/tst_test.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/lib/tst_test.sh +4 -4
index 1cf724cbe..2e637b25b 100644
@@ -1,6 +1,6 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) Linux Test Project, 2014-2019
+# Copyright (c) Linux Test Project, 2014-2020
 # Author: Cyril Hrubis <[email protected]>
 #
 # LTP test library for shell.
@@ -102,9 +102,9 @@ tst_res()
 
 	_tst_inc_res "$res"
 
-	printf "$TST_ID $TST_COUNT "
-	tst_print_colored $res "$res: "
-	echo "$@"
+	printf "$TST_ID $TST_COUNT " >&2
+	tst_print_colored $res "$res: " >&2
+	echo "$@" >&2
 }
 
 tst_brk()
Signature · 1 line
2.27.0
#1 lore raw

RFC PATCH 1/1 tst_test.sh: Print tst_{res, brk} into stdout

----- Original Message -----

Quoted 3 lines

This allows printing messages on functions which output is redirected into variable or used in eval. Also this change unifies the behavior with C new API, which printed into stderr from the beginning.

Should the subject say "into stderr"? Other than that I'm OK with the change.

#2 lore raw

RFC PATCH 1/1 tst_test.sh: Print tst_{res, brk} into stdout

Hi Jan,

Quoted 6 lines

----- Original Message -----

Quoted 3 lines

This allows printing messages on functions which output is redirected into variable or used in eval. Also this change unifies the behavior with C new API, which printed into stderr from the beginning.

Should the subject say "into stderr"?

Yes. Thanks for pointing out silly error.

Quoted 1 line

Other than that I'm OK with the change.

Thanks a lot for your review!

Kind regards,
Petr

#3 lore raw

RFC PATCH 1/1 tst_test.sh: Print tst_{res, brk} into stdout

In reply to Petr Vorel

Hi!

Quoted 3 lines

This allows printing messages on functions which output is redirected into variable or used in eval. Also this change unifies the behavior with C new API, which printed into stderr from the beginning.

The patch looks fine but the first line and the email subject should say stderr, right?

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#4 lore raw

RFC PATCH 1/1 tst_test.sh: Print tst_{res, brk} into stdout

Hi Cyril, Jan,

Quoted 7 lines

Hi!

Quoted 3 lines

This allows printing messages on functions which output is redirected into variable or used in eval. Also this change unifies the behavior with C new API, which printed into stderr from the beginning.

The patch looks fine but the first line and the email subject should say stderr, right?

Thanks, merged with fixed subject (Jan already reported it).

Kind regards,
Petr