similarity index 86%
rename from testcases/lib/test_net.sh
rename to testcases/lib/tst_net.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
-# Copyright (c) 2016-2017 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2016-2018 Petr Vorel <pvorel@suse.cz>
#
# 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,74 @@
# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
#
-[ -z "$TST_LIB_LOADED" ] && . test.sh
+TST_OPTS="6$TST_OPTS"
+TST_PARSE_ARGS_CALLER="$TST_PARSE_ARGS"
+TST_PARSE_ARGS="tst_net_parse_args"
+TST_USAGE_CALLER="$TST_USAGE"
+TST_USAGE="tst_net_usage"
+TST_SETUP_CALLER="$TST_SETUP"
+TST_SETUP="tst_net_setup"
+
+# Blank for an IPV4 test; 6 for an IPV6 test.
+TST_IPV6=
+
+tst_net_parse_args()
+{
+ case $1 in
+ 6) TST_IPV6=6;;
+ *) $TST_PARSE_ARGS_CALLER "$1" "$2";;
+ esac
+}
+
+tst_read_opts()
+{
+ local OPTIND
+ while getopts "$TST_OPTS" opt; do
+ $TST_PARSE_ARGS "$opt"
+ done
+}
+
+tst_net_usage()
+{
+ if [ -n "$TST_USAGE_CALLER" ]; then
+ $TST_USAGE_CALLER
+ else
+ echo "Usage: $0 [-6]"
+ echo "OPTIONS"
+ fi
+ echo "-6 IPv6 tests"
+}
+
+tst_net_setup()
+{
+ ipver=${TST_IPV6:-4}
+ [ -n "$TST_SETUP_CALLER" ] && $TST_SETUP_CALLER
+}
+
+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 +143,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 +151,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 +172,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 +184,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 +194,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 +262,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 +347,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 +385,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 +401,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 +435,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 +488,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 +500,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 +561,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 +603,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
@@ -597,7 +642,7 @@ tst_cleanup_rhost()
[ -z "$RHOST" ] && TST_USE_NETNS="yes"
export RHOST="$RHOST"
export PASSWD="${PASSWD:-}"
-# Don't use it in new tests, use tst_rhost_run() from test_net.sh instead.
+# Don't use it in new tests, use tst_rhost_run() from tst_net.sh instead.
export LTP_RSH="${LTP_RSH:-rsh -n}"
# Test Links
@@ -644,10 +689,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 +732,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
@@ -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
@@ -68,7 +68,7 @@ Testcases and network tools must be in PATH, e.g.:
```sh
export PATH=/opt/ltp/testcases/bin:/usr/bin:$PATH
```
-Default values for all LTP network variables are set in testcases/lib/test_net.sh.
+Default values for all LTP network variables are set in testcases/lib/tst_net.sh.
If you need to override some parameters please export them before test run or
specify them when running ltp-pan or testscripts/network.sh.
@@ -79,7 +79,7 @@ To run the test type the following:
TEST_VARS ./network.sh OPTIONS
```
Where
-* TEST_VARS - non-default network parameters (see testcases/lib/test_net.sh), they
+* TEST_VARS - non-default network parameters (see testcases/lib/tst_net.sh), they
could be exported before test run;
* OPTIONS - test group(s), use '-h' to see available ones.
@@ -21,7 +21,8 @@ TST_TOTAL=1
TCID="busy_poll01"
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. busy_poll_lib.sh
cleanup()
@@ -21,7 +21,8 @@ TST_TOTAL=1
TCID="busy_poll02"
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. busy_poll_lib.sh
cleanup()
@@ -21,7 +21,8 @@ TST_TOTAL=2
TCID="busy_poll03"
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. busy_poll_lib.sh
cleanup()
@@ -21,7 +21,8 @@ TST_TOTAL=3
TST_CLEANUP="cleanup"
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
cleanup()
{
@@ -23,7 +23,8 @@ TST_NEEDS_TMPDIR=1
def_alg="cubic"
prev_alg=
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
set_cong_alg()
{
@@ -24,7 +24,8 @@ TST_TOTAL=1
TCID="dhcpd"
dhcp_name="dhcpd"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. dhcp_lib.sh
setup_dhcpd_conf()
@@ -22,7 +22,8 @@ TST_TOTAL=1
TCID="dnsmasq"
dhcp_name="dnsmasq"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. dhcp_lib.sh
start_dhcp()
@@ -24,7 +24,8 @@ TST_CLEANUP=cleanup
TST_TOTAL=6
TCID="ip_tests"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
rm_dummy=
@@ -29,7 +29,8 @@
TCID=mc_cmds
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
knob="net.ipv4.icmp_echo_ignore_broadcasts"
knob_changed=
@@ -31,7 +31,8 @@ OUTFILE=mc_commo_out
TCID=mc_commo
TST_TOTAL=2
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup()
{
@@ -33,7 +33,8 @@ TCID=mc_member
TST_TOTAL=1
TST_COUNT=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
setup()
{
@@ -32,7 +32,8 @@ EXECUTABLES=${EXECUTABLES:-"mc_verify_opts mc_verify_opts_error"}
TCID=mc_opts
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
COUNT=1
while [ $COUNT -le 10 ]; do
@@ -26,7 +26,8 @@ TST_TOTAL=1
TST_CLEANUP="nfs_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_test()
{
@@ -25,7 +25,8 @@ TST_TOTAL=1
TST_CLEANUP="nfs_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_test()
{
@@ -25,7 +25,8 @@ TST_TOTAL=3
TST_CLEANUP="nfs_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_test1()
{
@@ -25,7 +25,8 @@ TST_TOTAL=1
TST_CLEANUP="nfs03_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
DIR_NUM=${DIR_NUM:-"100"}
FILE_NUM=${FILE_NUM:-"100"}
@@ -28,7 +28,8 @@ TST_TOTAL=1
TST_CLEANUP="nfs_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
nfs_setup
@@ -29,7 +29,8 @@ FILE_NUM=${FILE_NUM:-"50"}
THREAD_NUM=${THREAD_NUM:-"8"}
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_check_cmds make gcc
@@ -25,7 +25,8 @@ TST_TOTAL=1
TST_CLEANUP="nfs_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_test()
{
@@ -26,7 +26,8 @@ TST_TOTAL=1
TST_CLEANUP="nfs_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
LUSER=${LUSER:=root}
@@ -22,7 +22,8 @@ TST_TOTAL=4
TST_CLEANUP="nfs_cleanup"
. nfs_lib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
setup()
{
@@ -19,7 +19,8 @@ TCID="rpc01"
TST_TOTAL=6
TST_CLEANUP=do_cleanup
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
NUMLOOPS=${NUMLOOPS:=3}
DATAFILES=${DATAFILES:="file.1 file.2"}
@@ -19,7 +19,8 @@ TCID="rpcinfo01"
TST_TOTAL=16
TST_CLEANUP=tst_rmdir
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup()
{
@@ -18,7 +18,8 @@
TCID="rup01"
TST_TOTAL=7
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup()
{
@@ -18,7 +18,8 @@
TCID="rusers01"
TST_TOTAL=5
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup()
{
@@ -82,7 +82,8 @@ TST_TOTAL=1
TST_COUNT=1
TST_CLEANUP=cleanup
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
if [ ! -z "$SERVER" ]; then
$SERVER $PROGNUMNOSVC &
@@ -21,7 +21,8 @@ TST_TOTAL=4
TST_CLEANUP="cleanup"
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
cleanup()
{
@@ -18,7 +18,8 @@ TST_TOTAL=1
TCID="bind_noport"
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
cleanup()
{
@@ -21,7 +21,8 @@
TCID=broken_ip4-checksum01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong chksum field for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip4-dstaddr01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong dst address for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip4-fragment01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong frag. info for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip4-ihl01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong header len field for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip4-protocol01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong proto field for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip4-totlen01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong total len field for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip4-version01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong version field for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip6-dstaddr01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv6 with wrong dst address for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip6-nexthdr01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong next header for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip6-plen01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv4 with wrong payload len for $NS_DURATION sec"
@@ -21,7 +21,8 @@
TCID=broken_ip6-version01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_resm TINFO "Sending ICMPv6 with wrong version field for $NS_DURATION sec"
@@ -22,7 +22,8 @@ TCID=dns-stress
TST_TOTAL=2
TST_CLEANUP="cleanup"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
# Minimum host ID in the zone file.
# The ID is used as the host portion of the address
@@ -23,7 +23,8 @@ TCID=ftp-download-stress
TST_TOTAL=2
TST_CLEANUP="cleanup"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
# Big file size to upload/download in ftp tests (byte)
DOWNLOAD_BIGFILESIZE=${DOWNLOAD_BIGFILESIZE:-2147483647}
@@ -23,7 +23,8 @@ TCID=ftp-upload-stress
TST_TOTAL=2
TST_CLEANUP="cleanup"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
# Big file size to upload (byte)
UPLOAD_BIGFILESIZE=${UPLOAD_BIGFILESIZE:-2147483647} # 2GB - 1
@@ -23,7 +23,8 @@ TCID=http-stress
TST_TOTAL=2
TST_CLEANUP="cleanup"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
cleanup()
{
@@ -21,7 +21,8 @@ TST_TOTAL=1
TCID=if4-addr-change
TST_CLEANUP="do_cleanup"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
# Maximum host portion of the IPv4 address on the local host
@@ -19,7 +19,8 @@
#
#######################################################################
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
# Authenticated encryption with associated data
AEALGO="rfc4106_128"
@@ -21,11 +21,12 @@
#
# Library for all network/stress/ tests.
# NOTE: More information about network variables can be found
-# in test_net.sh and testcases/network/stress/README.
+# in tst_net.sh and testcases/network/stress/README.
export TCID="${TCID:-$(basename $0)}"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
ipver=${TST_IPV6:-4}
@@ -24,7 +24,8 @@ TCID=ssh-stress
TST_TOTAL=3
TST_CLEANUP="cleanup"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
# Temporary directory to store sshd setting or ssh key
# Note: ssh doesn't work when those directory is under /tmp.
@@ -18,7 +18,8 @@
TCID=arping01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_require_root
tst_check_cmds arping
@@ -18,7 +18,8 @@
TCID=clockdiff01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
tst_require_root
tst_check_cmds cut clockdiff
@@ -19,7 +19,8 @@
TCID=ipneigh01
NUMLOOPS=${NUMLOOPS:-50}
TST_TOTAL=2
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup()
{
@@ -28,7 +28,8 @@
TST_TOTAL=10
TCID="ping01"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup()
{
@@ -17,7 +17,8 @@
TST_TOTAL=10
TCID="ping02"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup()
{
@@ -20,7 +20,8 @@
TCID="rlogin01"
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
setup()
{
@@ -102,7 +102,8 @@ do_cleanup()
tst_rmdir
}
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup
do_test
@@ -64,7 +64,8 @@ do_cleanup()
tst_rmdir
}
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
do_setup
do_test
@@ -20,7 +20,8 @@
TCID="telnet01"
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
setup()
{
@@ -18,7 +18,8 @@
TCID=tracepath01
TST_TOTAL=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
test_tracepath()
{
@@ -23,7 +23,8 @@ TST_TOTAL=1
TCID="tcp_fastopen"
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
while getopts :hr:n:R:6 opt; do
case "$opt" in
@@ -19,7 +19,8 @@ TST_TOTAL=6
TCID="traceroute01"
TST_CLEANUP="cleanup"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
cleanup()
{
@@ -27,7 +27,8 @@ start_id=16700000
# that is why using here 'vxlan_*' library functions.
vxlan_dst_addr="uni"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-160}
@@ -24,7 +24,8 @@ TCID=gre01
TST_TOTAL=1
TST_NEEDS_TMPDIR=1
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
virt_type="gre"
[ "$TST_IPV6" ] && virt_type="ip6gre"
@@ -24,7 +24,8 @@ TST_TOTAL=2
virt_type="ipvlan"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
options="mode l2,mode l3"
@@ -24,7 +24,8 @@ TST_TOTAL=4
virt_type="macvlan"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
options="mode private,mode vepa,mode bridge,mode passthru"
@@ -24,7 +24,8 @@ TST_TOTAL=4
virt_type="macvtap"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
options="mode private,mode vepa,mode bridge,mode passthru"
@@ -24,7 +24,8 @@ TST_TOTAL=9
virt_type="vlan"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
p0="protocol 802.1Q"
@@ -25,7 +25,8 @@ TST_TOTAL=1
virt_type="vlan"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
virt_add_delete_test "id 4094"
@@ -29,7 +29,8 @@ TST_NEEDS_TMPDIR=1
virt_type="vlan"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
TST_CLEANUP="virt_cleanup"
@@ -25,7 +25,8 @@ TST_TOTAL=5
virt_type="vxlan"
start_id=16700000
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
options="l2miss l3miss,norsc nolearning noproxy,\
@@ -26,7 +26,8 @@ TST_TOTAL=1
virt_type="vxlan"
start_id=16700000
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
[ "$TST_IPV6" ] && mult_addr="ff02::abc" || mult_addr="239.1.1.1"
@@ -33,7 +33,8 @@ start_id=16700000
# Destination address, can be unicast or multicast address
vxlan_dst_addr="uni"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
. virt_lib.sh
# In average cases (with small packets less then 150 bytes) VxLAN slower
@@ -20,7 +20,8 @@ TST_TOTAL=2
TST_CLEANUP="cleanup"
. daemonlib.sh
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_net.sh
setup()
{
@@ -84,16 +84,17 @@ if [ "$OPTIND" -eq 1 ]; then
usage
exit 1
fi
+shift $(($OPTIND - 1))
TST_TOTAL=1
TCID="network_settings"
-. test_net.sh
+TST_USE_LEGACY_API=1
+. tst_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
The new name states that library supports new API. 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). New API requires merging tst_net.sh getopts handling with the test's one (if there is any). Define ipver variable in tst_net.sh setup function. ipver is commonly used in tests, but for new API it needs to be set after setting TST_IPV6 variable (after parsing getopts), i.e. in function defined by TST_SETUP. Thus in scripts using new API TST_IPV6 and ipver must not be used in test scripts outside setup/run/cleanup functions as they're not set (and ipver should be removed from these scripts). Filter out TST_IPV6 variable in tst_test.sh. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- testcases/lib/{test_net.sh => tst_net.sh} | 147 ++++++++++++++------- testcases/lib/tst_test.sh | 1 + testcases/network/README.md | 4 +- testcases/network/busy_poll/busy_poll01.sh | 3 +- testcases/network/busy_poll/busy_poll02.sh | 3 +- testcases/network/busy_poll/busy_poll03.sh | 3 +- testcases/network/dccp/dccp01.sh | 3 +- testcases/network/dctcp/dctcp01.sh | 3 +- testcases/network/dhcp/dhcpd_tests.sh | 3 +- testcases/network/dhcp/dnsmasq_tests.sh | 3 +- testcases/network/iproute/ip_tests.sh | 3 +- testcases/network/multicast/mc_cmds/mc_cmds | 3 +- testcases/network/multicast/mc_commo/mc_commo | 3 +- testcases/network/multicast/mc_member/mc_member | 3 +- testcases/network/multicast/mc_opts/mc_opts | 3 +- testcases/network/nfs/fsx-linux/fsx.sh | 3 +- testcases/network/nfs/nfs_stress/nfs01 | 3 +- testcases/network/nfs/nfs_stress/nfs02 | 3 +- testcases/network/nfs/nfs_stress/nfs03 | 3 +- testcases/network/nfs/nfs_stress/nfs04 | 3 +- testcases/network/nfs/nfs_stress/nfs05 | 3 +- testcases/network/nfs/nfs_stress/nfs06 | 3 +- testcases/network/nfs/nfslock01/nfslock01 | 3 +- testcases/network/nfs/nfsstat01/nfsstat01 | 3 +- testcases/network/rpc/basic_tests/rpc01/rpc01 | 3 +- .../network/rpc/basic_tests/rpcinfo/rpcinfo01 | 3 +- testcases/network/rpc/basic_tests/rup/rup01 | 3 +- testcases/network/rpc/basic_tests/rusers/rusers01 | 3 +- testcases/network/rpc/rpc-tirpc/rpc_test.sh | 3 +- testcases/network/sctp/sctp01.sh | 3 +- testcases/network/sockets/bind_noport01.sh | 3 +- .../network/stress/broken_ip/broken_ip4-checksum | 3 +- .../network/stress/broken_ip/broken_ip4-dstaddr | 3 +- .../network/stress/broken_ip/broken_ip4-fragment | 3 +- testcases/network/stress/broken_ip/broken_ip4-ihl | 3 +- .../network/stress/broken_ip/broken_ip4-protcol | 3 +- .../network/stress/broken_ip/broken_ip4-totlen | 3 +- .../network/stress/broken_ip/broken_ip4-version | 3 +- .../network/stress/broken_ip/broken_ip6-dstaddr | 3 +- .../network/stress/broken_ip/broken_ip6-nexthdr | 3 +- testcases/network/stress/broken_ip/broken_ip6-plen | 3 +- .../network/stress/broken_ip/broken_ip6-version | 3 +- testcases/network/stress/dns/dns-stress | 3 +- testcases/network/stress/ftp/ftp-download-stress | 3 +- testcases/network/stress/ftp/ftp-upload-stress | 3 +- testcases/network/stress/http/http-stress | 3 +- testcases/network/stress/interface/if4-addr-change | 3 +- testcases/network/stress/ipsec/ipsec_lib.sh | 3 +- .../network/stress/ns-tools/test_net_stress.sh | 5 +- testcases/network/stress/ssh/ssh-stress | 3 +- testcases/network/tcp_cmds/arping/arping01.sh | 3 +- .../network/tcp_cmds/clockdiff/clockdiff01.sh | 3 +- testcases/network/tcp_cmds/ipneigh/ipneigh01.sh | 3 +- testcases/network/tcp_cmds/ping/ping01.sh | 3 +- testcases/network/tcp_cmds/ping/ping02.sh | 3 +- testcases/network/tcp_cmds/rlogin/rlogin01 | 3 +- testcases/network/tcp_cmds/sendfile/sendfile01 | 3 +- testcases/network/tcp_cmds/tcpdump/tcpdump01 | 3 +- testcases/network/tcp_cmds/telnet/telnet01 | 3 +- .../network/tcp_cmds/tracepath/tracepath01.sh | 3 +- testcases/network/tcp_fastopen/tcp_fastopen_run.sh | 3 +- testcases/network/traceroute/traceroute01.sh | 3 +- testcases/network/virt/geneve01.sh | 3 +- testcases/network/virt/gre01.sh | 3 +- testcases/network/virt/ipvlan01.sh | 3 +- testcases/network/virt/macvlan01.sh | 3 +- testcases/network/virt/macvtap01.sh | 3 +- testcases/network/virt/vlan01.sh | 3 +- testcases/network/virt/vlan02.sh | 3 +- testcases/network/virt/vlan03.sh | 3 +- testcases/network/virt/vxlan01.sh | 3 +- testcases/network/virt/vxlan02.sh | 3 +- testcases/network/virt/vxlan03.sh | 3 +- testcases/network/xinetd/xinetd_tests.sh | 3 +- testscripts/network.sh | 7 +- 75 files changed, 246 insertions(+), 128 deletions(-) rename testcases/lib/{test_net.sh => tst_net.sh} (86%)