Rewritting network tests into new shell API
v2 cover Rewritting network tests into new shell API
Hi,
changes v1->v2:
* Make new API default for test_net.sh
* Rename variable TST_USE_NEW_API => TST_USE_LEGACY_API
* Set TST_USE_LEGACY_API=1 in majority of network scripts.
NOTE: still kept the old script names.
I'm not happy with the state of testscripts/network.sh. I kept it using the legacy API. I tried to migrate it into new API, but that would require too much changes (and I don't like to have tst_run call in testscripts/network.sh).
Kind regards,
Petr
Petr Vorel (3):
test_net.sh: Support both old and new shell APIs network/interface: Cleanup if4-addr-change
net: Migrate test_net_stress.sh and it's dependencies to new shell API
testcases/lib/test_net.sh | 133 +++++++++++++-------- testcases/lib/tst_test.sh | 1 + testcases/network/busy_poll/busy_poll01.sh | 1 + testcases/network/busy_poll/busy_poll02.sh | 1 + testcases/network/busy_poll/busy_poll03.sh | 1 + testcases/network/dccp/dccp01.sh | 1 + testcases/network/dctcp/dctcp01.sh | 1 + testcases/network/dhcp/dhcpd_tests.sh | 1 + testcases/network/dhcp/dnsmasq_tests.sh | 1 + testcases/network/iproute/ip_tests.sh | 1 + testcases/network/multicast/mc_cmds/mc_cmds | 1 + testcases/network/multicast/mc_commo/mc_commo | 1 + testcases/network/multicast/mc_member/mc_member | 1 + testcases/network/multicast/mc_opts/mc_opts | 1 + testcases/network/nfs/fsx-linux/fsx.sh | 1 + testcases/network/nfs/nfs_stress/nfs01 | 1 + testcases/network/nfs/nfs_stress/nfs02 | 1 + testcases/network/nfs/nfs_stress/nfs03 | 1 + testcases/network/nfs/nfs_stress/nfs04 | 1 + testcases/network/nfs/nfs_stress/nfs05 | 1 + testcases/network/nfs/nfs_stress/nfs06 | 1 + testcases/network/nfs/nfslock01/nfslock01 | 1 + testcases/network/nfs/nfsstat01/nfsstat01 | 1 + testcases/network/rpc/basic_tests/rpc01/rpc01 | 1 + .../network/rpc/basic_tests/rpcinfo/rpcinfo01 | 1 + testcases/network/rpc/basic_tests/rup/rup01 | 1 + testcases/network/rpc/basic_tests/rusers/rusers01 | 1 + testcases/network/rpc/rpc-tirpc/rpc_test.sh | 1 + testcases/network/sctp/sctp01.sh | 1 + testcases/network/sockets/bind_noport01.sh | 1 + .../network/stress/broken_ip/broken_ip4-checksum | 1 + .../network/stress/broken_ip/broken_ip4-dstaddr | 1 + .../network/stress/broken_ip/broken_ip4-fragment | 1 + testcases/network/stress/broken_ip/broken_ip4-ihl | 1 + .../network/stress/broken_ip/broken_ip4-protcol | 1 + .../network/stress/broken_ip/broken_ip4-totlen | 1 + .../network/stress/broken_ip/broken_ip4-version | 1 + .../network/stress/broken_ip/broken_ip6-dstaddr | 1 + .../network/stress/broken_ip/broken_ip6-nexthdr | 1 + testcases/network/stress/broken_ip/broken_ip6-plen | 1 + .../network/stress/broken_ip/broken_ip6-version | 1 + testcases/network/stress/dns/dns-stress | 1 + testcases/network/stress/ftp/ftp-download-stress | 1 + testcases/network/stress/ftp/ftp-upload-stress | 1 + testcases/network/stress/http/http-stress | 1 + testcases/network/stress/interface/if-addr-adddel | 31 ++--- .../network/stress/interface/if-addr-addlarge | 37 +++--- testcases/network/stress/interface/if-mtu-change | 24 ++-- testcases/network/stress/interface/if-route-adddel | 26 ++-- .../network/stress/interface/if-route-addlarge | 28 ++--- testcases/network/stress/interface/if-updown | 27 ++--- testcases/network/stress/interface/if4-addr-change | 74 +++++++----- testcases/network/stress/ipsec/ipsec_lib.sh | 1 + .../grp-operation/mcast-group-multiple-socket | 16 +-- .../multicast/grp-operation/mcast-group-same-group | 17 ++- .../grp-operation/mcast-group-single-socket | 17 ++- .../grp-operation/mcast-group-source-filter | 17 ++- .../stress/multicast/grp-operation/mcast-lib.sh | 15 +-- .../network/stress/ns-tools/test_net_stress.sh | 24 +++- testcases/network/stress/ssh/ssh-stress | 1 + testcases/network/tcp_cmds/arping/arping01.sh | 1 + .../network/tcp_cmds/clockdiff/clockdiff01.sh | 1 + testcases/network/tcp_cmds/ipneigh/ipneigh01.sh | 1 + testcases/network/tcp_cmds/ping/ping01.sh | 1 + testcases/network/tcp_cmds/ping/ping02.sh | 1 + testcases/network/tcp_cmds/rlogin/rlogin01 | 1 + testcases/network/tcp_cmds/sendfile/sendfile01 | 1 + testcases/network/tcp_cmds/tcpdump/tcpdump01 | 1 + testcases/network/tcp_cmds/telnet/telnet01 | 1 + .../network/tcp_cmds/tracepath/tracepath01.sh | 1 + testcases/network/tcp_fastopen/tcp_fastopen_run.sh | 1 + testcases/network/traceroute/traceroute01.sh | 1 + testcases/network/virt/geneve01.sh | 1 + testcases/network/virt/gre01.sh | 1 + testcases/network/virt/ipvlan01.sh | 1 + testcases/network/virt/macvlan01.sh | 1 + testcases/network/virt/macvtap01.sh | 1 + testcases/network/virt/vlan01.sh | 1 + testcases/network/virt/vlan02.sh | 1 + testcases/network/virt/vlan03.sh | 1 + testcases/network/virt/vxlan01.sh | 1 + testcases/network/virt/vxlan02.sh | 1 + testcases/network/virt/vxlan03.sh | 1 + testcases/network/xinetd/xinetd_tests.sh | 1 + testscripts/network.sh | 4 +- 85 files changed, 340 insertions(+), 220 deletions(-)
Signature · 1 line
2.16.3
RFC PATCH v2 1/3 test_net.sh: Support both old and new shell APIs
This is temporary solution, after migrating all tests to new SHELL API the compatibility layer and old SHELL API support should be removed and file renamed to tst_net.sh.
Add TST_USE_LEGACY_API=1 to all scripts using tst_net.sh (including testscripts/network.sh).
Filter out TST_IPV6 variable in tst_test.sh.
--- testcases/lib/test_net.sh | 133 +++++++++++++-------- testcases/lib/tst_test.sh | 1 + testcases/network/busy_poll/busy_poll01.sh | 1 + testcases/network/busy_poll/busy_poll02.sh | 1 + testcases/network/busy_poll/busy_poll03.sh | 1 + testcases/network/dccp/dccp01.sh | 1 + testcases/network/dctcp/dctcp01.sh | 1 + testcases/network/dhcp/dhcpd_tests.sh | 1 + testcases/network/dhcp/dnsmasq_tests.sh | 1 + testcases/network/iproute/ip_tests.sh | 1 + testcases/network/multicast/mc_cmds/mc_cmds | 1 + testcases/network/multicast/mc_commo/mc_commo | 1 + testcases/network/multicast/mc_member/mc_member | 1 + testcases/network/multicast/mc_opts/mc_opts | 1 + testcases/network/nfs/fsx-linux/fsx.sh | 1 + testcases/network/nfs/nfs_stress/nfs01 | 1 + testcases/network/nfs/nfs_stress/nfs02 | 1 + testcases/network/nfs/nfs_stress/nfs03 | 1 + testcases/network/nfs/nfs_stress/nfs04 | 1 + testcases/network/nfs/nfs_stress/nfs05 | 1 + testcases/network/nfs/nfs_stress/nfs06 | 1 + testcases/network/nfs/nfslock01/nfslock01 | 1 + testcases/network/nfs/nfsstat01/nfsstat01 | 1 + testcases/network/rpc/basic_tests/rpc01/rpc01 | 1 + .../network/rpc/basic_tests/rpcinfo/rpcinfo01 | 1 + testcases/network/rpc/basic_tests/rup/rup01 | 1 + testcases/network/rpc/basic_tests/rusers/rusers01 | 1 + testcases/network/rpc/rpc-tirpc/rpc_test.sh | 1 + testcases/network/sctp/sctp01.sh | 1 + testcases/network/sockets/bind_noport01.sh | 1 + .../network/stress/broken_ip/broken_ip4-checksum | 1 + .../network/stress/broken_ip/broken_ip4-dstaddr | 1 + .../network/stress/broken_ip/broken_ip4-fragment | 1 + testcases/network/stress/broken_ip/broken_ip4-ihl | 1 + .../network/stress/broken_ip/broken_ip4-protcol | 1 + .../network/stress/broken_ip/broken_ip4-totlen | 1 + .../network/stress/broken_ip/broken_ip4-version | 1 + .../network/stress/broken_ip/broken_ip6-dstaddr | 1 + .../network/stress/broken_ip/broken_ip6-nexthdr | 1 + testcases/network/stress/broken_ip/broken_ip6-plen | 1 + .../network/stress/broken_ip/broken_ip6-version | 1 + testcases/network/stress/dns/dns-stress | 1 + testcases/network/stress/ftp/ftp-download-stress | 1 + testcases/network/stress/ftp/ftp-upload-stress | 1 + testcases/network/stress/http/http-stress | 1 + testcases/network/stress/interface/if4-addr-change | 1 + testcases/network/stress/ipsec/ipsec_lib.sh | 1 + .../network/stress/ns-tools/test_net_stress.sh | 1 + testcases/network/stress/ssh/ssh-stress | 1 + testcases/network/tcp_cmds/arping/arping01.sh | 1 + .../network/tcp_cmds/clockdiff/clockdiff01.sh | 1 + testcases/network/tcp_cmds/ipneigh/ipneigh01.sh | 1 + testcases/network/tcp_cmds/ping/ping01.sh | 1 + testcases/network/tcp_cmds/ping/ping02.sh | 1 + testcases/network/tcp_cmds/rlogin/rlogin01 | 1 + testcases/network/tcp_cmds/sendfile/sendfile01 | 1 + testcases/network/tcp_cmds/tcpdump/tcpdump01 | 1 + testcases/network/tcp_cmds/telnet/telnet01 | 1 + .../network/tcp_cmds/tracepath/tracepath01.sh | 1 + testcases/network/tcp_fastopen/tcp_fastopen_run.sh | 1 + testcases/network/traceroute/traceroute01.sh | 1 + testcases/network/virt/geneve01.sh | 1 + testcases/network/virt/gre01.sh | 1 + testcases/network/virt/ipvlan01.sh | 1 + testcases/network/virt/macvlan01.sh | 1 + testcases/network/virt/macvtap01.sh | 1 + testcases/network/virt/vlan01.sh | 1 + testcases/network/virt/vlan02.sh | 1 + testcases/network/virt/vlan03.sh | 1 + testcases/network/virt/vxlan01.sh | 1 + testcases/network/virt/vxlan02.sh | 1 + testcases/network/virt/vxlan03.sh | 1 + testcases/network/xinetd/xinetd_tests.sh | 1 + testscripts/network.sh | 4 +- 74 files changed, 157 insertions(+), 52 deletions(-)
testcases/lib/test_net.sh +83 -50
@@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved. -# Copyright (c) 2016-2017 Petr Vorel <[email protected]> +# Copyright (c) 2016-2018 Petr Vorel <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -19,12 +19,62 @@ # Author: Alexey Kodanev <[email protected]> # -[ -z "$TST_LIB_LOADED" ] && . test.sh +TST_OPTS=":6" +TST_PARSE_ARGS=parse_args +TST_USAGE=usage + +# Blank for an IPV4 test; 6 for an IPV6 test. +TST_IPV6= + +parse_args() +{ + case $1 in + 6) TST_IPV6=6;; + esac +} + +tst_read_opts() +{ + local OPTIND + while getopts "$TST_OPTS" opt; do + $TST_PARSE_ARGS "$opt" + done +} + +usage() +{ + cat << EOF +usage: $0 [-6] + +OPTIONS +-6 Use IPv6 +EOF +} + +if [ -z "$TST_LIB_LOADED" ]; then + [ -n "$TST_USE_LEGACY_API" ] && . test.sh || . tst_test.sh +fi + +[ -n "$TST_USE_LEGACY_API" ] && tst_read_opts $* + +# old vs. new API compatibility layer +_tst_res() +{ + [ -z "$TST_USE_LEGACY_API" ] && tst_res $@ || tst_resm $@ +} +_tst_brk() +{ + [ -z "$TST_USE_LEGACY_API" ] && tst_brk $@ || tst_brkm $@ +} +_tst_require_root() +{ + [ -z "$TST_USE_LEGACY_API" ] && TST_NEEDS_ROOT=1 || tst_require_root +} init_ltp_netspace() { tst_check_cmds ip - tst_require_root + _tst_require_root local pid=
@@ -81,7 +131,7 @@ tst_rhost_run() s) safe=1 ;; c) cmd="$OPTARG" ;; u) user="$OPTARG" ;; - *) tst_brkm TBROK "tst_rhost_run: unknown option: $OPTARG" ;; + *) _tst_brk TBROK "tst_rhost_run: unknown option: $OPTARG" ;; esac done
@@ -89,8 +139,8 @@ tst_rhost_run() if [ -z "$cmd" ]; then [ "$safe" -eq 1 ] && \ - tst_brkm TBROK "tst_rhost_run: command not defined" - tst_resm TWARN "tst_rhost_run: command not defined" + _tst_brk TBROK "tst_rhost_run: command not defined" + _tst_res TWARN "tst_rhost_run: command not defined" return 1 fi
@@ -110,7 +160,7 @@ tst_rhost_run() if [ $ret -eq 1 ]; then output=$(echo "$output" | sed 's/RTERR//') [ "$safe" -eq 1 ] && \ - tst_brkm TBROK "'$cmd' failed on '$RHOST': '$output'" + _tst_brk TBROK "'$cmd' failed on '$RHOST': '$output'" fi [ -z "$out" -a -n "$output" ] && echo "$output"
@@ -122,9 +172,9 @@ EXPECT_RHOST_PASS() { tst_rhost_run -c "$*" > /dev/null if [ $? -eq 0 ]; then - tst_resm TPASS "$* passed as expected" + _tst_res TPASS "$* passed as expected" else - tst_resm TFAIL "$* failed unexpectedly" + _tst_res TFAIL "$* failed unexpectedly" fi }
@@ -132,9 +182,9 @@ EXPECT_RHOST_FAIL() { tst_rhost_run -c "$* 2> /dev/null" if [ $? -ne 0 ]; then - tst_resm TPASS "$* failed as expected" + _tst_res TPASS "$* failed as expected" else - tst_resm TFAIL "$* passed unexpectedly" + _tst_res TFAIL "$* passed unexpectedly" fi }
@@ -200,23 +250,6 @@ tst_iface() echo "$(tst_get_ifaces $type)" | awk '{ print $'"$link_num"' }' } -# Blank for an IPV4 test; 6 for an IPV6 test. -TST_IPV6= - -tst_read_opts() -{ - OPTIND=0 - while getopts ":6" opt; do - case "$opt" in - 6) - TST_IPV6=6;; - esac - done - OPTIND=0 -} - -tst_read_opts $* - # Get IP address # tst_ipaddr [TYPE] # TYPE: { lhost | rhost }; Default value is 'lhost'.
@@ -302,7 +335,7 @@ tst_init_iface() local type="${1:-lhost}" local link_num="${2:-0}" local iface="$(tst_iface $type $link_num)" - tst_resm TINFO "initialize '$type' '$iface' interface" + _tst_res TINFO "initialize '$type' '$iface' interface" if [ "$type" = "lhost" ]; then ip xfrm policy flush || return $?
@@ -340,12 +373,12 @@ tst_add_ipaddr() local iface=$(tst_iface $type $link_num) if [ $type = "lhost" ]; then - tst_resm TINFO "set local addr $(tst_ipaddr)/$mask" + _tst_res TINFO "set local addr $(tst_ipaddr)/$mask" ip addr add $(tst_ipaddr)/$mask dev $iface return $? fi - tst_resm TINFO "set remote addr $(tst_ipaddr rhost)/$mask" + _tst_res TINFO "set remote addr $(tst_ipaddr rhost)/$mask" tst_rhost_run -c "ip addr add $(tst_ipaddr rhost)/$mask dev $iface" }
@@ -356,7 +389,7 @@ tst_add_ipaddr() tst_restore_ipaddr() { tst_check_cmds ip - tst_require_root + _tst_require_root local type="${1:-lhost}" local link_num="${2:-0}"
@@ -390,7 +423,7 @@ tst_wait_ipv6_dad() [ $ret -ne 0 -a $? -ne 0 ] && return [ $(($i % 10)) -eq 0 ] && \ - tst_resm TINFO "wait for IPv6 DAD completion $((i / 10))/5 sec" + _tst_res TINFO "wait for IPv6 DAD completion $((i / 10))/5 sec" tst_sleep 100ms done
@@ -443,7 +476,7 @@ tst_netload() f) cs_opts="${cs_opts}-f " ;; F) cs_opts="${cs_opts}-F " ;; e) expect_res="$OPTARG" ;; - *) tst_brkm TBROK "tst_netload: unknown option: $OPTARG" ;; + *) _tst_brk TBROK "tst_netload: unknown option: $OPTARG" ;; esac done OPTIND=0
@@ -455,37 +488,37 @@ tst_netload() tst_rhost_run -c "pkill -9 netstress\$" s_opts="${cs_opts}${s_opts}-R $s_replies -B $TST_TMPDIR" - tst_resm TINFO "run server 'netstress $s_opts'" + _tst_res TINFO "run server 'netstress $s_opts'" tst_rhost_run -c "netstress $s_opts" > tst_netload.log 2>&1 if [ $? -ne 0 ]; then cat tst_netload.log local ttype="TFAIL" grep -e 'CONF:' tst_netload.log && ttype="TCONF" - tst_brkm $ttype "server failed" + _tst_brk $ttype "server failed" fi local port=$(tst_rhost_run -s -c "cat $TST_TMPDIR/netstress_port") c_opts="${cs_opts}${c_opts}-a $c_num -r $c_requests -d $rfile -g $port" - tst_resm TINFO "run client 'netstress -l $c_opts'" + _tst_res TINFO "run client 'netstress -l $c_opts'" netstress -l $c_opts > tst_netload.log 2>&1 || ret=1 tst_rhost_run -c "pkill -9 netstress\$" if [ "$expect_ret" -ne "$ret" ]; then tst_dump_rhost_cmd cat tst_netload.log - tst_brkm TFAIL "expected '$expect_res' but ret: '$ret'" + _tst_brk TFAIL "expected '$expect_res' but ret: '$ret'" fi if [ "$ret" -eq 0 ]; then if [ ! -f $rfile ]; then tst_dump_rhost_cmd cat tst_netload.log - tst_brkm TFAIL "can't read $rfile" + _tst_brk TFAIL "can't read $rfile" fi - tst_resm TPASS "netstress passed, time spent '$(cat $rfile)' ms" + _tst_res TPASS "netstress passed, time spent '$(cat $rfile)' ms" else - tst_resm TPASS "netstress failed as expected" + _tst_res TPASS "netstress failed as expected" fi return $ret
@@ -516,9 +549,9 @@ tst_ping() -s $size -i 0 > /dev/null 2>&1 ret=$? if [ $ret -eq 0 ]; then - tst_resm TPASS "$msg $size: pass" + _tst_res TPASS "$msg $size: pass" else - tst_resm TFAIL "$msg $size: fail" + _tst_res TFAIL "$msg $size: fail" break fi done
@@ -558,9 +591,9 @@ tst_icmp() ns-icmpv${ver}_sender -s $size $opts ret=$? if [ $ret -eq 0 ]; then - tst_resm TPASS "'ns-icmpv${ver}_sender -s $size $opts' pass" + _tst_res TPASS "'ns-icmpv${ver}_sender -s $size $opts' pass" else - tst_resm TFAIL "'ns-icmpv${ver}_sender -s $size $opts' fail" + _tst_res TFAIL "'ns-icmpv${ver}_sender -s $size $opts' fail" break fi done
@@ -644,10 +677,10 @@ if [ -z "$TST_PARSE_VARIABLES" ]; then eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \ $IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?") - tst_resm TINFO "Network config (local -- remote):" - tst_resm TINFO "$LHOST_IFACES -- $RHOST_IFACES" - tst_resm TINFO "$IPV4_LHOST/$IPV4_LPREFIX -- $IPV4_RHOST/$IPV4_RPREFIX" - tst_resm TINFO "$IPV6_LHOST/$IPV6_LPREFIX -- $IPV6_RHOST/$IPV6_RPREFIX" + _tst_res TINFO "Network config (local -- remote):" + _tst_res TINFO "$LHOST_IFACES -- $RHOST_IFACES" + _tst_res TINFO "$IPV4_LHOST/$IPV4_LPREFIX -- $IPV4_RHOST/$IPV4_RPREFIX" + _tst_res TINFO "$IPV6_LHOST/$IPV6_LPREFIX -- $IPV6_RHOST/$IPV6_RPREFIX" export TST_PARSE_VARIABLES="yes" fi
@@ -687,7 +720,7 @@ export RHOST_HWADDRS="${RHOST_HWADDRS:-$(tst_get_hwaddrs rhost)}" # in the following document: testcases/network/stress/README if [ "$TST_NEEDS_TMPDIR" = 1 ]; then - tst_tmpdir + [ -n "$TST_USE_LEGACY_API" ] && tst_tmpdir tst_rhost_run -c "mkdir -p $TST_TMPDIR" tst_rhost_run -c "chmod 777 $TST_TMPDIR" export TST_TMPDIR_RHOST=1
testcases/lib/tst_test.sh +1 -0
@@ -255,6 +255,7 @@ tst_run() OPTS|USAGE|PARSE_ARGS|POS_ARGS);; NEEDS_ROOT|NEEDS_TMPDIR|NEEDS_DEVICE|DEVICE);; NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);; + IPV6);; *) tst_res TWARN "Reserved variable TST_$tst_i used!";; esac done
testcases/network/busy_poll/busy_poll01.sh +1 -0
@@ -21,6 +21,7 @@ TST_TOTAL=1 TCID="busy_poll01" TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh . busy_poll_lib.sh
testcases/network/busy_poll/busy_poll02.sh +1 -0
@@ -21,6 +21,7 @@ TST_TOTAL=1 TCID="busy_poll02" TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh . busy_poll_lib.sh
testcases/network/busy_poll/busy_poll03.sh +1 -0
@@ -21,6 +21,7 @@ TST_TOTAL=2 TCID="busy_poll03" TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh . busy_poll_lib.sh
testcases/network/dccp/dccp01.sh +1 -0
@@ -21,6 +21,7 @@ TST_TOTAL=3 TST_CLEANUP="cleanup" TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh cleanup()
testcases/network/dctcp/dctcp01.sh +1 -0
@@ -23,6 +23,7 @@ TST_NEEDS_TMPDIR=1 def_alg="cubic" prev_alg= +TST_USE_LEGACY_API=1 . test_net.sh set_cong_alg()
testcases/network/dhcp/dhcpd_tests.sh +1 -0
@@ -24,6 +24,7 @@ TST_TOTAL=1 TCID="dhcpd" dhcp_name="dhcpd" +TST_USE_LEGACY_API=1 . test_net.sh . dhcp_lib.sh
testcases/network/dhcp/dnsmasq_tests.sh +1 -0
@@ -22,6 +22,7 @@ TST_TOTAL=1 TCID="dnsmasq" dhcp_name="dnsmasq" +TST_USE_LEGACY_API=1 . test_net.sh . dhcp_lib.sh
testcases/network/iproute/ip_tests.sh +1 -0
@@ -24,6 +24,7 @@ TST_CLEANUP=cleanup TST_TOTAL=6 TCID="ip_tests" +TST_USE_LEGACY_API=1 . test_net.sh rm_dummy=
testcases/network/multicast/mc_cmds/mc_cmds +1 -0
@@ -29,6 +29,7 @@ TCID=mc_cmds TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh knob="net.ipv4.icmp_echo_ignore_broadcasts"
testcases/network/multicast/mc_commo/mc_commo +1 -0
@@ -31,6 +31,7 @@ OUTFILE=mc_commo_out TCID=mc_commo TST_TOTAL=2 +TST_USE_LEGACY_API=1 . test_net.sh do_setup()
testcases/network/multicast/mc_member/mc_member +1 -0
@@ -33,6 +33,7 @@ TCID=mc_member TST_TOTAL=1 TST_COUNT=1 +TST_USE_LEGACY_API=1 . test_net.sh setup()
testcases/network/multicast/mc_opts/mc_opts +1 -0
@@ -32,6 +32,7 @@ EXECUTABLES=${EXECUTABLES:-"mc_verify_opts mc_verify_opts_error"} TCID=mc_opts TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh COUNT=1
testcases/network/nfs/fsx-linux/fsx.sh +1 -0
@@ -26,6 +26,7 @@ TST_TOTAL=1 TST_CLEANUP="nfs_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh do_test()
testcases/network/nfs/nfs_stress/nfs01 +1 -0
@@ -25,6 +25,7 @@ TST_TOTAL=1 TST_CLEANUP="nfs_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh do_test()
testcases/network/nfs/nfs_stress/nfs02 +1 -0
@@ -25,6 +25,7 @@ TST_TOTAL=3 TST_CLEANUP="nfs_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh do_test1()
testcases/network/nfs/nfs_stress/nfs03 +1 -0
@@ -25,6 +25,7 @@ TST_TOTAL=1 TST_CLEANUP="nfs03_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh DIR_NUM=${DIR_NUM:-"100"}
testcases/network/nfs/nfs_stress/nfs04 +1 -0
@@ -28,6 +28,7 @@ TST_TOTAL=1 TST_CLEANUP="nfs_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh nfs_setup
testcases/network/nfs/nfs_stress/nfs05 +1 -0
@@ -29,6 +29,7 @@ FILE_NUM=${FILE_NUM:-"50"} THREAD_NUM=${THREAD_NUM:-"8"} . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh tst_check_cmds make gcc
testcases/network/nfs/nfs_stress/nfs06 +1 -0
@@ -25,6 +25,7 @@ TST_TOTAL=1 TST_CLEANUP="nfs_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh do_test()
testcases/network/nfs/nfslock01/nfslock01 +1 -0
@@ -26,6 +26,7 @@ TST_TOTAL=1 TST_CLEANUP="nfs_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh LUSER=${LUSER:=root}
testcases/network/nfs/nfsstat01/nfsstat01 +1 -0
@@ -22,6 +22,7 @@ TST_TOTAL=4 TST_CLEANUP="nfs_cleanup" . nfs_lib.sh +TST_USE_LEGACY_API=1 . test_net.sh setup()
testcases/network/rpc/basic_tests/rpc01/rpc01 +1 -0
@@ -19,6 +19,7 @@ TCID="rpc01" TST_TOTAL=6 TST_CLEANUP=do_cleanup +TST_USE_LEGACY_API=1 . test_net.sh NUMLOOPS=${NUMLOOPS:=3}
testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01 +1 -0
@@ -19,6 +19,7 @@ TCID="rpcinfo01" TST_TOTAL=16 TST_CLEANUP=tst_rmdir +TST_USE_LEGACY_API=1 . test_net.sh do_setup()
testcases/network/rpc/basic_tests/rup/rup01 +1 -0
@@ -18,6 +18,7 @@ TCID="rup01" TST_TOTAL=7 +TST_USE_LEGACY_API=1 . test_net.sh do_setup()
testcases/network/rpc/basic_tests/rusers/rusers01 +1 -0
@@ -18,6 +18,7 @@ TCID="rusers01" TST_TOTAL=5 +TST_USE_LEGACY_API=1 . test_net.sh do_setup()
testcases/network/rpc/rpc-tirpc/rpc_test.sh +1 -0
@@ -82,6 +82,7 @@ TST_TOTAL=1 TST_COUNT=1 TST_CLEANUP=cleanup +TST_USE_LEGACY_API=1 . test_net.sh if [ ! -z "$SERVER" ]; then
testcases/network/sctp/sctp01.sh +1 -0
@@ -21,6 +21,7 @@ TST_TOTAL=4 TST_CLEANUP="cleanup" TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh cleanup()
testcases/network/sockets/bind_noport01.sh +1 -0
@@ -18,6 +18,7 @@ TST_TOTAL=1 TCID="bind_noport" TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh cleanup()
testcases/network/stress/broken_ip/broken_ip4-checksum +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip4-checksum01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong chksum field for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip4-dstaddr +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip4-dstaddr01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong dst address for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip4-fragment +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip4-fragment01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong frag. info for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip4-ihl +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip4-ihl01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong header len field for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip4-protcol +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip4-protocol01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong proto field for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip4-totlen +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip4-totlen01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong total len field for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip4-version +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip4-version01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong version field for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip6-dstaddr +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip6-dstaddr01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv6 with wrong dst address for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip6-nexthdr +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip6-nexthdr01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong next header for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip6-plen +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip6-plen01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv4 with wrong payload len for $NS_DURATION sec"
testcases/network/stress/broken_ip/broken_ip6-version +1 -0
@@ -21,6 +21,7 @@ TCID=broken_ip6-version01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_resm TINFO "Sending ICMPv6 with wrong version field for $NS_DURATION sec"
testcases/network/stress/dns/dns-stress +1 -0
@@ -22,6 +22,7 @@ TCID=dns-stress TST_TOTAL=2 TST_CLEANUP="cleanup" +TST_USE_LEGACY_API=1 . test_net.sh # Minimum host ID in the zone file.
testcases/network/stress/ftp/ftp-download-stress +1 -0
@@ -23,6 +23,7 @@ TCID=ftp-download-stress TST_TOTAL=2 TST_CLEANUP="cleanup" +TST_USE_LEGACY_API=1 . test_net.sh # Big file size to upload/download in ftp tests (byte)
testcases/network/stress/ftp/ftp-upload-stress +1 -0
@@ -23,6 +23,7 @@ TCID=ftp-upload-stress TST_TOTAL=2 TST_CLEANUP="cleanup" +TST_USE_LEGACY_API=1 . test_net.sh # Big file size to upload (byte)
testcases/network/stress/http/http-stress +1 -0
@@ -23,6 +23,7 @@ TCID=http-stress TST_TOTAL=2 TST_CLEANUP="cleanup" +TST_USE_LEGACY_API=1 . test_net.sh cleanup()
testcases/network/stress/interface/if4-addr-change +1 -0
@@ -21,6 +21,7 @@ TST_TOTAL=1 TCID=if4-addr-change TST_CLEANUP="do_cleanup" +TST_USE_LEGACY_API=1 . test_net.sh CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
testcases/network/stress/ipsec/ipsec_lib.sh +1 -0
@@ -19,6 +19,7 @@ # ####################################################################### +TST_USE_LEGACY_API=1 . test_net.sh # Authenticated encryption with associated data
testcases/network/stress/ns-tools/test_net_stress.sh +1 -0
@@ -25,6 +25,7 @@ export TCID="${TCID:-$(basename $0)}" +TST_USE_LEGACY_API=1 . test_net.sh ipver=${TST_IPV6:-4}
testcases/network/stress/ssh/ssh-stress +1 -0
@@ -24,6 +24,7 @@ TCID=ssh-stress TST_TOTAL=3 TST_CLEANUP="cleanup" +TST_USE_LEGACY_API=1 . test_net.sh # Temporary directory to store sshd setting or ssh key
testcases/network/tcp_cmds/arping/arping01.sh +1 -0
@@ -18,6 +18,7 @@ TCID=arping01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_require_root
testcases/network/tcp_cmds/clockdiff/clockdiff01.sh +1 -0
@@ -18,6 +18,7 @@ TCID=clockdiff01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh tst_require_root
testcases/network/tcp_cmds/ipneigh/ipneigh01.sh +1 -0
@@ -19,6 +19,7 @@ TCID=ipneigh01 NUMLOOPS=${NUMLOOPS:-50} TST_TOTAL=2 +TST_USE_LEGACY_API=1 . test_net.sh do_setup()
testcases/network/tcp_cmds/ping/ping01.sh +1 -0
@@ -28,6 +28,7 @@ TST_TOTAL=10 TCID="ping01" +TST_USE_LEGACY_API=1 . test_net.sh do_setup()
testcases/network/tcp_cmds/ping/ping02.sh +1 -0
@@ -17,6 +17,7 @@ TST_TOTAL=10 TCID="ping02" +TST_USE_LEGACY_API=1 . test_net.sh do_setup()
testcases/network/tcp_cmds/rlogin/rlogin01 +1 -0
@@ -20,6 +20,7 @@ TCID="rlogin01" TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh setup()
testcases/network/tcp_cmds/sendfile/sendfile01 +1 -0
@@ -102,6 +102,7 @@ do_cleanup() tst_rmdir } +TST_USE_LEGACY_API=1 . test_net.sh do_setup
testcases/network/tcp_cmds/tcpdump/tcpdump01 +1 -0
@@ -64,6 +64,7 @@ do_cleanup() tst_rmdir } +TST_USE_LEGACY_API=1 . test_net.sh do_setup
testcases/network/tcp_cmds/telnet/telnet01 +1 -0
@@ -20,6 +20,7 @@ TCID="telnet01" TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh setup()
testcases/network/tcp_cmds/tracepath/tracepath01.sh +1 -0
@@ -18,6 +18,7 @@ TCID=tracepath01 TST_TOTAL=1 +TST_USE_LEGACY_API=1 . test_net.sh test_tracepath()
testcases/network/tcp_fastopen/tcp_fastopen_run.sh +1 -0
@@ -23,6 +23,7 @@ TST_TOTAL=1 TCID="tcp_fastopen" TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh while getopts :hr:n:R:6 opt; do
testcases/network/traceroute/traceroute01.sh +1 -0
@@ -19,6 +19,7 @@ TST_TOTAL=6 TCID="traceroute01" TST_CLEANUP="cleanup" +TST_USE_LEGACY_API=1 . test_net.sh cleanup()
testcases/network/virt/geneve01.sh +1 -0
@@ -27,6 +27,7 @@ start_id=16700000 # that is why using here 'vxlan_*' library functions. vxlan_dst_addr="uni" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/gre01.sh +1 -0
@@ -24,6 +24,7 @@ TCID=gre01 TST_TOTAL=1 TST_NEEDS_TMPDIR=1 +TST_USE_LEGACY_API=1 . test_net.sh virt_type="gre"
testcases/network/virt/ipvlan01.sh +1 -0
@@ -24,6 +24,7 @@ TST_TOTAL=2 virt_type="ipvlan" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/macvlan01.sh +1 -0
@@ -24,6 +24,7 @@ TST_TOTAL=4 virt_type="macvlan" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/macvtap01.sh +1 -0
@@ -24,6 +24,7 @@ TST_TOTAL=4 virt_type="macvtap" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/vlan01.sh +1 -0
@@ -24,6 +24,7 @@ TST_TOTAL=9 virt_type="vlan" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/vlan02.sh +1 -0
@@ -25,6 +25,7 @@ TST_TOTAL=1 virt_type="vlan" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/vlan03.sh +1 -0
@@ -29,6 +29,7 @@ TST_NEEDS_TMPDIR=1 virt_type="vlan" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/vxlan01.sh +1 -0
@@ -25,6 +25,7 @@ TST_TOTAL=5 virt_type="vxlan" start_id=16700000 +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/vxlan02.sh +1 -0
@@ -26,6 +26,7 @@ TST_TOTAL=1 virt_type="vxlan" start_id=16700000 +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/virt/vxlan03.sh +1 -0
@@ -33,6 +33,7 @@ start_id=16700000 # Destination address, can be unicast or multicast address vxlan_dst_addr="uni" +TST_USE_LEGACY_API=1 . test_net.sh . virt_lib.sh
testcases/network/xinetd/xinetd_tests.sh +1 -0
@@ -20,6 +20,7 @@ TST_TOTAL=2 TST_CLEANUP="cleanup" . daemonlib.sh +TST_USE_LEGACY_API=1 . test_net.sh setup()
testscripts/network.sh +2 -2
@@ -88,12 +88,12 @@ fi TST_TOTAL=1 TCID="network_settings" +TST_USE_LEGACY_API=1 . test_net.sh # Reset variables. # Don't break the tests which are using 'testcases/lib/cmdlib.sh' -export TCID= -export TST_LIB_LOADED= +unset TCID TST_LIB_LOADED TST_USE_LEGACY_API rm -f $CMDFILE
Signature · 1 line
2.16.3
RFC PATCH v2 2/3 network/interface: Cleanup if4-addr-change
In reply to Petr VorelWrap test code into function.
This is preparation for next commit.
--- testcases/network/stress/interface/if4-addr-change | 60 ++++++++++++---------- 1 file changed, 33 insertions(+), 27 deletions(-)
testcases/network/stress/interface/if4-addr-change +33 -27
@@ -36,42 +36,48 @@ do_cleanup() trap "tst_brkm TBROK 'test interrupted'" INT -tst_check_cmds ifconfig +test_body() +{ + local cnt=0 + local num=1 + local add_to_net= + + tst_resm TINFO "ifconfig changes IPv4 address $NS_TIMES times" -tst_resm TINFO "ifconfig changes IPv4 address $NS_TIMES times" + while [ $cnt -lt $NS_TIMES ]; do + # Define the network portion + num=$(($num + 1)) + [ $num -gt $LHOST_IPV4_HOST_MAX ] && num=1 -cnt=0 -num=1 -while [ $cnt -lt $NS_TIMES ]; do - # Define the network portion - num=$(($num + 1)) - [ $num -gt $LHOST_IPV4_HOST_MAX ] && num=1 + [ $num -eq $RHOST_IPV4_HOST ] && continue - [ $num -eq $RHOST_IPV4_HOST ] && continue + # check prefix and fix values for prefix != 24 + add_to_net= + if [ $IPV4_LPREFIX -lt 8 -o $IPV4_LPREFIX -ge 32 ] ; then + tst_brkm TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)" + elif [ $IPV4_LPREFIX -lt 16 ]; then # N.x.x.num + add_to_net=".0.1" + elif [ $IPV4_LPREFIX -lt 24 ]; then # N.N.x.num + add_to_net=".1" + fi - # check prefix and fix values for prefix != 24 - add_to_net= - if [ $IPV4_LPREFIX -lt 8 -o $IPV4_LPREFIX -ge 32 ] ; then - tst_brkm TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)" - elif [ $IPV4_LPREFIX -lt 16 ]; then # N.x.x.num - add_to_net=".0.1" - elif [ $IPV4_LPREFIX -lt 24 ]; then # N.N.x.num - add_to_net=".1" - fi + # Change IPv4 address + ROD ifconfig $(tst_iface) ${IPV4_LNETWORK}${add_to_net}.${num} netmask \ + $IPV4_LNETMASK broadcast $IPV4_LBROADCAST - # Change IPv4 address - ROD ifconfig $(tst_iface) ${IPV4_LNETWORK}${add_to_net}.${num} netmask \ - $IPV4_LNETMASK broadcast $IPV4_LBROADCAST + cnt=$(($cnt + 1)) - cnt=$(($cnt + 1)) + [ $CHECK_INTERVAL -eq 0 ] && continue + [ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue - [ $CHECK_INTERVAL -eq 0 ] && continue - [ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue + tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES" + tst_ping + done - tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES" tst_ping -done +} -tst_ping +tst_check_cmds ifconfig +test_body tst_exit
Signature · 1 line
2.16.3
RFC PATCH v2 3/3 net: Migrate test_net_stress.sh and it's dependencies to new shell API
In reply to Petr Vorel--- testcases/network/stress/interface/if-addr-adddel | 31 ++++++++---------- .../network/stress/interface/if-addr-addlarge | 37 ++++++++++------------ testcases/network/stress/interface/if-mtu-change | 24 ++++++-------- testcases/network/stress/interface/if-route-adddel | 26 ++++++--------- .../network/stress/interface/if-route-addlarge | 28 +++++++--------- testcases/network/stress/interface/if-updown | 27 +++++++--------- testcases/network/stress/interface/if4-addr-change | 25 ++++++++------- .../grp-operation/mcast-group-multiple-socket | 16 ++++++---- .../multicast/grp-operation/mcast-group-same-group | 17 +++++++--- .../grp-operation/mcast-group-single-socket | 17 +++++++--- .../grp-operation/mcast-group-source-filter | 17 +++++++--- .../stress/multicast/grp-operation/mcast-lib.sh | 15 +++++---- .../network/stress/ns-tools/test_net_stress.sh | 25 ++++++++++++--- 13 files changed, 157 insertions(+), 148 deletions(-)
testcases/network/stress/interface/if-addr-adddel +13 -18
@@ -1,5 +1,6 @@ #!/bin/sh # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # Copyright (c) International Business Machines Corp., 2005 # # This program is free software; you can redistribute it and/or
@@ -17,10 +18,10 @@ # # Author: Mitsuru Chinen <[email protected]> -TST_TOTAL=2 - +TST_CNT=2 +TST_SETUP="netstress_setup" TST_CLEANUP="netstress_cleanup" - +TST_TESTFUNC="test_if_ip" . test_net_stress.sh # The interval of the check interface activity
@@ -33,7 +34,7 @@ test_body() case $cmd_type in if_cmd) local cmd_name='ifconfig' ;; ip_cmd) local cmd_name='ip' ;; - *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" + *) tst_brk TBROK "Unknown test parameter '$cmd_type'" esac local num=$(($(od -A n -t u1 -N 1 /dev/random) * 253 / 255 + 2 ))
@@ -46,10 +47,10 @@ test_body() local netmask=24 fi - tst_resm TINFO "'$cmd_name' add/del IPv$ipver '$new_ip' $NS_TIMES times" + tst_res TINFO "'$cmd_name' add/del IPv$ipver '$new_ip' $NS_TIMES times" if ! restore_ipaddr; then - tst_resm TBROK "Failed to set default IP addresses" + tst_res TBROK "Failed to set default IP addresses" return fi
@@ -69,14 +70,14 @@ test_body() esac if [ $? -ne 0 ]; then - tst_resm TFAIL "command failed to add $new_ip to $iface" + tst_res TFAIL "command failed to add $new_ip to $iface" return fi ip addr show $iface | grep -q $new_ip if [ $? -ne 0 ]; then ip addr show $iface - tst_resm TFAIL "$new_ip not configured" + tst_res TFAIL "$new_ip not configured" return fi
@@ -96,26 +97,20 @@ test_body() esac if [ $? -ne 0 ]; then - tst_resm TFAIL " delete command failed". + tst_res TFAIL " delete command failed". return fi ip addr show $iface | grep -q $new_ip if [ $? -eq 0 ]; then ip addr show $iface - tst_resm TFAIL "Failed to remove '$new_ip' address" + tst_res TFAIL "Failed to remove '$new_ip' address" return fi done - tst_resm TPASS "Test is finished correctly" + tst_res TPASS "Test is finished correctly" } -netstress_setup - tst_check_cmds ifconfig - -test_body 'if_cmd' -test_body 'ip_cmd' - -tst_exit +tst_run
testcases/network/stress/interface/if-addr-addlarge +16 -21
@@ -1,5 +1,6 @@ #!/bin/sh # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # Copyright (c) International Business Machines Corp., 2005 # # This program is free software; you can redistribute it and/or
@@ -17,10 +18,10 @@ # # Author: Mitsuru Chinen <[email protected]> -TST_TOTAL=2 - +TST_CNT=2 +TST_SETUP="netstress_setup" TST_CLEANUP="netstress_cleanup" - +TST_TESTFUNC="test_if_ip" . test_net_stress.sh # The interval of the check interface activity
@@ -33,17 +34,17 @@ test_body() case $cmd_type in if_cmd) local cmd_name='ifconfig' ;; ip_cmd) local cmd_name='ip' ;; - *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" + *) tst_brk TBROK "Unknown test parameter '$cmd_type'" esac local iface=$(tst_iface) [ "$TST_IPV6" ] && local netmask=64 || local netmask=16 - tst_resm TINFO "'$cmd_name' add $IP_TOTAL IPv$ipver addresses" - tst_resm TINFO "check interval that $iface is working: $CHECK_INTERVAL" + tst_res TINFO "'$cmd_name' add $IP_TOTAL IPv$ipver addresses" + tst_res TINFO "check interval that $iface is working: $CHECK_INTERVAL" if ! restore_ipaddr; then - tst_resm TBROK "Failed to set default IP addresses" + tst_res TBROK "Failed to set default IP addresses" return fi
@@ -54,7 +55,7 @@ test_body() [ "$TST_IPV6" ] && local xymax=65535 || xymax=254 if [ $IP_TOTAL -gt $((xymax * xymax)) ]; then - tst_resm TWARN "set IP_TOTAL to $xymax * $xymax" + tst_res TWARN "set IP_TOTAL to $xymax * $xymax" IP_TOTAL=$((xymax * xymax)) fi
@@ -81,14 +82,14 @@ test_body() esac if [ $? -ne 0 ]; then - tst_resm TFAIL "command failed to add $new_ip to $iface" + tst_res TFAIL "command failed to add $new_ip to $iface" return fi ip addr show $iface | grep -q $new_ip if [ $? -ne 0 ]; then ip addr show $iface - tst_resm TFAIL "$new_ip not configured" + tst_res TFAIL "$new_ip not configured" return fi
@@ -106,14 +107,14 @@ test_body() esac if [ $? -ne 0 ]; then - tst_resm TFAIL " delete command failed". + tst_res TFAIL " delete command failed". return fi ip addr show $iface | grep -q $new_ip if [ $? -eq 0 ]; then ip addr show $iface - tst_resm TFAIL "Failed to remove '$new_ip' address" + tst_res TFAIL "Failed to remove '$new_ip' address" return fi
@@ -123,19 +124,13 @@ test_body() y=1 x=$(($x + 1)) if [ $x -gt $xymax ]; then - tst_brkm TBROK "Too large $IP_TOTAL" + tst_brk TBROK "Too large $IP_TOTAL" fi fi done - tst_resm TPASS "Test is finished correctly" + tst_res TPASS "Test is finished correctly" } -netstress_setup - tst_check_cmds ifconfig - -test_body 'if_cmd' -test_body 'ip_cmd' - -tst_exit +tst_run
testcases/network/stress/interface/if-mtu-change +9 -15
@@ -1,5 +1,6 @@ #!/bin/sh # Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # Copyright (c) International Business Machines Corp., 2005 # # This program is free software; you can redistribute it and/or
@@ -17,10 +18,10 @@ # # Author: Mitsuru Chinen <[email protected]> -TST_TOTAL=2 - +TST_CNT=2 +TST_SETUP="netstress_setup" TST_CLEANUP="do_cleanup" - +TST_TESTFUNC="test_if_ip" . test_net_stress.sh # The interval of the mtu change [second]
@@ -52,14 +53,14 @@ test_body() case $cmd_type in if_cmd) local cmd_name='ifconfig' ;; ip_cmd) local cmd_name='ip' ;; - *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" + *) tst_brk TBROK "Unknown test parameter '$cmd_type'" esac local iface=$(tst_iface) local iface_rmt=$(tst_iface rhost) [ "$TST_IPV6" ] && local netmask=64 || local netmask=16 - tst_resm TINFO "'$cmd_name changes MTU $MTU_CHANGE_TIMES times" \ + tst_res TINFO "'$cmd_name changes MTU $MTU_CHANGE_TIMES times" \ "every $CHANGE_INTERVAL seconds" mtu_array_len=$(echo $CHANGE_VALUES | wc -w)
@@ -73,7 +74,7 @@ test_body() make_background_tcp_traffic - tst_resm TINFO "set MTU to $mtu $cnt/$MTU_CHANGE_TIMES" + tst_res TINFO "set MTU to $mtu $cnt/$MTU_CHANGE_TIMES" local ret=0 case $cmd_type in if_cmd) ifconfig $iface mtu $mtu || ret=1
@@ -85,7 +86,7 @@ test_body() esac if [ $? -ne 0 -o $ret -ne 0 ]; then - tst_resm TFAIL "Failed to change the mtu at $cnt time" + tst_res TFAIL "Failed to change the mtu at $cnt time" return fi
@@ -95,13 +96,6 @@ test_body() done } -netstress_setup - tst_check_cmds ifconfig - saved_mtu="$(cat /sys/class/net/$(tst_iface)/mtu)" - -test_body 'if_cmd' -test_body 'ip_cmd' - -tst_exit +tst_run
testcases/network/stress/interface/if-route-adddel +10 -16
@@ -17,10 +17,10 @@ # # Author: Mitsuru Chinen <[email protected]> -TST_TOTAL=2 - +TST_CNT=2 +TST_SETUP="netstress_setup" TST_CLEANUP="netstress_cleanup" - +TST_TESTFUNC="test_rt_ip" . test_net_stress.sh CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
@@ -32,7 +32,7 @@ test_body() case $cmd_type in rt_cmd) local cmd_name='route' ;; ip_cmd) local cmd_name='ip' ;; - *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" + *) tst_brk TBROK "Unknown test parameter '$cmd_type'" esac local iface=$(tst_iface)
@@ -50,10 +50,10 @@ test_body() esac fi - tst_resm TINFO "'$cmd_name' add/del ${new_rt}${opt_rt} $NS_TIMES times" + tst_res TINFO "'$cmd_name' add/del ${new_rt}${opt_rt} $NS_TIMES times" if ! restore_ipaddr; then - tst_resm TBROK "Failed to set default IP addresses" + tst_res TBROK "Failed to set default IP addresses" return fi
@@ -66,7 +66,7 @@ test_body() ip_cmd) ip route add ${new_rt}${opt_rt} dev $iface ;; esac if [ $? -ne 0 ]; then - tst_resm TFAIL "Can't add route $new_rt to $iface" + tst_res TFAIL "Can't add route $new_rt to $iface" return fi
@@ -75,7 +75,7 @@ test_body() ip_cmd) ip route del ${new_rt}${opt_rt} dev $iface ;; esac if [ $? -ne 0 ]; then - tst_resm TFAIL "Can't del route $new_rt from $iface" + tst_res TFAIL "Can't del route $new_rt from $iface" return fi
@@ -84,14 +84,8 @@ test_body() cnt=$(($cnt + 1)) done - tst_resm TPASS "Test is finished correctly" + tst_res TPASS "Test is finished correctly" } -netstress_setup - tst_check_cmds route - -test_body 'rt_cmd' -test_body 'ip_cmd' - -tst_exit +tst_run
testcases/network/stress/interface/if-route-addlarge +11 -17
@@ -17,10 +17,10 @@ # # Author: Mitsuru Chinen <[email protected]> -TST_TOTAL=2 - +TST_CNT=2 +TST_SETUP="netstress_setup" TST_CLEANUP="netstress_cleanup" - +TST_TESTFUNC="test_rt_ip" . test_net_stress.sh CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 20))}
@@ -32,7 +32,7 @@ test_body() case $cmd_type in rt_cmd) local cmd_name='route' ;; ip_cmd) local cmd_name='ip' ;; - *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" + *) tst_brk TBROK "Unknown test parameter '$cmd_type'" esac local iface=$(tst_iface)
@@ -47,10 +47,10 @@ test_body() esac fi - tst_resm TINFO "'$cmd_name' add IPv$ipver $ROUTE_TOTAL routes" + tst_res TINFO "'$cmd_name' add IPv$ipver $ROUTE_TOTAL routes" if ! restore_ipaddr; then - tst_resm TBROK "Failed to set default IP addresses" + tst_res TBROK "Failed to set default IP addresses" return fi
@@ -61,7 +61,7 @@ test_body() [ "$TST_IPV6" ] && local xymax=65535 || xymax=254 if [ $ROUTE_TOTAL -gt $((xymax * xymax)) ]; then - tst_resm TWARN "set ROUTE_TOTAL to $xymax * $xymax" + tst_res TWARN "set ROUTE_TOTAL to $xymax * $xymax" ROUTE_TOTAL=$((xymax * xymax)) fi
@@ -81,7 +81,7 @@ test_body() ip_cmd) ip route add ${new_rt}${opt_rt} dev $iface ;; esac if [ $? -ne 0 ]; then - tst_resm TFAIL "Can't add route $new_rt to $iface" + tst_res TFAIL "Can't add route $new_rt to $iface" return fi
@@ -93,19 +93,13 @@ test_body() y=1 x=$(($x + 1)) if [ $x -gt $xymax ]; then - tst_brkm TBROK "Too large $ROUTE_TOTAL" + tst_brk TBROK "Too large $ROUTE_TOTAL" fi fi done - tst_resm TPASS "Test is finished correctly" + tst_res TPASS "Test is finished correctly" } -netstress_setup - tst_check_cmds route - -test_body 'rt_cmd' -test_body 'ip_cmd' - -tst_exit +tst_run
testcases/network/stress/interface/if-updown +11 -16
@@ -1,5 +1,6 @@ #!/bin/sh # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # Copyright (c) International Business Machines Corp., 2005 # # This program is free software; you can redistribute it and/or
@@ -17,10 +18,10 @@ # # Author: Mitsuru Chinen <[email protected]> -TST_TOTAL=2 - +TST_CNT=2 +TST_SETUP="netstress_setup" TST_CLEANUP="netstress_cleanup" - +TST_TESTFUNC="test_if_ip" . test_net_stress.sh CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 20))}
@@ -32,13 +33,13 @@ test_body() case $cmd_type in if_cmd) local cmd_name='ifconfig' ;; ip_cmd) local cmd_name='ip' ;; - *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" + *) tst_brk TBROK "Unknown test parameter '$cmd_type'" esac local iface=$(tst_iface) - tst_resm TINFO "'$cmd_name ups/downs $iface $IF_UPDOWN_TIMES times" - tst_resm TINFO "check connectivity interval is $CHECK_INTERVAL" + tst_res TINFO "'$cmd_name ups/downs $iface $IF_UPDOWN_TIMES times" + tst_res TINFO "check connectivity interval is $CHECK_INTERVAL" local cnt=1 while [ $cnt -le $IF_UPDOWN_TIMES ]; do
@@ -47,7 +48,7 @@ test_body() ip_cmd) ip link set $iface down ;; esac if [ $? -ne 0 ]; then - tst_resm TFAIL "Failed to down $iface" + tst_res TFAIL "Failed to down $iface" return fi
@@ -56,7 +57,7 @@ test_body() ip_cmd) ip link set $iface up ;; esac if [ $? -ne 0 ]; then - tst_resm TFAIL "Failed to up $iface" + tst_res TFAIL "Failed to up $iface" return fi
@@ -65,14 +66,8 @@ test_body() cnt=$(($cnt + 1)) done - tst_resm TPASS "Test is finished correctly" + tst_res TPASS "Test is finished correctly" } -netstress_setup - tst_check_cmds ifconfig - -test_body 'if_cmd' -test_body 'ip_cmd' - -tst_exit +tst_run
testcases/network/stress/interface/if4-addr-change +14 -11
@@ -1,5 +1,6 @@ #!/bin/sh # Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # Copyright (c) International Business Machines Corp., 2005 # # This program is free software; you can redistribute it and/or
@@ -17,24 +18,29 @@ # # Author: Mitsuru Chinen <[email protected]> -TST_TOTAL=1 +TST_CNT=1 TCID=if4-addr-change +TST_SETUP="do_setup" TST_CLEANUP="do_cleanup" - -TST_USE_LEGACY_API=1 +TST_TESTFUNC="test_body" . test_net.sh CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))} # Maximum host portion of the IPv4 address on the local host LHOST_IPV4_HOST_MAX="254" +do_setup() +{ + tst_check_cmds ifconfig +} + do_cleanup() { tst_restore_ipaddr tst_wait_ipv6_dad } -trap "tst_brkm TBROK 'test interrupted'" INT +trap "tst_brk TBROK 'test interrupted'" INT test_body() {
@@ -42,7 +48,7 @@ test_body() local num=1 local add_to_net= - tst_resm TINFO "ifconfig changes IPv4 address $NS_TIMES times" + tst_res TINFO "ifconfig changes IPv4 address $NS_TIMES times" while [ $cnt -lt $NS_TIMES ]; do # Define the network portion
@@ -54,7 +60,7 @@ test_body() # check prefix and fix values for prefix != 24 add_to_net= if [ $IPV4_LPREFIX -lt 8 -o $IPV4_LPREFIX -ge 32 ] ; then - tst_brkm TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)" + tst_brk TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)" elif [ $IPV4_LPREFIX -lt 16 ]; then # N.x.x.num add_to_net=".0.1" elif [ $IPV4_LPREFIX -lt 24 ]; then # N.N.x.num
@@ -70,14 +76,11 @@ test_body() [ $CHECK_INTERVAL -eq 0 ] && continue [ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue - tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES" + tst_res TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES" tst_ping done tst_ping } -tst_check_cmds ifconfig -test_body - -tst_exit +tst_run
testcases/network/stress/multicast/grp-operation/mcast-group-multiple-socket +9 -7
@@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) International Business Machines Corp., 2006 -# Copyright (c) 2017 Petr Vorel <[email protected]> +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -21,19 +21,21 @@ . mcast-lib.sh -tst_resm TINFO "joining $MCASTNUM_HEAVY IPv$ipver multicast groups on multiple sockets" - do_setup() { # Increase the maximum number of open file descriptors if [ $(ulimit -n) -lt $MCASTNUM_HEAVY ]; then - ulimit -n $MCASTNUM_HEAVY || tst_brkm TCONF \ + ulimit -n $MCASTNUM_HEAVY || tst_brk TCONF \ "Failed to set the maximum number of open file descriptors to $MCASTNUM_HEAVY" fi mcast_setup $MCASTNUM_HEAVY } -do_setup -do_multicast_test_multiple_join $MCASTNUM_HEAVY true -tst_exit +do_test() +{ + tst_res TINFO "joining $MCASTNUM_HEAVY IPv$ipver multicast groups on multiple sockets" + do_multicast_test_multiple_join $MCASTNUM_HEAVY true +} + +tst_run
testcases/network/stress/multicast/grp-operation/mcast-group-same-group +12 -5
@@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) International Business Machines Corp., 2006 -# Copyright (c) 2017 Petr Vorel <[email protected]> +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -21,8 +21,15 @@ . mcast-lib.sh -tst_resm TINFO "joining and leaving the same IPv$ipver multicast group on $MCASTNUM_NORMAL sockets in $NS_TIMES times" +do_setup() +{ + mcast_setup $MCASTNUM_NORMAL +} -mcast_setup $MCASTNUM_NORMAL -do_multicast_test_join_leave $MCASTNUM_NORMAL -tst_exit +do_test() +{ + tst_res TINFO "joining and leaving the same IPv$ipver multicast group on $MCASTNUM_NORMAL sockets in $NS_TIMES times" + do_multicast_test_join_leave $MCASTNUM_NORMAL +} + +tst_run
testcases/network/stress/multicast/grp-operation/mcast-group-single-socket +12 -5
@@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) International Business Machines Corp., 2006 -# Copyright (c) 2017 Petr Vorel <[email protected]> +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -21,8 +21,15 @@ . mcast-lib.sh -tst_resm TINFO "joining $MCASTNUM_HEAVY IPv$ipver multicast groups on a single socket" +do_setup() +{ + mcast_setup $MCASTNUM_HEAVY +} -mcast_setup $MCASTNUM_HEAVY -do_multicast_test_multiple_join $MCASTNUM_HEAVY -tst_exit +do_test() +{ + tst_res TINFO "joining $MCASTNUM_HEAVY IPv$ipver multicast groups on a single socket" + do_multicast_test_multiple_join $MCASTNUM_HEAVY +} + +tst_run
testcases/network/stress/multicast/grp-operation/mcast-group-source-filter +12 -5
@@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) International Business Machines Corp., 2006 -# Copyright (c) 2017 Petr Vorel <[email protected]> +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -21,8 +21,15 @@ . mcast-lib.sh -tst_resm TINFO "joining and leaving the same IPv$ipver multicast group with a different source filters on $MCASTNUM_NORMAL sockets in $NS_TIMES times" +do_setup() +{ + mcast_setup $MCASTNUM_NORMAL +} -mcast_setup $MCASTNUM_NORMAL -do_multicast_test_join_leave $MCASTNUM_NORMAL true -tst_exit +do_test() +{ + tst_res TINFO "joining and leaving the same IPv$ipver multicast group with a different source filters on $MCASTNUM_NORMAL sockets in $NS_TIMES times" + do_multicast_test_join_leave $MCASTNUM_NORMAL true +} + +tst_run
testcases/network/stress/multicast/grp-operation/mcast-lib.sh +8 -7
@@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) International Business Machines Corp., 2006 -# Copyright (c) 2017 Petr Vorel <[email protected]> +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -19,9 +19,11 @@ # # Setup script for multicast stress tests. -TST_TOTAL=1 +TST_CNT=1 +TST_SETUP="do_setup" TST_CLEANUP="mcast_cleanup" - +TST_TESTFUNC="do_test" +TST_NEEDS_TMPDIR=1 . test_net_stress.sh MCAST_LCMD="ns-mcast_join -f $ipver -I $(tst_iface)"
@@ -39,7 +41,7 @@ mcast_setup4() SYSFS_FORCE_IGMP_VERSION=$(sysctl -b net.ipv4.conf.$(tst_iface).force_igmp_version) SYSFS_ALL_FORCE_IGMP_VERSION=$(sysctl -b net.ipv4.conf.all.force_igmp_version) - [ "$igmp_max_memberships" -gt 5459 ] && tst_resm TWARN \ + [ "$igmp_max_memberships" -gt 5459 ] && tst_res TWARN \ "\$1 shouldn't be set higher than 5459 as it's used to set /proc/sys/net/ipv4/igmp_max_memberships" ROD sysctl -qw net.ipv4.igmp_max_memberships=$igmp_max_memberships
@@ -67,7 +69,6 @@ mcast_setup() local max="$1" netstress_setup - tst_tmpdir [ "$TST_IPV6" ] && mcast_setup6 || mcast_setup4 $max }
@@ -110,7 +111,7 @@ do_multicast_test_multiple_join() # Run a multicast join tool tmpfile=$$ EXPECT_PASS $MCAST_LCMD $param_multi_socket -n $num -p $mprefix \> $tmpfile - tst_resm TINFO "joined $(grep groups $tmpfile)" + tst_res TINFO "joined $(grep groups $tmpfile)" # Send MLD / IGMP General Query from the remote host if [ "$TST_IPV6" ]; then
@@ -150,5 +151,5 @@ do_multicast_test_join_leave() wait - tst_resm TPASS "test is finished successfully" + tst_res TPASS "test is finished successfully" }
testcases/network/stress/ns-tools/test_net_stress.sh +20 -5
@@ -1,7 +1,7 @@ #!/bin/sh # Copyright (c) International Business Machines Corp., 2006 # Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved. -# Copyright (c) 2017 Petr Vorel <[email protected]> +# Copyright (c) 2017-2018 Petr Vorel <[email protected]> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -25,7 +25,6 @@ export TCID="${TCID:-$(basename $0)}" -TST_USE_LEGACY_API=1 . test_net.sh ipver=${TST_IPV6:-4}
@@ -43,9 +42,9 @@ MCAST_IPV6_ADDR="${MCAST_IPV6_ADDR_PREFIX}:1" # Setup for tests using netstress. netstress_setup() { - tst_require_root + TST_NEEDS_ROOT=1 tst_check_cmds pgrep pkill - trap "tst_brkm TBROK 'test interrupted'" INT + trap "tst_brk TBROK 'test interrupted'" INT } # Cleanup for tests using netstress.
@@ -86,7 +85,7 @@ check_connectivity() [ -n "$cnt" ] && cnt_msg=" (step $cnt)" - tst_resm TINFO "ping through $src_iface iface to ${dst_addr}$cnt_msg" + tst_res TINFO "ping through $src_iface iface to ${dst_addr}$cnt_msg" tst_ping $src_iface $dst_addr }
@@ -125,3 +124,19 @@ make_background_tcp_traffic() netstress -R 3 -g $port > /dev/null 2>&1 & tst_rhost_run -b -c "netstress -l -H $ip -g $port" } + +test_if_ip() +{ + case $1 in + 1) test_body 'if_cmd';; + 2) test_body 'ip_cmd';; + esac +} + +test_rt_ip() +{ + case $1 in + 1) test_body 'rt_cmd';; + 2) test_body 'ip_cmd';; + esac +}
Signature · 1 line
2.16.3
v2 cover Rewritting network tests into new shell API
In reply to Petr VorelQuoted 7 lines · Petr Vorel
Hi,
changes
v1->v2:
* Make new API default fortest_net.sh
* Rename variableTST_USE_NEW_API=>TST_USE_LEGACY_API
* Set TST_USE_LEGACY_API=1 in majority of network scripts.
Hi Petr,
A few questions about the changes to the new API:
I think, you wrote about renaming test_net.sh to tst_net.sh, and the corresponded test_net_stress.sh, so why we can't keep the copy to the old API during migration and make the new one with the new name?
What is actually changing in the new API that require the changes in test_net.sh except tst_resm/tst_brkm renamed to tst_res/tst_brk?
The new variables TST_NEEDS_ROOT and TST_SETUP, TST_TESTFUNC? Can we run a test without them temporary, without tst_run(), e.g. define some stubs and old API with the new one in tst_net.sh?
tst_exit()
{
tst_do_exit()
}
etc.
I remember that ROD function not using the script but tst_rod binary so may affect some scripts, like "ROD cd" for example... but may be it is already fixed, I need to check.
And we need to remove tst_rmdir() because it will be handled in the library as we already have TST_TMPDIR_RHOST there.
Best regards,
Alexey
Quoted 102 lines
NOTE: still kept the old script names.
I'm not happy with the state of
testscripts/network.sh. I kept it using the legacy API. I tried to migrate it into new API, but that would require too much changes (and I don't like to havetst_runcall intestscripts/network.sh).Kind regards,
PetrPetr Vorel (3):
test_net.sh: Support both old and new shell APIs network/interface: Cleanup if4-addr-change
net: Migratetest_net_stress.shand it's dependencies to new shell APItestcases/lib/test_net.sh | 133 +++++++++++++-------- testcases/lib/tst_test.sh | 1 + testcases/network/busy_poll/busy_poll01.sh | 1 + testcases/network/busy_poll/busy_poll02.sh | 1 + testcases/network/busy_poll/busy_poll03.sh | 1 + testcases/network/dccp/dccp01.sh | 1 + testcases/network/dctcp/dctcp01.sh | 1 + testcases/network/dhcp/dhcpd_tests.sh | 1 + testcases/network/dhcp/dnsmasq_tests.sh | 1 + testcases/network/iproute/ip_tests.sh | 1 + testcases/network/multicast/mc_cmds/mc_cmds | 1 + testcases/network/multicast/mc_commo/mc_commo | 1 + testcases/network/multicast/mc_member/mc_member | 1 + testcases/network/multicast/mc_opts/mc_opts | 1 + testcases/network/nfs/fsx-linux/fsx.sh | 1 + testcases/network/nfs/nfs_stress/nfs01 | 1 + testcases/network/nfs/nfs_stress/nfs02 | 1 + testcases/network/nfs/nfs_stress/nfs03 | 1 + testcases/network/nfs/nfs_stress/nfs04 | 1 + testcases/network/nfs/nfs_stress/nfs05 | 1 + testcases/network/nfs/nfs_stress/nfs06 | 1 + testcases/network/nfs/nfslock01/nfslock01 | 1 + testcases/network/nfs/nfsstat01/nfsstat01 | 1 + testcases/network/rpc/basic_tests/rpc01/rpc01 | 1 + .../network/rpc/basic_tests/rpcinfo/rpcinfo01 | 1 + testcases/network/rpc/basic_tests/rup/rup01 | 1 + testcases/network/rpc/basic_tests/rusers/rusers01 | 1 + testcases/network/rpc/rpc-tirpc/rpc_test.sh | 1 + testcases/network/sctp/sctp01.sh | 1 + testcases/network/sockets/bind_noport01.sh | 1 + .../network/stress/broken_ip/broken_ip4-checksum | 1 + .../network/stress/broken_ip/broken_ip4-dstaddr | 1 + .../network/stress/broken_ip/broken_ip4-fragment | 1 + testcases/network/stress/broken_ip/broken_ip4-ihl | 1 + .../network/stress/broken_ip/broken_ip4-protcol | 1 + .../network/stress/broken_ip/broken_ip4-totlen | 1 + .../network/stress/broken_ip/broken_ip4-version | 1 + .../network/stress/broken_ip/broken_ip6-dstaddr | 1 + .../network/stress/broken_ip/broken_ip6-nexthdr | 1 + testcases/network/stress/broken_ip/broken_ip6-plen | 1 + .../network/stress/broken_ip/broken_ip6-version | 1 + testcases/network/stress/dns/dns-stress | 1 + testcases/network/stress/ftp/ftp-download-stress | 1 + testcases/network/stress/ftp/ftp-upload-stress | 1 + testcases/network/stress/http/http-stress | 1 + testcases/network/stress/interface/if-addr-adddel | 31 ++--- .../network/stress/interface/if-addr-addlarge | 37 +++--- testcases/network/stress/interface/if-mtu-change | 24 ++-- testcases/network/stress/interface/if-route-adddel | 26 ++-- .../network/stress/interface/if-route-addlarge | 28 ++--- testcases/network/stress/interface/if-updown | 27 ++--- testcases/network/stress/interface/if4-addr-change | 74 +++++++----- testcases/network/stress/ipsec/ipsec_lib.sh | 1 + .../grp-operation/mcast-group-multiple-socket | 16 +-- .../multicast/grp-operation/mcast-group-same-group | 17 ++- .../grp-operation/mcast-group-single-socket | 17 ++- .../grp-operation/mcast-group-source-filter | 17 ++- .../stress/multicast/grp-operation/mcast-lib.sh | 15 +-- .../network/stress/ns-tools/test_net_stress.sh | 24 +++- testcases/network/stress/ssh/ssh-stress | 1 + testcases/network/tcp_cmds/arping/arping01.sh | 1 + .../network/tcp_cmds/clockdiff/clockdiff01.sh | 1 + testcases/network/tcp_cmds/ipneigh/ipneigh01.sh | 1 + testcases/network/tcp_cmds/ping/ping01.sh | 1 + testcases/network/tcp_cmds/ping/ping02.sh | 1 + testcases/network/tcp_cmds/rlogin/rlogin01 | 1 + testcases/network/tcp_cmds/sendfile/sendfile01 | 1 + testcases/network/tcp_cmds/tcpdump/tcpdump01 | 1 + testcases/network/tcp_cmds/telnet/telnet01 | 1 + .../network/tcp_cmds/tracepath/tracepath01.sh | 1 + testcases/network/tcp_fastopen/tcp_fastopen_run.sh | 1 + testcases/network/traceroute/traceroute01.sh | 1 + testcases/network/virt/geneve01.sh | 1 + testcases/network/virt/gre01.sh | 1 + testcases/network/virt/ipvlan01.sh | 1 + testcases/network/virt/macvlan01.sh | 1 + testcases/network/virt/macvtap01.sh | 1 + testcases/network/virt/vlan01.sh | 1 + testcases/network/virt/vlan02.sh | 1 + testcases/network/virt/vlan03.sh | 1 + testcases/network/virt/vxlan01.sh | 1 + testcases/network/virt/vxlan02.sh | 1 + testcases/network/virt/vxlan03.sh | 1 + testcases/network/xinetd/xinetd_tests.sh | 1 + testscripts/network.sh | 4 +- 85 files changed, 340 insertions(+), 220 deletions(-)
v2 cover Rewritting network tests into new shell API
Hi Alexey,
thanks for your comments!
Quoted 7 lines
Hi Petr,
A few questions about the changes to the new API:
I think, you wrote about renaming
test_net.shtotst_net.sh, and the correspondedtest_net_stress.sh, so why we can't keep the copy to the old API during migration and make the new one with the new name?
That's another option, but I thought, it'd be easier to have just one version of test_net.sh which supports both APIs, than maintain two files (test_net.sh and tst_net.sh). But I might be wrong.
Quoted 4 lines
What is actually changing in the new API that require the changes in
test_net.shexcept tst_resm/tst_brkm renamed to tst_res/tst_brk?The new variables
TST_NEEDS_ROOTandTST_SETUP,TST_TESTFUNC?
Yes (you list all or most of them in your reply below) + the need to call tst_run().
I did most of the changes with simple script using sed (manual fixes are still needed).
tst_run() is the biggest change in the behavior, which complicates migrating of testscripts/network.sh. I haven't figured out, what would be an elegant way to move it and I'd prefer to migrate it into new version. Not sure whether we'd like to add part of "network_settings" execution to tst_run() for tst_net.sh and thus to be run twice (once by testscripts/network.sh and then by test which is called by testscripts/network.sh).
Now I see the best would be move this "network_settings" stuff into new called function tst_net_run() which would set it and at the end call tst_run() + remove sourcing test_net.sh in testscripts/network.sh (only testing script would load it and call tst_net_run() at the end instead of tst_run()).
Quoted 3 lines
Can we run a test without them temporary, without
tst_run(), e.g. define some stubs and old API with the new one intst_net.sh?
Do you mean to move all network scripts to new API, using these "shim" in tst_net.sh? I'd prefer tests were really using new API (to benefit from it), I just don't want to migrate all tests at once. This can be dangerous trying to implement new API functions in legacy one.
That's why I implemented in tst_net.sh functions starting with underscore which choose the implementation via $TST_USE_LEGACY_API. I wanted to ony tst_net.sh itself using it.
Quoted 9 lines
tst_exit(){ tst_do_exit() }etc.
I remember that ROD function not using the script but
tst_rodbinary so may affect some scripts, like "ROD cd" for example... but may be it is already fixed, I need to check.
Git log shows it's not fixed. Good point. (s/ROD cd /cd /g)
Quoted 2 lines
And we need to remove
tst_rmdir()because it will be handled in the library as we already haveTST_TMPDIR_RHOSTthere.
Yes, I handled it in test_net.sh and during rewrite.
Quoted 2 lines
Best regards,
Alexey
Kind regards,
Petr
v2 cover Rewritting network tests into new shell API
Quoted 29 lines · Petr Vorel
Hi Alexey,
thanks for your comments!
Quoted 7 lines
Hi Petr,
A few questions about the changes to the new API:
I think, you wrote about renaming
test_net.shtotst_net.sh, and the correspondedtest_net_stress.sh, so why we can't keep the copy to the old API during migration and make the new one with the new name?That's another option, but I thought, it'd be easier to have just one version of
test_net.shwhich supports both APIs, than maintain two files (test_net.shandtst_net.sh). But I might be wrong.Quoted 4 lines
What is actually changing in the new API that require the changes in
test_net.shexcept tst_resm/tst_brkm renamed to tst_res/tst_brk?The new variables
TST_NEEDS_ROOTandTST_SETUP,TST_TESTFUNC?Yes (you list all or most of them in your reply below) + the need to call
tst_run().I did most of the changes with simple script using sed (manual fixes are still needed).
tst_run()is the biggest change in the behavior, which complicates migrating oftestscripts/network.sh. I haven't figured out, what would be an elegant way to move it and I'd prefer to migrate it into new version. Not sure whether we'd like to add part of "network_settings" execution totst_run()fortst_net.shand thus to be run twice (once bytestscripts/network.shand then by test which is called bytestscripts/network.sh).
Quoted 4 lines
Now I see the best would be move this "
network_settings" stuff into new called functiontst_net_run()which would set it and at the end calltst_run()+ remove sourcingtest_net.shintestscripts/network.sh(only testing script would load it and calltst_net_run()at the end instead oftst_run()).
Hi Petr,
I think we need to add a new flag, similar to LTP C library that can define TST_NO_DEFAULT_MAIN, i.e. we could add TST_NO_DEFAULT_RUN in the tst_test.sh.
Quoted 8 lines
Quoted 4 lines
Can we run a test without them temporary, without
tst_run(), e.g. define some stubs and old API with the new one intst_net.sh?Do you mean to move all network scripts to new API, using these "shim" in
tst_net.sh? I'd prefer tests were really using new API (to benefit from it), I just don't want to migrate all tests at once. This can be dangerous trying to implement new API functions in legacy one.> That's why I implemented intst_net.shfunctions starting with underscore which choose the
It's better to place underscore in the end of a function.
Quoted 2 lines
implementation via $TST_USE_LEGACY_API. I wanted to ony
tst_net.shitself using it.
Thanks,
Alexey
v2 cover Rewritting network tests into new shell API
Hi Alexey,
again, thanks for your comments.
...
Quoted 11 lines
Quoted 10 lines
tst_run()is the biggest change in the behavior, which complicates migrating oftestscripts/network.sh. I haven't figured out, what would be an elegant way to move it and I'd prefer to migrate it into new version. Not sure whether we'd like to add part of "network_settings" execution totst_run()fortst_net.shand thus to be run twice (once bytestscripts/network.shand then by test which is called bytestscripts/network.sh).Now I see the best would be move this "
network_settings" stuff into new called functiontst_net_run()which would set it and at the end calltst_run()+ remove sourcingtest_net.shintestscripts/network.sh(only testing script would load it and calltst_net_run()at the end instead oftst_run()).
Quoted 5 lines
Hi Petr,
I think we need to add a new flag, similar to LTP C library that can define
TST_NO_DEFAULT_MAIN, i.e. we could addTST_NO_DEFAULT_RUNin thetst_test.sh.
I was thinking about it as well, while trying to implement it.
ATM network.sh is for handling getopts and setting environment variables. I was even thinking whether
1) get rid of it at all
2) have network settings as "first test". This is the concept of tst_net_run(), I described previously.
1) is probably not a good idea, as separation of functions in test_net.sh and using it in network.sh is probably useful), but sourcing test_net.sh twice and handling correctly getopts for tst_test.sh make things a bit complicated.
I'll try to come up with some solution in v3 (+ rename tests, as I wrote).
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
Can we run a test without them temporary, without
tst_run(), e.g. define some stubs and old API with the new one intst_net.sh?Do you mean to move all network scripts to new API, using these "shim" in
tst_net.sh? I'd prefer tests were really using new API (to benefit from it), I just don't want to migrate all tests at once. This can be dangerous trying to implement new API functions in legacy one.> That's why I implemented intst_net.shfunctions starting with underscore which choose theIt's better to place underscore in the end of a function.
OK, I changed them.
I used them at the beginning as the same is for kernel / glibc internal (well, they have it doubled).
I hope the migration of all network scripts will not take months, so it should be something temporary.
Quoted 4 lines
Quoted 1 line
implementation via $TST_USE_LEGACY_API. I wanted to ony
tst_net.shitself using it.Thanks,
Alexey
Kind regards,
Petr