Skip to contentSkip to conversation

Convert network stress tests to tst_net.sh

PATCH New Joerg Vehlow 2 participants 6 messages Nov 16, 2020

lore
Share & tools
lore
#0 lore raw

cover Convert network stress tests to tst_net.sh

Hi,

this patch series converts (all?) remeianing tests in network/stress to use tst_net.sh

J?rg

 .../stress/multicast/packet-flood/mcast4-pktfld01  | 114 +++----------
 .../stress/multicast/packet-flood/mcast4-pktfld02  | 116 +++----------
 .../stress/multicast/packet-flood/mcast6-pktfld01  | 112 +++----------
 .../stress/multicast/packet-flood/mcast6-pktfld02  | 114 +++----------
 .../stress/multicast/query-flood/mcast4-queryfld01 | 153 +++++------------
 .../stress/multicast/query-flood/mcast4-queryfld02 | 145 ++++-------------
 .../stress/multicast/query-flood/mcast4-queryfld03 | 142 ++++------------
 .../stress/multicast/query-flood/mcast4-queryfld04 | 148 ++++-------------
 .../stress/multicast/query-flood/mcast4-queryfld05 | 181 +++++++--------------
 .../stress/multicast/query-flood/mcast4-queryfld06 | 166 ++++++-------------
 .../stress/multicast/query-flood/mcast6-queryfld01 | 144 ++++------------
 .../stress/multicast/query-flood/mcast6-queryfld02 | 140 ++++------------
 .../stress/multicast/query-flood/mcast6-queryfld03 | 144 +++++-----------
 .../stress/multicast/query-flood/mcast6-queryfld04 | 147 +++++------------
 .../stress/multicast/query-flood/mcast6-queryfld05 | 180 +++++++-------------
 .../stress/multicast/query-flood/mcast6-queryfld06 | 177 ++++++--------------
 testcases/network/stress/route/route4-redirect     | 155 +++++-------------
 testcases/network/stress/route/route6-redirect     | 143 ++++------------
 18 files changed, 662 insertions(+), 1959 deletions(-)
#1 lore raw

PATCH 1/3 network/stress/mutlicast/packet-flood: Update to tst_net.sh

From: Joerg Vehlow <[email protected]>

---
 .../multicast/packet-flood/mcast4-pktfld01    | 114 ++++-------------
 .../multicast/packet-flood/mcast4-pktfld02    | 116 ++++--------------
 .../multicast/packet-flood/mcast6-pktfld01    | 112 ++++-------------
 .../multicast/packet-flood/mcast6-pktfld02    | 114 ++++-------------
 4 files changed, 85 insertions(+), 371 deletions(-)
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +21 -93
index c1ee513d4..20284569d 100644
@@ -42,41 +42,20 @@
 #trace_logic=${trace_logic:-"set -x"}
 $trace_logic
 
-# The test case ID, the test case count and the total number of test case
-TCID=mcast4-pktfld01
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Dulation of the test [sec]
-NS_DURATION=${NS_DURATION:-3600}      # 1 hour
+TST_TESTFUNC=test_body
+TST_NEEDS_ROOT=1
+TST_SETUP=do_setup
+TST_CLEANUP=do_cleanup
 
 # The number of the test link where tests run
 LINK_NUM=${LINK_NUM:-0}
 
-# Network portion of the IPv4 address
-NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of the IPv4 network
-NETWORK_MASK=24
-
-# Host portion of the IPv4 address
-LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
-RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
-
 # Multicast Address
 MCAST_ADDR=224.10.0.1
 
 
+. tst_net.sh
+
 #-----------------------------------------------------------------------
 #
 # Function: do_cleanup
@@ -89,11 +68,7 @@ do_cleanup()
 {
     # Make sure to kill the multicast receiver and sender
     killall -SIGHUP ns-mcast_receiver >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+	tst_rhost_run -c "killall -SIGHUP ns-udpsender >/dev/null 2>&1"
 }
 
 
