Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/net/if_vlan tests: reduce repeated phrases... (NFC)



details:   https://anonhg.NetBSD.org/src/rev/3010b6c35e47
branches:  trunk
changeset: 446468:3010b6c35e47
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Dec 07 09:28:31 2018 +0000

description:
tests: reduce repeated phrases... (NFC)

diffstat:

 tests/net/if_vlan/t_vlan.sh |  292 ++++++++++++++++++++++---------------------
 1 files changed, 151 insertions(+), 141 deletions(-)

diffs (truncated from 513 to 300 lines):

diff -r cce1d1d66f5e -r 3010b6c35e47 tests/net/if_vlan/t_vlan.sh
--- a/tests/net/if_vlan/t_vlan.sh       Fri Dec 07 09:11:04 2018 +0000
+++ b/tests/net/if_vlan/t_vlan.sh       Fri Dec 07 09:28:31 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_vlan.sh,v 1.12 2018/11/14 05:07:48 knakahara Exp $
+#      $NetBSD: t_vlan.sh,v 1.13 2018/12/07 09:28:31 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -45,43 +45,45 @@
 
 vlan_create_destroy_body_common()
 {
+       local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
+
        export RUMP_SERVER=${SOCK_LOCAL}
 
-       atf_check -s exit:0 rump.ifconfig vlan0 create
-       atf_check -s exit:0 rump.ifconfig vlan0 destroy
+       $atf_ifconfig vlan0 create
+       $atf_ifconfig vlan0 destroy
 
-       atf_check -s exit:0 rump.ifconfig vlan0 create
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig vlan0 down
-       atf_check -s exit:0 rump.ifconfig vlan0 destroy
+       $atf_ifconfig vlan0 create
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig vlan0 down
+       $atf_ifconfig vlan0 destroy
 
-       atf_check -s exit:0 rump.ifconfig shmif0 create
-       atf_check -s exit:0 rump.ifconfig vlan0 create
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 1 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig vlan0 destroy
+       $atf_ifconfig shmif0 create
+       $atf_ifconfig vlan0 create
+       $atf_ifconfig vlan0 vlan 1 vlanif shmif0
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig vlan0 destroy
 
        # more than one vlan interface with a same parent interface
-       atf_check -s exit:0 rump.ifconfig shmif1 create
-       atf_check -s exit:0 rump.ifconfig vlan0 create
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan1 create
-       atf_check -s exit:0 rump.ifconfig vlan1 vlan 11 vlanif shmif0
+       $atf_ifconfig shmif1 create
+       $atf_ifconfig vlan0 create
+       $atf_ifconfig vlan0 vlan 10 vlanif shmif0
+       $atf_ifconfig vlan1 create
+       $atf_ifconfig vlan1 vlan 11 vlanif shmif0
 
        # more than one interface with another parent interface
-       atf_check -s exit:0 rump.ifconfig vlan2 create
-       atf_check -s exit:0 rump.ifconfig vlan2 vlan 12 vlanif shmif1
-       atf_check -s exit:0 rump.ifconfig vlan3 create
-       atf_check -s exit:0 rump.ifconfig vlan3 vlan 13 vlanif shmif1
-       atf_check -s exit:0 rump.ifconfig shmif0 destroy
+       $atf_ifconfig vlan2 create
+       $atf_ifconfig vlan2 vlan 12 vlanif shmif1
+       $atf_ifconfig vlan3 create
+       $atf_ifconfig vlan3 vlan 13 vlanif shmif1
+       $atf_ifconfig shmif0 destroy
        atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig vlan0
        atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig vlan1
        atf_check -s exit:0 -o match:'shmif1' rump.ifconfig vlan2
        atf_check -s exit:0 -o match:'shmif1' rump.ifconfig vlan3
-       atf_check -s exit:0 rump.ifconfig vlan0 destroy
-       atf_check -s exit:0 rump.ifconfig vlan1 destroy
-       atf_check -s exit:0 rump.ifconfig vlan2 destroy
-       atf_check -s exit:0 rump.ifconfig vlan3 destroy
+       $atf_ifconfig vlan0 destroy
+       $atf_ifconfig vlan1 destroy
+       $atf_ifconfig vlan2 destroy
+       $atf_ifconfig vlan3 destroy
 
 }
 
