Skip to contentSkip to conversation

net/ip_tests: Return TCONF if ip command can not create dummy interface

PATCH New Kory Maincent 2 participants 3 messages Nov 30, 2020 – Dec 1, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ip_tests: Return TCONF if ip command can not create dummy interface

Test if the dummy interface can be created, return TCONF if not. Move ip4_addr before, to have it defined and avoid cleanup error.

---
 testcases/network/iproute/ip_tests.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
testcases/network/iproute/ip_tests.sh +5 -2
index 41c515696..1f0c4634d 100755
@@ -23,11 +23,14 @@ init()
 	tst_res TINFO "inititalizing tests"
 
 	iface=ltp_dummy
+	ip4_addr=${IPV4_NET16_UNUSED}.6.6
 	lsmod | grep -q dummy || rm_dummy=1
 
-	ROD ip li add $iface type dummy
+	if ! ip li add $iface type dummy >/dev/null; then
+		rm_dummy=
+		tst_brk TCONF "Module 'dummy' not found"
+	fi
 
-	ip4_addr=${IPV4_NET16_UNUSED}.6.6
 	ROD ip a add ${ip4_addr}/24 dev $iface
 
 	cat > tst_ip02.exp <<-EOF
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 net/ip_tests: Return TCONF if ip command can not create dummy interface

Quoted 3 lines · Kory Maincent

Test if the dummy interface can be created, return TCONF if not. Move ip4_addr before, to have it defined and avoid cleanup error.

There is TST_NEEDS_DRIVERS for checking missing modules, so it should TCONF if some are not found.

TST_NEEDS_DRIVERS="dummy"

Quoted 27 lines
---
 testcases/network/iproute/ip_tests.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
testcases/network/iproute/ip_tests.sh +5 -2
index 41c515696..1f0c4634d 100755
@@ -23,11 +23,14 @@ init()
 	tst_res TINFO "inititalizing tests"
 
 	iface=ltp_dummy
+	ip4_addr=${IPV4_NET16_UNUSED}.6.6
 	lsmod | grep -q dummy || rm_dummy=1
 
-	ROD ip li add $iface type dummy
+	if ! ip li add $iface type dummy >/dev/null; then
+		rm_dummy=
+		tst_brk TCONF "Module 'dummy' not found"
+	fi
 
-	ip4_addr=${IPV4_NET16_UNUSED}.6.6
 	ROD ip a add ${ip4_addr}/24 dev $iface
 
 	cat > tst_ip02.exp <<-EOF
#2 lore raw

PATCH 1/1 net/ip_tests: Return TCONF if ip command can not create dummy interface

Hello Alexey,

Quoted 9 lines · On Tue, 1 Dec 2020 13:54:37 +0300 Alexey Kodanev <[email protected]>…
Quoted 3 lines · Kory Maincent

Test if the dummy interface can be created, return TCONF if not. Move ip4_addr before, to have it defined and avoid cleanup error.

There is TST_NEEDS_DRIVERS for checking missing modules, so it should TCONF if some are not found.

TST_NEEDS_DRIVERS="dummy"

Ah yes thanks.

Regards,

K?ry

Quoted 30 lines
Quoted 29 lines
---
 testcases/network/iproute/ip_tests.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/testcases/network/iproute/ip_tests.sh index 41c515696..1f0c4634d 100755

testcases/network/iproute/ip_tests.sh +5 -2
@@ -23,11 +23,14 @@ init()
 	tst_res TINFO "inititalizing tests"
 
 	iface=ltp_dummy
+	ip4_addr=${IPV4_NET16_UNUSED}.6.6
 	lsmod | grep -q dummy || rm_dummy=1
 
-	ROD ip li add $iface type dummy
+	if ! ip li add $iface type dummy >/dev/null; then
+		rm_dummy=
+		tst_brk TCONF "Module 'dummy' not found"
+	fi
 
-	ip4_addr=${IPV4_NET16_UNUSED}.6.6
 	ROD ip a add ${ip4_addr}/24 dev $iface
 
 	cat > tst_ip02.exp <<-EOF