1312123Sngie#	$NetBSD: t_vlan.sh,v 1.1 2016/11/26 03:19:49 ozaki-r Exp $
2312123Sngie#
3312123Sngie# Copyright (c) 2016 Internet Initiative Japan Inc.
4312123Sngie# All rights reserved.
5312123Sngie#
6312123Sngie# Redistribution and use in source and binary forms, with or without
7312123Sngie# modification, are permitted provided that the following conditions
8312123Sngie# are met:
9312123Sngie# 1. Redistributions of source code must retain the above copyright
10312123Sngie#    notice, this list of conditions and the following disclaimer.
11312123Sngie# 2. Redistributions in binary form must reproduce the above copyright
12312123Sngie#    notice, this list of conditions and the following disclaimer in the
13312123Sngie#    documentation and/or other materials provided with the distribution.
14312123Sngie#
15312123Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16312123Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17312123Sngie# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18312123Sngie# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19312123Sngie# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20312123Sngie# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21312123Sngie# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22312123Sngie# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23312123Sngie# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24312123Sngie# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25312123Sngie# POSSIBILITY OF SUCH DAMAGE.
26312123Sngie#
27312123Sngie
28312123SngieBUS=bus
29312123SngieSOCK_LOCAL=unix://commsock1
30312123SngieSOCK_REMOTE=unix://commsock2
31312123SngieIP_LOCAL=10.0.0.1
32312123SngieIP_REMOTE=10.0.0.2
33312123Sngie
34312123SngieDEBUG=${DEBUG:-false}
35312123Sngie
36312123Sngieatf_test_case vlan_create_destroy cleanup
37312123Sngievlan_create_destroy_head()
38312123Sngie{
39312123Sngie
40312123Sngie	atf_set "descr" "tests of creation and deletion of vlan interface"
41312123Sngie	atf_set "require.progs" "rump_server"
42312123Sngie}
43312123Sngie
44312123Sngievlan_create_destroy_body()
45312123Sngie{
46312123Sngie
47312123Sngie	rump_server_start $SOCK_LOCAL vlan
48312123Sngie
49312123Sngie	export RUMP_SERVER=${SOCK_LOCAL}
50312123Sngie
51312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 create
52312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 up
53312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 down
54312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 destroy
55312123Sngie}
56312123Sngie
57312123Sngievlan_create_destroy_cleanup()
58312123Sngie{
59312123Sngie
60312123Sngie	$DEBUG && dump
61312123Sngie	cleanup
62312123Sngie}
63312123Sngie
64312123Sngieatf_test_case vlan_basic cleanup
65312123Sngievlan_basic_head()
66312123Sngie{
67312123Sngie
68312123Sngie	atf_set "descr" "tests of communications over vlan interfaces"
69312123Sngie	atf_set "require.progs" "rump_server"
70312123Sngie}
71312123Sngie
72312123Sngievlan_basic_body()
73312123Sngie{
74312123Sngie
75312123Sngie	rump_server_start $SOCK_LOCAL vlan
76312123Sngie	rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
77312123Sngie	rump_server_start $SOCK_REMOTE vlan
78312123Sngie	rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
79312123Sngie
80312123Sngie	export RUMP_SERVER=$SOCK_LOCAL
81312123Sngie	atf_check -s exit:0 rump.ifconfig shmif0 up
82312123Sngie	export RUMP_SERVER=$SOCK_REMOTE
83312123Sngie	atf_check -s exit:0 rump.ifconfig shmif0 up
84312123Sngie
85312123Sngie	export RUMP_SERVER=$SOCK_LOCAL
86312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 create
87312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
88312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 $IP_LOCAL/24
89312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 up
90312123Sngie	atf_check -s exit:0 rump.ifconfig -w 10
91312123Sngie
92312123Sngie	export RUMP_SERVER=$SOCK_REMOTE
93312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 create
94312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 vlan 10 vlanif shmif0
95312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 $IP_REMOTE/24
96312123Sngie	atf_check -s exit:0 rump.ifconfig vlan0 up
97312123Sngie	atf_check -s exit:0 rump.ifconfig -w 10
98312123Sngie
99312123Sngie	export RUMP_SERVER=$SOCK_LOCAL
100312123Sngie	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP_REMOTE
101312123Sngie}
102312123Sngie
103312123Sngievlan_basic_cleanup()
104312123Sngie{
105312123Sngie
106312123Sngie	$DEBUG && dump
107312123Sngie	cleanup
108312123Sngie}
109312123Sngie
110312123Sngieatf_init_test_cases()
111312123Sngie{
112312123Sngie
113312123Sngie	atf_add_test_case vlan_create_destroy
114312123Sngie	atf_add_test_case vlan_basic
115312123Sngie}
116