@@ -133,6 +135,7 @@
 
 vlan_basic_body_common()
 {
+       local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
        local outfile=./out
        local af=inet
        local prefix=24
@@ -152,23 +155,23 @@
        rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
 
        export RUMP_SERVER=$SOCK_LOCAL
-       atf_check -s exit:0 rump.ifconfig shmif0 up
+       $atf_ifconfig shmif0 up
        export RUMP_SERVER=$SOCK_REMOTE
-       atf_check -s exit:0 rump.ifconfig shmif0 up
+       $atf_ifconfig shmif0 up
 
        export RUMP_SERVER=$SOCK_LOCAL
-       atf_check -s exit:0 rump.ifconfig vlan0 create
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig -w 10
+       $atf_ifconfig vlan0 create
+       $atf_ifconfig vlan0 vlan 10 vlanif shmif0
+       $atf_ifconfig vlan0 $af $local0/$prefix
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig -w 10
 
        export RUMP_SERVER=$SOCK_REMOTE
-       atf_check -s exit:0 rump.ifconfig vlan0 create
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $af $remote0/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig -w 10
+       $atf_ifconfig vlan0 create
+       $atf_ifconfig vlan0 vlan 10 vlanif shmif0
+       $atf_ifconfig vlan0 $af $remote0/$prefix
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig -w 10
 
        extract_new_packets $BUS > $outfile
 
@@ -178,11 +181,11 @@
        extract_new_packets $BUS > $outfile
        atf_check -s exit:0 -o match:'vlan 10' cat $outfile
 
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 20 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig -w 10
+       $atf_ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 vlan 20 vlanif shmif0
+       $atf_ifconfig vlan0 $af $local0/$prefix
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig -w 10
 
        extract_new_packets $BUS > $outfile
        atf_check -s not-exit:0 -o ignore $ping_cmd $remote0
@@ -191,11 +194,11 @@
        atf_check -s exit:0 -o match:'vlan 20' cat $outfile
 
        export RUMP_SERVER=$SOCK_LOCAL
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig -w 10
+       $atf_ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 vlan 10 vlanif shmif0
+       $atf_ifconfig vlan0 $af $local0/$prefix
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig -w 10
 
        atf_check -s exit:0 -o ignore rump.ifconfig -z vlan0
        atf_check -s exit:0 -o ignore $ping_cmd $remote0
@@ -254,52 +257,55 @@
 
 vlanid_config_and_ping()
 {
+       local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
        local vlanid=$1
        shift
 
        export RUMP_SERVER=$SOCK_LOCAL
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $IP_LOCAL0/24
-       atf_check -s exit:0 rump.ifconfig vlan0 up
+       $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0
+       $atf_ifconfig vlan0 $IP_LOCAL0/24
+       $atf_ifconfig vlan0 up
 
        export RUMP_SERVER=$SOCK_REMOTE
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $IP_REMOTE0/24
-       atf_check -s exit:0 rump.ifconfig vlan0 up
+       $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0
+       $atf_ifconfig vlan0 $IP_REMOTE0/24
+       $atf_ifconfig vlan0 up
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP_REMOTE0
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 -vlanif
 
        export RUMP_SERVER=$SOCK_REMOTE
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 -vlanif
 }
 
 vlanid_config_and_ping6()
 {
+       local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
        local vlanid=$1
        shift
 
        export RUMP_SERVER=$SOCK_LOCAL
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 inet6 $IP6_LOCAL0/64
-       atf_check -s exit:0 rump.ifconfig vlan0 up
+       $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0
+       $atf_ifconfig vlan0 inet6 $IP6_LOCAL0/64
+       $atf_ifconfig vlan0 up
 
        export RUMP_SERVER=$SOCK_REMOTE
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan $vlanid vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 inet6 $IP6_REMOTE0/64
-       atf_check -s exit:0 rump.ifconfig vlan0 up
+       $atf_ifconfig vlan0 vlan $vlanid vlanif shmif0
+       $atf_ifconfig vlan0 inet6 $IP6_REMOTE0/64
+       $atf_ifconfig vlan0 up
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 $IP6_REMOTE0
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 -vlanif
 
        export RUMP_SERVER=$SOCK_REMOTE
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 -vlanif
 }
 
 vlan_vlanid_body_common()
 {
+       local atf_ifconfig="atf_check -s exit:0 rump.ifconfig"
        local af=inet
        local prefix=24
        local sysctl_param="net.inet.ip.dad_count=0"
@@ -327,13 +333,13 @@
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param
-       atf_check -s exit:0 rump.ifconfig shmif0 up
-       atf_check -s exit:0 rump.ifconfig vlan0 create
+       $atf_ifconfig shmif0 up
+       $atf_ifconfig vlan0 create
 
        export RUMP_SERVER=$SOCK_REMOTE
        atf_check -s exit:0 -o ignore rump.sysctl -w $sysctl_param
-       atf_check -s exit:0 rump.ifconfig shmif0 up
-       atf_check -s exit:0 rump.ifconfig vlan0 create
+       $atf_ifconfig shmif0 up
+       $atf_ifconfig vlan0 create
 
        export RUMP_SERVER=$SOCK_LOCAL
        atf_check -s not-exit:0 -e ignore\
@@ -361,35 +367,35 @@
                    rump.ifconfig vlan0 vlan "${TAG}" vlanif shmif0
        done
 
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 1 vlanif shmif0
+       $atf_ifconfig vlan0 vlan 1 vlanif shmif0
        atf_check -s not-exit:0 -e ignore \
            rump.ifconfig vlan0 vlan 2 vlanif shmif0
 
        atf_check -s not-exit:0 -e ignore \
            rump.ifconfig vlan0 vlan 1 vlanif shmif1
 
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 -vlanif
        atf_check -s not-exit:0 -e ignore \
            rump.ifconfig vlan0 $local0/$prefix
 
        export RUMP_SERVER=$SOCK_LOCAL
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $af $local0/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig vlan1 create
-       atf_check -s exit:0 rump.ifconfig vlan1 vlan 11 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan1 $af $local1/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan1 up
+       $atf_ifconfig vlan0 vlan 10 vlanif shmif0
+       $atf_ifconfig vlan0 $af $local0/$prefix
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig vlan1 create
+       $atf_ifconfig vlan1 vlan 11 vlanif shmif0
+       $atf_ifconfig vlan1 $af $local1/$prefix
+       $atf_ifconfig vlan1 up
 
        export RUMP_SERVER=$SOCK_REMOTE
-       atf_check -s exit:0 rump.ifconfig vlan0 -vlanif
-       atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan0 $af $remote0/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan0 up
-       atf_check -s exit:0 rump.ifconfig vlan1 create
-       atf_check -s exit:0 rump.ifconfig vlan1 vlan 11 vlanif shmif0
-       atf_check -s exit:0 rump.ifconfig vlan1 $af $remote1/$prefix
-       atf_check -s exit:0 rump.ifconfig vlan1 up
+       $atf_ifconfig vlan0 -vlanif
+       $atf_ifconfig vlan0 vlan 10 vlanif shmif0
+       $atf_ifconfig vlan0 $af $remote0/$prefix
+       $atf_ifconfig vlan0 up
+       $atf_ifconfig vlan1 create
+       $atf_ifconfig vlan1 vlan 11 vlanif shmif0
+       $atf_ifconfig vlan1 $af $remote1/$prefix
+       $atf_ifconfig vlan1 up
 
        export RUMP_SERVER=$SOCK_LOCAL



Home | Main Index | Thread Index | Old Index