@@ -107,57 +82,15 @@ do_cleanup()
 #-----------------------------------------------------------------------
 do_setup()
 {
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
+	local lhost_ifname=$(tst_iface lhost ${LINK_NUM})
 
     # Unset the maximum number of processes
     ulimit -u unlimited
 
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv4_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-
     # Make sure the sysctl values
     sysctl -w net.ipv4.igmp_max_memberships=20 >/dev/null
     if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
+		tst_brk TBROK "Failed to set the sysctl value regarding multicast"
     fi
 
     sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
@@ -173,35 +106,30 @@ do_setup()
 #
 
 # Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining a IPv4 multicast group a single socket, then receiving a large number of UDP packets at the socket in $NS_DURATION [sec]"
 
-do_setup
+test_body()
+{
+	local lhost_ifname=$(tst_iface lhost ${LINK_NUM})
+	local rhost_ifname=$(tst_iface rhost ${LINK_NUM})
+
+	tst_res TINFO "Verify that the kernel is not crashed when joining a IPv4 multicast group a single socket, then receiving a large number of UDP packets at the socket in $NS_DURATION [sec]"
 
 # Find the available consecutive ports
 mcast_port=`find_portbundle udp 1025 1`
 if [ $? -ne 0 ]; then
-    tst_resm TBROK "No port is available."
-    exit 1
+		tst_brk TBROK "No port is available."
 fi
 
 # Run a receiver
 ns-mcast_receiver -f 4 -I $lhost_ifname -m $MCAST_ADDR -p $mcast_port -b
 if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to start multicast receiver"
-    exit 1
+		tst_brk TBROK "Failed to start multicast receiver"
 fi
 
 # Run a sender
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-udpsender -D $MCAST_ADDR -f 4 -p $mcast_port -s 32767 -m -I $rhost_ifname -t $NS_DURATION' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start multicast sender"
-    exit 1
-fi
+	tst_rhost_run -s -c "ns-udpsender -D $MCAST_ADDR -f 4 -p $mcast_port -s 32767 -m -I $rhost_ifname -t $NS_DURATION"
 
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
+	tst_res TPASS "Test is finished successfully."
+}
 
-tst_resm TPASS "Test is finished successfully."
-exit 0
+tst_run
testcases/network/stress/multicast/packet-flood/mcast4-pktfld02 +21 -95

178 lines not on this page · raw message

testcases/network/stress/multicast/packet-flood/mcast6-pktfld01 +21 -91

162 lines not on this page · raw message

testcases/network/stress/multicast/packet-flood/mcast6-pktfld02 +22 -92

176 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 1/3 network/stress/mutlicast/packet-flood: Update to tst_net.sh

Hi Joerg,

Quoted 8 lines

From: Joerg Vehlow <[email protected]>

---
 .../multicast/packet-flood/mcast4-pktfld01    | 114 ++++-------------
 .../multicast/packet-flood/mcast4-pktfld02    | 116 ++++--------------
 .../multicast/packet-flood/mcast6-pktfld01    | 112 ++++-------------
 .../multicast/packet-flood/mcast6-pktfld02    | 114 ++++-------------

Thanks a lot!
Could you please merge files into single one:
mcast{4,6}-pktfld01 => mcast-pktfld01
mcast{4,6}-pktfld02 => mcast-pktfld02

as done previously in other multicast and route tests?

Could you also add ".sh" extension to the files? (it's then obvious it's shell, not a compiled binary).

NOTE: $TST_IPVER is often used.

Also, please remove all bogus comments like GPL verbose text (replaced by SPDX) and also bogus comments like:
# Test description

The comment at the top should be small, e.g.:
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) International Business Machines Corp., 2006

# your copyright
# Author: Mitsuru Chinen <[email protected]>
# joining a IPv4/IPv6 multicast group on a single socket, then receiving a large
# number of UDP packets at the socket

You also mix tabs and spaces. We usually prefer tabs, but please reformat whole file.

testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 line 43

