t_vether.sh revision 1.1 1 # $NetBSD: t_vether.sh,v 1.1 2020/09/29 19:41:48 roy Exp $
2 #
3 # Copyright (c) 2016 Internet Initiative Japan Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
26 #
27
28 SOCK_LOCAL=unix://commsock1
29 SOCK_REMOTE=unix://commsock2
30 BUS=bus1
31 IP4_LOCAL=10.0.0.1
32 IP4_VETHER=10.0.0.2
33 IP4_REMOTE=10.0.0.3
34 IP6_LOCAL=fc00::1
35 IP6_VETHER=fc00::2
36 IP6_REMOTE=fc00::3
37
38 DEBUG=${DEBUG:-false}
39 TIMEOUT=1
40
41 atf_test_case vether_create_destroy cleanup
42 vether_create_destroy_head()
43 {
44
45 atf_set "descr" "tests of creation and deletion of vether interface"
46 atf_set "require.progs" "rump_server"
47 }
48
49 vether_create_destroy_body()
50 {
51
52 rump_server_fs_start $SOCK_LOCAL netinet6 vether
53
54 test_create_destroy_common $SOCK_LOCAL vether0 true
55 }
56
57 vether_create_destroy_cleanup()
58 {
59
60 $DEBUG && dump
61 cleanup
62 }
63
64 atf_test_case vether_stand_alone cleanup
65 vether_create_destroy_head()
66 {
67
68 atf_set "descr" "tests of alone vether interface"
69 atf_set "require.progs" "rump_server"
70 }
71
72 vether_stand_alone_body()
73 {
74
75 rump_server_fs_start $SOCK_LOCAL netinet6 vether
76 rump_server_fs_start $SOCK_REMOTE netinet6 vether
77
78 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
79 rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
80
81 export RUMP_SERVER=${SOCK_LOCAL}
82 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL
83 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
84 atf_check -s exit:0 rump.ifconfig shmif0 up
85 atf_check -s exit:0 rump.ifconfig -w 10
86
87 export RUMP_SERVER=${SOCK_REMOTE}
88 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE
89 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
90 atf_check -s exit:0 rump.ifconfig shmif0 up
91 atf_check -s exit:0 rump.ifconfig -w 10
92
93 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL
94 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL
95
96 export RUMP_SERVER=${SOCK_LOCAL}
97 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL delete
98 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL delete
99 rump_server_add_iface $SOCK_LOCAL vether0
100 atf_check -s exit:0 rump.ifconfig vether0 $IP4_VETHER
101 atf_check -s exit:0 rump.ifconfig vether0 inet6 $IP6_VETHER
102 atf_check -s exit:0 rump.ifconfig vether0 up
103 atf_check -s exit:0 rump.ifconfig -w 10
104
105 export RUMP_SERVER=${SOCK_REMOTE}
106 # Cannot reach to an alone vether
107 atf_check -s not-exit:0 -o ignore -e ignore \
108 rump.ping6 -n -X $TIMEOUT -c 1 $IP6_VETHER
109 atf_check -s not-exit:0 -o ignore -e ignore \
110 rump.ping -n -w $TIMEOUT -c 1 $IP4_VETHER
111
112 rump_server_destroy_ifaces
113 }
114
115 vether_stand_alone_cleanup()
116 {
117
118 $DEBUG && dump
119 cleanup
120 }
121
122 atf_test_case vether_bridged cleanup
123 vether_bridged_head()
124 {
125
126 atf_set "descr" "tests of alone vether interface"
127 atf_set "require.progs" "rump_server"
128 }
129
130 vether_bridged_body()
131 {
132
133 rump_server_fs_start $SOCK_LOCAL netinet6 vether bridge
134 rump_server_fs_start $SOCK_REMOTE netinet6 vether
135
136 rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
137 rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
138
139 export RUMP_SERVER=${SOCK_LOCAL}
140 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL
141 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
142 atf_check -s exit:0 rump.ifconfig shmif0 up
143 rump_server_add_iface $SOCK_LOCAL vether0
144 atf_check -s exit:0 rump.ifconfig vether0 $IP4_VETHER
145 atf_check -s exit:0 rump.ifconfig vether0 inet6 $IP6_VETHER
146 atf_check -s exit:0 rump.ifconfig vether0 up
147
148 rump_server_add_iface $SOCK_LOCAL bridge0
149 atf_check -s exit:0 rump.ifconfig bridge0 up
150 export LD_PRELOAD=/usr/lib/librumphijack.so
151 atf_check -s exit:0 brconfig bridge0 add shmif0
152 atf_check -s exit:0 brconfig bridge0 add vether0
153 unset LD_PRELOAD
154
155 atf_check -s exit:0 rump.ifconfig -w 10
156
157 export RUMP_SERVER=${SOCK_REMOTE}
158 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE
159 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
160 atf_check -s exit:0 rump.ifconfig shmif0 up
161 atf_check -s exit:0 rump.ifconfig -w 10
162
163 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL
164 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_VETHER
165
166 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL
167 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_VETHER
168
169 rump_server_destroy_ifaces
170 }
171
172 vether_bridged_cleanup()
173 {
174
175 $DEBUG && dump
176 cleanup
177 }
178
179 atf_init_test_cases()
180 {
181
182 atf_add_test_case vether_create_destroy
183 atf_add_test_case vether_stand_alone
184 atf_add_test_case vether_bridged
185 }
186