Module Name:    src
Committed By:   ozaki-r
Date:           Thu Feb  1 05:22:02 UTC 2018

Modified Files:
        src/tests/net: net_common.sh
        src/tests/net/if_bridge: t_bridge.sh
        src/tests/net/if_gif: t_gif.sh
        src/tests/net/if_ipsec: t_ipsec.sh
        src/tests/net/if_l2tp: t_l2tp.sh
        src/tests/net/if_loop: t_basic.sh
        src/tests/net/if_pppoe: t_pppoe.sh
        src/tests/net/if_tap: t_tap.sh
        src/tests/net/if_tun: Makefile t_tun.sh
        src/tests/net/if_vlan: t_vlan.sh

Log Message:
Commonalize and add tests of creating/destroying interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/net/net_common.sh
cvs rdiff -u -r1.17 -r1.18 src/tests/net/if_bridge/t_bridge.sh
cvs rdiff -u -r1.11 -r1.12 src/tests/net/if_gif/t_gif.sh
cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_ipsec/t_ipsec.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/net/if_l2tp/t_l2tp.sh
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_loop/t_basic.sh
cvs rdiff -u -r1.17 -r1.18 src/tests/net/if_pppoe/t_pppoe.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/net/if_tap/t_tap.sh
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_tun/Makefile
cvs rdiff -u -r1.4 -r1.5 src/tests/net/if_tun/t_tun.sh
cvs rdiff -u -r1.7 -r1.8 src/tests/net/if_vlan/t_vlan.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/net_common.sh
diff -u src/tests/net/net_common.sh:1.25 src/tests/net/net_common.sh:1.26
--- src/tests/net/net_common.sh:1.25	Fri Nov 24 03:28:49 2017
+++ src/tests/net/net_common.sh	Thu Feb  1 05:22:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: net_common.sh,v 1.25 2017/11/24 03:28:49 kre Exp $
+#	$NetBSD: net_common.sh,v 1.26 2018/02/01 05:22:01 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -422,3 +422,45 @@ skip_if_qemu()
 	    atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"
 	fi
 }
+
+test_create_destroy_common()
+{
+	local sock=$1
+	local ifname=$2
+	local test_address=${3:-false}
+	local ipv4="10.0.0.1/24"
+	local ipv6="fc00::1"
+
+	export RUMP_SERVER=$sock
+
+	atf_check -s exit:0 rump.ifconfig $ifname create
+	atf_check -s exit:0 rump.ifconfig $ifname destroy
+
+	atf_check -s exit:0 rump.ifconfig $ifname create
+	atf_check -s exit:0 rump.ifconfig $ifname up
+	atf_check -s exit:0 rump.ifconfig $ifname down
+	atf_check -s exit:0 rump.ifconfig $ifname destroy
+
+	# Destroy while UP
+	atf_check -s exit:0 rump.ifconfig $ifname create
+	atf_check -s exit:0 rump.ifconfig $ifname up
+	atf_check -s exit:0 rump.ifconfig $ifname destroy
+
+	if ! $test_address; then
+		return
+	fi
+
+	# With an IPv4 address
+	atf_check -s exit:0 rump.ifconfig $ifname create
+	atf_check -s exit:0 rump.ifconfig $ifname inet $ipv4
+	atf_check -s exit:0 rump.ifconfig $ifname up
+	atf_check -s exit:0 rump.ifconfig $ifname destroy
+
+	# With an IPv6 address
+	atf_check -s exit:0 rump.ifconfig $ifname create
+	atf_check -s exit:0 rump.ifconfig $ifname inet6 $ipv6
+	atf_check -s exit:0 rump.ifconfig $ifname up
+	atf_check -s exit:0 rump.ifconfig $ifname destroy
+
+	unset RUMP_SERVER
+}

Index: src/tests/net/if_bridge/t_bridge.sh
diff -u src/tests/net/if_bridge/t_bridge.sh:1.17 src/tests/net/if_bridge/t_bridge.sh:1.18
--- src/tests/net/if_bridge/t_bridge.sh:1.17	Sat Mar 11 04:24:52 2017
+++ src/tests/net/if_bridge/t_bridge.sh	Thu Feb  1 05:22:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_bridge.sh,v 1.17 2017/03/11 04:24:52 ozaki-r Exp $
+#	$NetBSD: t_bridge.sh,v 1.18 2018/02/01 05:22:01 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -40,11 +40,19 @@ IP6BR2=fc00::12
 DEBUG=${DEBUG:-false}
 TIMEOUT=5
 