Quoted 9 lines
 4 files changed, 85 insertions(+), 371 deletions(-)
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +0 -0
index c1ee513d4..20284569d 100644
@@ -42,41 +42,20 @@
 #trace_logic=${trace_logic:-"set -x"}
 $trace_logic

Please remove this.

Quoted 14 lines
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +0 -14
-# The test case ID, the test case count and the total number of test case
-TCID=mcast4-pktfld01
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL

testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 line 51

Quoted 10 lines
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +4 -3
-
-# Dulation of the test [sec]
-NS_DURATION=${NS_DURATION:-3600}      # 1 hour
+TST_TESTFUNC=test_body
+TST_NEEDS_ROOT=1
+TST_SETUP=do_setup
+TST_CLEANUP=do_cleanup
 
 # The number of the test link where tests run
 LINK_NUM=${LINK_NUM:-0}

LINK_NUM is not needed

testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 line 54

Quoted 12 lines
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +0 -10
-# Network portion of the IPv4 address
-NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of the IPv4 network
-NETWORK_MASK=24
-
-# Host portion of the IPv4 address
-LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
-RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
-
 # Multicast Address
 MCAST_ADDR=224.10.0.1

MCAST_ADDR is replaced by MCAST_IPV{4,6}_ADDR in tst_net_stress.sh (which is used by mcast-lib.sh, see below).

testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 line 53

Quoted 1 line
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +1 -0
+. tst_net.sh

