Skip to contentSkip to conversation

tst_net.sh: Allow to skip initialization

PATCH New Petr Vorel 2 participants 4 messages Jun 3, 2021 – Jun 7, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/2 tst_net.sh: Allow to skip initialization

with TST_NET_SKIP_VARIABLE_INIT=1.
Useful for testing the library itself.

---
 testcases/lib/tst_net.sh  | 2 ++
 testcases/lib/tst_test.sh | 1 +
 2 files changed, 3 insertions(+)
testcases/lib/tst_net.sh +2 -0
index fc5719057..db1db4790 100644
@@ -933,6 +933,8 @@ tst_default_max_pkt()
 	echo "$((mtu + mtu / 10))"
 }
 
+[ -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
+
 # Management Link
 [ -z "$RHOST" ] && TST_USE_NETNS="yes"
 export RHOST="$RHOST"
testcases/lib/tst_test.sh +1 -0
index 66ffde4eb..8b4e9cb60 100644
@@ -559,6 +559,7 @@ tst_run()
 			IPV6|IPV6_FLAG|IPVER|TEST_DATA|TEST_DATA_IFS);;
 			RETRY_FUNC|RETRY_FN_EXP_BACKOFF|TIMEOUT);;
 			NET_DATAROOT|NET_MAX_PKT|NET_RHOST_RUN_DEBUG|NETLOAD_CLN_NUMBER);;
+			NET_SKIP_VARIABLE_INIT);;
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 2/2 tst_ipaddr_un.sh: Properly disable netns initialization

It stopped working due 40110018e, but even before there were issues:

tst_ipaddr_un 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24 tst_ipaddr_un 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
cat: /sys/class/net/eth0/mtu: No such file or directory
cat: /sys/class/net/eth0/address: No such file or directory

Fixes 807d60628 ("net: Add tst_ipaddr_un.sh test")
---
 lib/newlib_tests/shell/net/tst_ipaddr_un.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/newlib_tests/shell/net/tst_ipaddr_un.sh +5 -2
index 512d6d880..e7730b8d0 100755
@@ -7,8 +7,11 @@ TST_CNT=2
 
 PATH="$(dirname $0)/../../../../testcases/lib/:$PATH"
 
-# workaround to disable netns initialization
-RHOST="foo"
+TST_NET_SKIP_VARIABLE_INIT=1
+
+# from tst_net_vars.c
+IPV4_NET16_UNUSED="10.23"
+IPV6_NET32_UNUSED="fd00:23"
 
 . tst_net.sh
 
Signature · 1 line
2.31.1
#2 lore raw

PATCH 2/2 tst_ipaddr_un.sh: Properly disable netns initialization

Hi Petr,

Quoted 19 lines · Petr Vorel

It stopped working due 40110018e, but even before there were issues:

tst_ipaddr_un 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24 tst_ipaddr_un 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
cat: /sys/class/net/eth0/mtu: No such file or directory
cat: /sys/class/net/eth0/address: No such file or directory

Fixes 807d60628 ("net: Add tst_ipaddr_un.sh test")
---
 lib/newlib_tests/shell/net/tst_ipaddr_un.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/newlib_tests/shell/net/tst_ipaddr_un.sh +0 -0
index 512d6d880..e7730b8d0 100755

lib/newlib_tests/shell/net/tst_ipaddr_un.sh TST_CNT=2 · line 11

Quoted 5 lines
lib/newlib_tests/shell/net/tst_ipaddr_un.sh +0 -2
@@ -7,8 +7,11 @@ TST_CNT=2
 
 PATH="$(dirname $0)/../../../../testcases/lib/:$PATH"
 
-# workaround to disable netns initialization
-RHOST="foo"

Could be TST_INIT_NETNS="no"

lib/newlib_tests/shell/net/tst_ipaddr_un.sh TST_CNT=2 · line 11

Quoted 2 lines
lib/newlib_tests/shell/net/tst_ipaddr_un.sh +2 -0
+TST_NET_SKIP_VARIABLE_INIT=1
+

OK, I think it's better than setting TST_INIT_NETNS and other vars (e.g. private _tst_net_parse_variables) here to actually skip init.

lib/newlib_tests/shell/net/tst_ipaddr_un.sh TST_CNT=2 · line 17

Quoted 7 lines
lib/newlib_tests/shell/net/tst_ipaddr_un.sh +3 -0
+# from tst_net_vars.c
+IPV4_NET16_UNUSED="10.23"
+IPV6_NET32_UNUSED="fd00:23"
 
 . tst_net.sh
 
author
#3 lore raw

PATCH 2/2 tst_ipaddr_un.sh: Properly disable netns initialization

Hi Alexey,

Quoted 4 lines

lib/newlib_tests/shell/net/tst_ipaddr_un.sh TST_CNT=2 · line 11

Quoted 2 lines
lib/newlib_tests/shell/net/tst_ipaddr_un.sh +0 -2
-# workaround to disable netns initialization
-RHOST="foo"

Could be TST_INIT_NETNS="no"

Good point.

Quoted 5 lines

lib/newlib_tests/shell/net/tst_ipaddr_un.sh TST_CNT=2 · line 11

Quoted 2 lines
lib/newlib_tests/shell/net/tst_ipaddr_un.sh +2 -0
+TST_NET_SKIP_VARIABLE_INIT=1
+

OK, I think it's better than setting TST_INIT_NETNS and other vars (e.g. private _tst_net_parse_variables) here to actually skip init.

+1. Patchset merged with your Reviewed-by: tag. Thanks!

Kind regards,
Petr