[LTP] [PATCH 1/1] tst_net.sh: Ignore stderr on tst_rhost_run -c tst_net_iface_prefix
Petr Vorel
pvorel@suse.cz
Fri Jan 17 15:31:04 CET 2025
From: Petr Vorel <petr.vorel@gmail.com>
This is another way to harden against the problem, which was manifested by
893ca0abe7 and fixed by 02d5e99df3.
There were previously two problems:
1) Unneeded multiple slow kernel config detection (TINFO: CONFIG_LATENCYTOP ...).
2) Printing TINFO message to stderr from tst_net_iface_prefix which was
redirected by tst_rhost_run() to stdout and then used in "eval" in
tst_net_setup_network():
eval: tst_kconfig.c:88:: not found
[: tst_kconfig.c:88:: unexpected operator
# ping01.sh
ping01 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
/opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88:: unexpected operator
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
/opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88:: unexpected operator
ping01 1 TINFO: add remote addr 10.0.0.1/24
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
/opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88:: unexpected operator
ping01 1 TINFO: add remote addr fd00:1:1:1::1/64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:667: TINFO: CONFIG_LATENCYTOP kernel option detected which might slow the execution
/opt/ltp/testcases/bin/ping01.sh: 1: eval: tst_kconfig.c:88:: not found
/opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
/opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
/opt/ltp/testcases/bin/ping01.sh: 142: [: tst_kconfig.c:88:: unexpected operator
/opt/ltp/testcases/bin/ping01.sh: 1: eval: tst_kconfig.c:88:: not found
/opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
/opt/ltp/testcases/bin/ping01.sh: 1: eval: 34mTINFO:: not found
ping01 1 TINFO: Network config (local -- remote):
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi all,
It'd be nice to have it in the release, but we can solve it
next week (network tests works) or even after the release.
Kind regards,
Petr
testcases/lib/tst_net.sh | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index ee0ae1cad7..9c7b2bac1f 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -209,6 +209,7 @@ tst_net_use_netns()
# Options:
# -b run in background
# -c CMD specify command to run (this must be binary, not shell builtin/function)
+# -Q ignore stderr
# -s safe option, if something goes wrong, will exit with TBROK
# -u USER for ssh (default root)
# RETURN: 0 on success, 1 on failure
@@ -218,16 +219,18 @@ tst_rhost_run()
local post_cmd=' || echo RTERR'
local user="root"
local ret=0
+ local stderr='2>&1'
local cmd out output pre_cmd rcmd sh_cmd safe use
local OPTIND
- while getopts :bc:su: opt; do
+ while getopts :bc:Qsu: opt; do
case "$opt" in
b) [ "${TST_USE_NETNS:-}" ] && pre_cmd= || pre_cmd="nohup"
- post_cmd=" > /dev/null 2>&1 &"
+ post_cmd=" > /dev/null $stderr &"
out="1> /dev/null"
;;
c) cmd="$OPTARG" ;;
+ Q) stderr= ;;
s) safe=1 ;;
u) user="$OPTARG" ;;
*) tst_brk_ TBROK "tst_rhost_run: unknown option: $OPTARG" ;;
@@ -254,10 +257,10 @@ tst_rhost_run()
if [ "$TST_NET_RHOST_RUN_DEBUG" = 1 ]; then
tst_res_ TINFO "tst_rhost_run: cmd: $cmd"
- tst_res_ TINFO "$use: $rcmd \"$sh_cmd\" $out 2>&1"
+ tst_res_ TINFO "$use: $rcmd \"$sh_cmd\" $out $stderr"
fi
- output=$($rcmd "$sh_cmd" $out 2>&1 || echo 'RTERR')
+ output=$($rcmd "$sh_cmd" $out $stderr || echo 'RTERR')
echo "$output" | grep -q 'RTERR$' && ret=1
if [ $ret -eq 1 ]; then
@@ -1058,7 +1061,7 @@ tst_net_setup_network()
tst_net_use_netns && init_ltp_netspace
eval $(tst_net_iface_prefix $IPV4_LHOST || echo "exit $?")
- eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV4_RHOST \
+ eval $(tst_rhost_run -Q -c 'tst_net_iface_prefix -r '$IPV4_RHOST \
|| echo "exit $?")
eval $(tst_net_vars $IPV4_LHOST/$IPV4_LPREFIX \
$IPV4_RHOST/$IPV4_RPREFIX || echo "exit $?")
@@ -1066,7 +1069,7 @@ tst_net_setup_network()
if [ "$TST_NET_IPV6_ENABLED" = 1 ]; then
tst_net_check_ifaces_ipv6
eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?")
- eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \
+ eval $(tst_rhost_run -Q -c 'tst_net_iface_prefix -r '$IPV6_RHOST \
|| echo "exit $?")
eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \
$IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?")
--
2.47.1
More information about the ltp
mailing list