NOTE:
other multicast tests use testcases/network/stress/multicast/grp-operation/mcast-lib.sh, which also uses testcases/network/stress/ns-tools/tst_net_stress.sh. I wrote them some time ago (today I'd do things differently), they deserve cleanup (so does also my rewrite of multicast stress tests). Even they're not perfect, it'd be probably better to use it to avoid redundancy.

testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 do_cleanup() · line 72

Quoted 12 lines
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +1 -5
 # Function: do_cleanup
@@ -89,11 +68,7 @@ do_cleanup()
 {
     # Make sure to kill the multicast receiver and sender
     killall -SIGHUP ns-mcast_receiver >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+	tst_rhost_run -c "killall -SIGHUP ns-udpsender >/dev/null 2>&1"
 }

Also cleanup is handled safer (if I remember correctly using killall -SIGHUP in original do_cleanup() does not work).

testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 do_cleanup() · line 85

Quoted 10 lines
testcases/network/stress/multicast/packet-flood/mcast4-pktfld01 +1 -5
@@ -107,57 +82,15 @@ do_cleanup()
 #-----------------------------------------------------------------------
 do_setup()
 {
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
+	local lhost_ifname=$(tst_iface lhost ${LINK_NUM})

Also {l,r}host_ifname is not needed. You use $(tst_iface rhost) for -I parameter, see mcast_setup() in mcast-lib.sh.

Kind regards,
Petr

#3 lore raw

PATCH 2/3 network/stress/multicast/query-flood: Convert to tst_net.sh

In reply to Joerg Vehlow

From: Joerg Vehlow <[email protected]>

---
 .../multicast/query-flood/mcast4-queryfld01   | 153 ++++-----------
 .../multicast/query-flood/mcast4-queryfld02   | 145 ++++----------
 .../multicast/query-flood/mcast4-queryfld03   | 142 ++++----------
 .../multicast/query-flood/mcast4-queryfld04   | 148 ++++----------
 .../multicast/query-flood/mcast4-queryfld05   | 181 ++++++------------
 .../multicast/query-flood/mcast4-queryfld06   | 166 +++++-----------
 .../multicast/query-flood/mcast6-queryfld01   | 144 ++++----------
 .../multicast/query-flood/mcast6-queryfld02   | 140 ++++----------
 .../multicast/query-flood/mcast6-queryfld03   | 144 ++++----------
 .../multicast/query-flood/mcast6-queryfld04   | 147 ++++----------
 .../multicast/query-flood/mcast6-queryfld05   | 180 ++++++-----------
 .../multicast/query-flood/mcast6-queryfld06   | 177 ++++++-----------
 12 files changed, 503 insertions(+), 1364 deletions(-)
testcases/network/stress/multicast/query-flood/mcast4-queryfld01 +39 -114
index 992cf423e..a659db387 100644
@@ -42,40 +42,18 @@
 #trace_logic=${trace_logic:-"set -x"}
 $trace_logic
 
-# The test case ID, the test case count and the total number of test case
-TCID=mcast4-queryfld01
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Dulation of the test [sec]
-NS_DURATION=${NS_DURATION:-3600}	# 1 hour
+TST_TESTFUNC=test_body
+TST_NEEDS_ROOT=1
+TST_SETUP=do_setup
+TST_CLEANUP=do_cleanup
 
 # The number of the test link where tests run
 LINK_NUM=${LINK_NUM:-0}
 
-# Network portion of the IPv4 address
-NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of the IPv4 network
-NETWORK_MASK=24
-
-# Host portion of the IPv4 address
-LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
-RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
-
 # Prefix of the Multicast Address
 MCAST_ADDR_PREFIX=224.10
 
+. tst_net.sh
 
 #-----------------------------------------------------------------------
 #
@@ -87,13 +65,9 @@ MCAST_ADDR_PREFIX=224.10
 #-----------------------------------------------------------------------
 do_cleanup()
 {
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+	# Make sure to kill the multicast receiver and sender
+	killall -SIGHUP ns-mcast_join >/dev/null 2>&1
+	tst_rhost_run -c "killall -SIGHUP ns-igmp_querier >/dev/null 2>&1"
 }
 
 
@@ -107,59 +81,17 @@ do_cleanup()
 #-----------------------------------------------------------------------
 do_setup()
 {
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv4_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv4.igmp_max_memberships=20 >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
-    sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
-    sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
+	local lhost_ifname=$(tst_iface lhost ${LINK_NUM})
+
+	# Make sure the sysctl values
+	sysctl -w net.ipv4.igmp_max_memberships=20 >/dev/null
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "Failed to set the sysctl value regarding multicast"
+	fi
+
+	sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
+	sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
+	sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
 }
 
 
@@ -169,31 +101,24 @@ do_setup()
 #
 #
 
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining an IPv4 multicast group on a single socket, then receiving a large number of General Query in $NS_DURATION [sec]"
-
-do_setup
-
-# Run a multicast join tool
-ns-mcast_join -f 4 -I $lhost_ifname -n 1 -p $MCAST_ADDR_PREFIX >/dev/null
-if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-    exit 1
-fi
-
-# Send IGMP General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -t $NS_DURATION -r 0' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start IGMP querier"
-    exit 1
-fi
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-tst_resm TPASS "Test is finished successfully."
+test_body()
+{
+	local lhost_ifname=$(tst_iface lhost ${LINK_NUM})
+	local rhost_ifname=$(tst_iface rhost ${LINK_NUM})
+
+	# Test description
+	tst_res TINFO "Verify that the kernel is not crashed when joining an IPv4 multicast group on a single socket, then receiving a large number of General Query in $NS_DURATION [sec]"
+
+	# Run a multicast join tool
+	ns-mcast_join -f 4 -I $lhost_ifname -n 1 -p $MCAST_ADDR_PREFIX >/dev/null
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "Failed to start multicast joining tool Please check the environment"
+	fi
+
+	# Send IGMP General Query from the remote host
+	tst_rhost_run -s -c "ns-igmp_querier -I $rhost_ifname -t $NS_DURATION -r 0"
+	
+	tst_res TPASS "Test is finished successfully."
+}
 
-exit 0
+tst_run
testcases/network/stress/multicast/query-flood/mcast4-queryfld02 +36 -109

182 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast4-queryfld03 +34 -108

180 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast4-queryfld04 +35 -113

181 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast4-queryfld05 +56 -125

212 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast4-queryfld06 +48 -118

207 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast6-queryfld01 +36 -108

177 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast6-queryfld02 +35 -105

178 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast6-queryfld03 +37 -107

180 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast6-queryfld04 +37 -110

183 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast6-queryfld05 +56 -124

209 lines not on this page · raw message

testcases/network/stress/multicast/query-flood/mcast6-queryfld06 +54 -123

211 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

PATCH 3/3 network/stress/route: Convert to tst_net.sh

In reply to Joerg Vehlow

From: Joerg Vehlow <[email protected]>

---
 .../network/stress/route/route4-redirect      | 155 +++++-------------
 .../network/stress/route/route6-redirect      | 143 ++++------------
 2 files changed, 74 insertions(+), 224 deletions(-)
testcases/network/stress/route/route4-redirect +39 -116
index 53df9abf2..8c0b09347 100644
@@ -42,26 +42,10 @@
 #trace_logic=${trace_logic:-"set -x"}
 $trace_logic
 
-# The test case ID, the test case count and the total number of test case
-TCID=route4-redirect01
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Test description
-tst_resm TINFO "Verify the kernel is not crashed when the IPv4 route is modified by  ICMP Redirects frequently"
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# The number of times where route is changed
-NS_TIMES=${NS_TIMES:-10000}
+TST_TESTFUNC=test_body
+TST_NEEDS_ROOT=1
+TST_SETUP=do_setup
+TST_CLEANUP=do_cleanup
 
 # The number of the test link where tests run
 LINK_NUM=${LINK_NUM:-0}
@@ -69,14 +53,7 @@ LINK_NUM=${LINK_NUM:-0}
 # Network portion of the IPv4 address
 IPV4_NETWORK=${IPV4_NETWORK:-"10.0.0"}
 
-# Netmask of for the tested network
-IPV4_NETMASK_NUM=24
-
-# Broadcast address of the tested network
-IPV4_BROADCAST=${IPV4_NETWORK}.255
-
 # Host portion of the IPv4 address
-LHOST_IPV4_HOST=${LHOST_IPV4_HOST:-"1"}	# src
 RHOST_IPV4_HOST="2"	# gateway
 
 # The destination network
@@ -84,24 +61,12 @@ DST_NETWORK="10.10.0"   # destination network would be 10.10.0.0/24
 DST_HOST="5"
 DST_PORT="7"
 
+. tst_net.sh
 
-#-----------------------------------------------------------------------
-#
-# NAME:
-#   do_cleanup
-#
-# DESCRIPTION:
-#   Recover the tested interfaces
-#
-#-----------------------------------------------------------------------
 do_cleanup()
 {
-    # Kill the redirector utility
-    $LTP_RSH $RHOST killall -SIGHUP ns-icmp_redirector >/dev/null 2>&1
-
-    # Initialize the interfaces
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+	# Kill the redirector utility
+	tst_rhost_run -c "killall -SIGHUP ns-icmp_redirector >/dev/null 2>&1"
 }
 
 
@@ -113,55 +78,25 @@ do_cleanup()
 # DESCRIPTION:
 #   Set the initial route and start icmp redirect on the remote host
 #
-# SET VALUES:
-#   rhost_ipv4addr      - IPv4 Address of the remote host
-#   lhost_ifname        - Interface name of the local host
-#   rhost_ifname        - Interface name of the remote host
-#
 #-----------------------------------------------------------------------
 do_setup()
 {
-    # Make sure to clean up
-    do_cleanup
-
-    # Get the Interface name of local host
-    lhost_ifname=`get_ifname lhost ${LINK_NUM}`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    # Get the Interface name of remote host
-    rhost_ifname=`get_ifname rhost ${LINK_NUM}`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Remove the link-local address of the remote host
-    sleep 3
-    $LTP_RSH $RHOST "ip addr flush dev $rhost_ifname" > /dev/null
-
-    # Assign IPv4 address to the interface of the local host
-    set_ipv4addr lhost ${LINK_NUM} ${IPV4_NETWORK} ${LHOST_IPV4_HOST}
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to assign an IPv4 address at the local host"
-	return 1
-    fi
-
-    # Add route to the initial gateway
-    route add -net ${DST_NETWORK}.0 netmask 255.255.255.0 gw ${IPV4_NETWORK}.${RHOST_IPV4_HOST} dev $lhost_ifname
-
-    # Make sure the sysctl value is set for accepting the redirect
-    sysctl -w net.ipv4.conf.${lhost_ifname}.accept_redirects=1 >/dev/null
-    sysctl -w net.ipv4.conf.${lhost_ifname}.secure_redirects=0 >/dev/null
-
-    # Run the redirector utility at the remote host
-    ret=`$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-icmp_redirector -I $rhost_ifname -b ; "'echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TBROK "Failed to run icmp redirector at the remote host"
-	exit $TST_TOTAL
-    fi
+	local lhost_ifname=$(tst_iface lhost ${LINK_NUM})
+	local rhost_ifname=$(tst_iface rhost ${LINK_NUM})
+
+	# Remove the link-local address of the remote host
+	sleep 3
+	tst_rhost_run -s -c "ip addr flush dev $rhost_ifname"
+
+	# Add route to the initial gateway
+	route add -net ${DST_NETWORK}.0 netmask 255.255.255.0 gw ${IPV4_NETWORK}.${RHOST_IPV4_HOST} dev $lhost_ifname
+
+	# Make sure the sysctl value is set for accepting the redirect
+	sysctl -w net.ipv4.conf.${lhost_ifname}.accept_redirects=1 >/dev/null
+	sysctl -w net.ipv4.conf.${lhost_ifname}.secure_redirects=0 >/dev/null
+
+	# Run the redirector utility at the remote host
+	tst_rhost_run -s -c "ns-icmp_redirector -I $rhost_ifname -b"
 }
 
 
@@ -180,33 +115,21 @@ do_setup()
 #-----------------------------------------------------------------------
 test_body()
 {
-    # Loop for changing the route
-    cnt=0
-    while [ $cnt -lt $NS_TIMES ]; do
-	ns-udpsender -f 4 -D ${DST_NETWORK}.${DST_HOST} -p $DST_PORT -o -s 8
-	if [ $? -ne 0 ]; then
-	    tst_resm TBROK "Failed to run udp packet sender"
-	    return 1
-	fi
-	cnt=`expr $cnt + 1`
-    done
-
-    tst_resm TPASS "Test is finished correctly."
-    return 0
+	# Test description
+	tst_resm TINFO "Verify the kernel is not crashed when the IPv4 route is modified by  ICMP Redirects frequently"
+	# Loop for changing the route
+	cnt=0
+	while [ $cnt -lt $NS_TIMES ]; do
+		ns-udpsender -f 4 -D ${DST_NETWORK}.${DST_HOST} -p $DST_PORT -o -s 8
+		if [ $? -ne 0 ]; then
+			tst_res TBROK "Failed to run udp packet sender"
+			return 1
+		fi
+		cnt=`expr $cnt + 1`
+	done
+
+	tst_res TPASS "Test is finished correctly."
+	return 0
 }
 
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-# Exit Value:
-#   The number of the failure
-#
-#-----------------------------------------------------------------------
-RC=0
-do_setup
-test_body || RC=`expr $RC + 1`
-do_cleanup
-
-exit $RC
+tst_run
testcases/network/stress/route/route6-redirect +35 -108

172 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

cover Convert network stress tests to tst_net.sh

In reply to Joerg Vehlow

Hi Joerg,

Quoted 4 lines

Hi,

this patch series converts (all?) remeianing tests in network/stress to use tst_net.sh

Please see my comments in first patch, they apply to second one and mostly to third one as well (it should use route-lib.sh).

Ad all: I've never reposted fixed version for route{4,6}-rmmod [1] (needs a cleanup) I'll do it soon.

Kind regards,
Petr

[1] http://lists.linux.it/pipermail/ltp/2017-July/005079.html