+atf_test_case bridge_create_destroy cleanup
 atf_test_case bridge_ipv4 cleanup
 atf_test_case bridge_ipv6 cleanup
 atf_test_case bridge_member_ipv4 cleanup
 atf_test_case bridge_member_ipv6 cleanup
 
+bridge_create_destroy_head()
+{
+
+	atf_set "descr" "Test creating/destroying bridge interfaces"
+	atf_set "require.progs" "rump_server"
+}
+
 bridge_ipv4_head()
 {
 	atf_set "descr" "Does simple if_bridge tests"
@@ -312,6 +320,14 @@ test_ping6_member()
 	rump.ifconfig -v shmif0
 }
 
+bridge_create_destroy_body()
+{
+
+	rump_server_start $SOCK1 bridge
+
+	test_create_destroy_common $SOCK1 bridge0
+}
+
 bridge_ipv4_body()
 {
 	setup
@@ -392,6 +408,13 @@ bridge_member_ipv6_body()
 	rump_server_destroy_ifaces
 }
 
+bridge_create_destroy_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 bridge_ipv4_cleanup()
 {
 
@@ -422,6 +445,8 @@ bridge_member_ipv6_cleanup()
 
 atf_init_test_cases()
 {
+
+	atf_add_test_case bridge_create_destroy
 	atf_add_test_case bridge_ipv4
 	atf_add_test_case bridge_ipv6
 	atf_add_test_case bridge_member_ipv4

Index: src/tests/net/if_gif/t_gif.sh
diff -u src/tests/net/if_gif/t_gif.sh:1.11 src/tests/net/if_gif/t_gif.sh:1.12
--- src/tests/net/if_gif/t_gif.sh:1.11	Thu Aug  3 03:16:26 2017
+++ src/tests/net/if_gif/t_gif.sh	Thu Feb  1 05:22:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_gif.sh,v 1.11 2017/08/03 03:16:26 ozaki-r Exp $
+#	$NetBSD: t_gif.sh,v 1.12 2018/02/01 05:22:01 ozaki-r Exp $
 #
 # Copyright (c) 2015 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -64,6 +64,29 @@ ROUTER2_GIFIP6_RECURSIVE2=fc00:204::1
 DEBUG=${DEBUG:-false}
 TIMEOUT=5
 
+atf_test_case gif_create_destroy cleanup
+gif_create_destroy_head()
+{
+
+	atf_set "descr" "Test creating/destroying gif interfaces"
+	atf_set "require.progs" "rump_server"
+}
+
+gif_create_destroy_body()
+{
+
+	rump_server_start $SOCK1 netinet6 gif
+
+	test_create_destroy_common $SOCK1 gif0 true
+}
+
+gif_create_destroy_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 setup_router()
 {
 	sock=${1}
@@ -757,6 +780,9 @@ add_test_allproto()
 
 atf_init_test_cases()
 {
+
+	atf_add_test_case gif_create_destroy
+
 	add_test_allproto basic "basic tests"
 	add_test_allproto ioctl "ioctl tests"
 	add_test_allproto recursive "recursive check tests"

Index: src/tests/net/if_ipsec/t_ipsec.sh
diff -u src/tests/net/if_ipsec/t_ipsec.sh:1.2 src/tests/net/if_ipsec/t_ipsec.sh:1.3
--- src/tests/net/if_ipsec/t_ipsec.sh:1.2	Thu Jan 11 07:58:22 2018
+++ src/tests/net/if_ipsec/t_ipsec.sh	Thu Feb  1 05:22:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ipsec.sh,v 1.2 2018/01/11 07:58:22 ozaki-r Exp $
+#	$NetBSD: t_ipsec.sh,v 1.3 2018/02/01 05:22:01 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -64,6 +64,29 @@ ROUTER2_IPSECIP6_RECURSIVE2=fc00:204::1
 DEBUG=${DEBUG:-false}
 TIMEOUT=7
 
+atf_test_case ipsecif_create_destroy cleanup
+ipsecif_create_destroy_head()
+{
+
+	atf_set "descr" "Test creating/destroying gif interfaces"
+	atf_set "require.progs" "rump_server"
+}
+
+ipsecif_create_destroy_body()
+{
+
+	rump_server_start $SOCK1 ipsec
+
+	test_create_destroy_common $SOCK1 ipsec0
+}
+
+ipsecif_create_destroy_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 setup_router()
 {
 	local sock=${1}
@@ -919,6 +942,9 @@ add_test_allproto()
 
 atf_init_test_cases()
 {
+
+	atf_add_test_case ipsecif_create_destroy
+
 	add_test_allproto basic "basic tests"
 	add_test_allproto ioctl "ioctl tests"
 	add_test_allproto recursive "recursive check tests"

Index: src/tests/net/if_l2tp/t_l2tp.sh
diff -u src/tests/net/if_l2tp/t_l2tp.sh:1.3 src/tests/net/if_l2tp/t_l2tp.sh:1.4
--- src/tests/net/if_l2tp/t_l2tp.sh:1.3	Thu Aug  3 03:16:26 2017
+++ src/tests/net/if_l2tp/t_l2tp.sh	Thu Feb  1 05:22:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_l2tp.sh,v 1.3 2017/08/03 03:16:26 ozaki-r Exp $
+#	$NetBSD: t_l2tp.sh,v 1.4 2018/02/01 05:22:01 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -49,6 +49,29 @@ CLIENT2_LANIP6=fc00:1::2
 TIMEOUT=5
 DEBUG=${DEBUG:-false}
 
+atf_test_case l2tp_create_destroy cleanup
+l2tp_create_destroy_head()
+{
+
+	atf_set "descr" "Test creating/destroying l2tp interfaces"
+	atf_set "require.progs" "rump_server"
+}
+
+l2tp_create_destroy_body()
+{
+
+	rump_server_start $LAC1SOCK l2tp
+
+	test_create_destroy_common $LAC1SOCK l2tp0
+}
+
+l2tp_create_destroy_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 setup_lac()
 {
 	sock=${1}
@@ -435,6 +458,9 @@ add_test_allproto()
 
 atf_init_test_cases()
 {
+
+	atf_add_test_case l2tp_create_destroy
+
 	add_test_allproto basic "basic tests"
 #	add_test_allproto recursive "recursive check tests"
 }

Index: src/tests/net/if_loop/t_basic.sh
diff -u src/tests/net/if_loop/t_basic.sh:1.1 src/tests/net/if_loop/t_basic.sh:1.2
--- src/tests/net/if_loop/t_basic.sh:1.1	Tue Feb 28 03:32:11 2017
+++ src/tests/net/if_loop/t_basic.sh	Thu Feb  1 05:22:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_basic.sh,v 1.1 2017/02/28 03:32:11 ozaki-r Exp $
+#	$NetBSD: t_basic.sh,v 1.2 2018/02/01 05:22:01 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -41,12 +41,7 @@ loop_create_destroy_body()
 
 	rump_server_start $SOCK_LOCAL netinet6
 
-	export RUMP_SERVER=${SOCK_LOCAL}
-
-	atf_check -s exit:0 rump.ifconfig lo1 create
-	atf_check -s exit:0 rump.ifconfig lo1 up
-	atf_check -s exit:0 rump.ifconfig lo1 down
-	atf_check -s exit:0 rump.ifconfig lo1 destroy
+	test_create_destroy_common $SOCK_LOCAL lo1 true
 }
 
 loop_create_destroy_cleanup()

Index: src/tests/net/if_pppoe/t_pppoe.sh
diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.17 src/tests/net/if_pppoe/t_pppoe.sh:1.18
--- src/tests/net/if_pppoe/t_pppoe.sh:1.17	Tue Mar 28 01:27:46 2017
+++ src/tests/net/if_pppoe/t_pppoe.sh	Thu Feb  1 05:22:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_pppoe.sh,v 1.17 2017/03/28 01:27:46 ozaki-r Exp $
+#	$NetBSD: t_pppoe.sh,v 1.18 2018/02/01 05:22:01 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -39,6 +39,29 @@ TIMEOUT=3
 WAITTIME=10
 DEBUG=${DEBUG:-false}
 
+atf_test_case pppoe_create_destroy cleanup
+pppoe_create_destroy_head()
+{
+
+	atf_set "descr" "Test creating/destroying pppoe interfaces"
+	atf_set "require.progs" "rump_server"
+}
+
+pppoe_create_destroy_body()
+{
+
+	rump_server_start $CLIENT netinet6 pppoe
+
+	test_create_destroy_common $CLIENT pppoe0 true
+}
+
+pppoe_create_destroy_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 setup()
 {
 	inet=true
@@ -403,6 +426,8 @@ pppoe6_chap_cleanup()
 
 atf_init_test_cases()
 {
+
+	atf_add_test_case pppoe_create_destroy
 	atf_add_test_case pppoe_pap
 	atf_add_test_case pppoe_chap
 	atf_add_test_case pppoe6_pap

Index: src/tests/net/if_tap/t_tap.sh
diff -u src/tests/net/if_tap/t_tap.sh:1.6 src/tests/net/if_tap/t_tap.sh:1.7
--- src/tests/net/if_tap/t_tap.sh:1.6	Fri Nov 25 08:51:16 2016
+++ src/tests/net/if_tap/t_tap.sh	Thu Feb  1 05:22:02 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_tap.sh,v 1.6 2016/11/25 08:51:16 ozaki-r Exp $
+#	$NetBSD: t_tap.sh,v 1.7 2018/02/01 05:22:02 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -51,23 +51,7 @@ tap_create_destroy_body()
 
 	rump_server_start $SOCK_LOCAL netinet6 tap
 
-	export RUMP_SERVER=${SOCK_LOCAL}
-
-	# Create and destroy (no address)
-	atf_check -s exit:0 rump.ifconfig tap0 create
-	atf_check -s exit:0 rump.ifconfig tap0 destroy
-
-	# Create and destroy (with an IPv4 address)
-	atf_check -s exit:0 rump.ifconfig tap0 create
-	atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP
-	atf_check -s exit:0 rump.ifconfig tap0 up
-	atf_check -s exit:0 rump.ifconfig tap0 destroy
-
-	# Create and destroy (with an IPv6 address)
-	atf_check -s exit:0 rump.ifconfig tap0 create
-	atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP
-	atf_check -s exit:0 rump.ifconfig tap0 up
-	atf_check -s exit:0 rump.ifconfig tap0 destroy
+	test_create_destroy_common $SOCK_LOCAL tap0 true
 }
 
 tap_create_destroy_cleanup()

Index: src/tests/net/if_tun/Makefile
diff -u src/tests/net/if_tun/Makefile:1.1 src/tests/net/if_tun/Makefile:1.2
--- src/tests/net/if_tun/Makefile:1.1	Mon Sep  5 02:26:48 2016
+++ src/tests/net/if_tun/Makefile	Thu Feb  1 05:22:02 2018
@@ -1,10 +1,13 @@
-# $NetBSD: Makefile,v 1.1 2016/09/05 02:26:48 ozaki-r Exp $
+# $NetBSD: Makefile,v 1.2 2018/02/01 05:22:02 ozaki-r Exp $
 #
 
 .include <bsd.own.mk>
 
 TESTSDIR=	${TESTSBASE}/net/if_tun
 
-TESTS_SH=	t_tun
+.for name in tun
+TESTS_SH+=		t_${name}
+TESTS_SH_SRC_t_${name}=	../net_common.sh t_${name}.sh
+.endfor
 
 .include <bsd.test.mk>

Index: src/tests/net/if_tun/t_tun.sh
diff -u src/tests/net/if_tun/t_tun.sh:1.4 src/tests/net/if_tun/t_tun.sh:1.5
--- src/tests/net/if_tun/t_tun.sh:1.4	Mon Nov  7 05:25:37 2016
+++ src/tests/net/if_tun/t_tun.sh	Thu Feb  1 05:22:02 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_tun.sh,v 1.4 2016/11/07 05:25:37 ozaki-r Exp $
+#	$NetBSD: t_tun.sh,v 1.5 2018/02/01 05:22:02 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -49,12 +49,7 @@ tun_create_destroy_body()
 
 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
 
-	export RUMP_SERVER=${SOCK_LOCAL}
-
-	atf_check -s exit:0 rump.ifconfig tun0 create
-	atf_check -s exit:0 rump.ifconfig tun0 up
-	atf_check -s exit:0 rump.ifconfig tun0 down
-	atf_check -s exit:0 rump.ifconfig tun0 destroy
+	test_create_destroy_common $SOCK_LOCAL tun0
 }
 
 tun_create_destroy_cleanup()

Index: src/tests/net/if_vlan/t_vlan.sh
diff -u src/tests/net/if_vlan/t_vlan.sh:1.7 src/tests/net/if_vlan/t_vlan.sh:1.8
--- src/tests/net/if_vlan/t_vlan.sh:1.7	Thu Nov 23 04:59:49 2017
+++ src/tests/net/if_vlan/t_vlan.sh	Thu Feb  1 05:22:02 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_vlan.sh,v 1.7 2017/11/23 04:59:49 kre Exp $
+#	$NetBSD: t_vlan.sh,v 1.8 2018/02/01 05:22:02 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -44,6 +44,9 @@ vlan_create_destroy_body_common()
 	export RUMP_SERVER=${SOCK_LOCAL}
 
 	atf_check -s exit:0 rump.ifconfig vlan0 create
+	atf_check -s exit:0 rump.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

Reply via email to