t_shmif.sh revision 1.1.2.2 1 1.1.2.2 martin # $NetBSD: t_shmif.sh,v 1.1.2.2 2024/08/24 16:42:25 martin Exp $
2 1.1.2.2 martin #
3 1.1.2.2 martin # Copyright (c) 2024 Internet Initiative Japan Inc.
4 1.1.2.2 martin # All rights reserved.
5 1.1.2.2 martin #
6 1.1.2.2 martin # Redistribution and use in source and binary forms, with or without
7 1.1.2.2 martin # modification, are permitted provided that the following conditions
8 1.1.2.2 martin # are met:
9 1.1.2.2 martin # 1. Redistributions of source code must retain the above copyright
10 1.1.2.2 martin # notice, this list of conditions and the following disclaimer.
11 1.1.2.2 martin # 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.2 martin # notice, this list of conditions and the following disclaimer in the
13 1.1.2.2 martin # documentation and/or other materials provided with the distribution.
14 1.1.2.2 martin #
15 1.1.2.2 martin # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1.2.2 martin # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1.2.2 martin # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1.2.2 martin # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1.2.2 martin # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1.2.2 martin # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1.2.2 martin # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1.2.2 martin # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1.2.2 martin # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1.2.2 martin # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1.2.2 martin # POSSIBILITY OF SUCH DAMAGE.
26 1.1.2.2 martin #
27 1.1.2.2 martin
28 1.1.2.2 martin RUMP_SERVER1=unix://./r1
29 1.1.2.2 martin RUMP_SERVER2=unix://./r2
30 1.1.2.2 martin
31 1.1.2.2 martin TIMEOUT=3
32 1.1.2.2 martin
33 1.1.2.2 martin atf_test_case shmif_linkstate cleanup
34 1.1.2.2 martin shmif_linkstate_head()
35 1.1.2.2 martin {
36 1.1.2.2 martin atf_set "descr" "tests of ifconfig media on shmif"
37 1.1.2.2 martin atf_set "require.progs" "rump_server"
38 1.1.2.2 martin }
39 1.1.2.2 martin
40 1.1.2.2 martin shmif_linkstate_body()
41 1.1.2.2 martin {
42 1.1.2.2 martin local auto="Ethernet autoselect"
43 1.1.2.2 martin local none="Ethernet none"
44 1.1.2.2 martin
45 1.1.2.2 martin rump_server_start $RUMP_SERVER1
46 1.1.2.2 martin rump_server_add_iface $RUMP_SERVER1 shmif0 bus1
47 1.1.2.2 martin
48 1.1.2.2 martin export RUMP_SERVER=$RUMP_SERVER1
49 1.1.2.2 martin # After ifconfig linkstr, the state becomes UP
50 1.1.2.2 martin atf_check -o match:'linkstate: up' \
51 1.1.2.2 martin -o match:"media: $auto" \
52 1.1.2.2 martin -o not-match:"<UP" rump.ifconfig -v shmif0
53 1.1.2.2 martin atf_check rump.ifconfig shmif0 up
54 1.1.2.2 martin atf_check -o match:'linkstate: up' \
55 1.1.2.2 martin -o match:"media: $auto" \
56 1.1.2.2 martin -o match:"<UP" rump.ifconfig -v shmif0
57 1.1.2.2 martin # ifconfig media none makes the state DOWN
58 1.1.2.2 martin atf_check rump.ifconfig shmif0 media none
59 1.1.2.2 martin atf_check -o match:'linkstate: down' \
60 1.1.2.2 martin -o match:"media: $none" \
61 1.1.2.2 martin -o match:"<UP" rump.ifconfig -v shmif0
62 1.1.2.2 martin # ifconfig media auto makes the state UP
63 1.1.2.2 martin atf_check rump.ifconfig shmif0 media auto
64 1.1.2.2 martin atf_check -o match:'linkstate: up' \
65 1.1.2.2 martin -o match:"media: $auto" \
66 1.1.2.2 martin -o match:"<UP" rump.ifconfig -v shmif0
67 1.1.2.2 martin atf_check rump.ifconfig shmif0 down
68 1.1.2.2 martin atf_check -o match:'linkstate: up' \
69 1.1.2.2 martin -o match:"media: $auto" \
70 1.1.2.2 martin -o not-match:"<UP" rump.ifconfig -v shmif0
71 1.1.2.2 martin # After ifconfig -linkstr, the state becomes UNKNOWN
72 1.1.2.2 martin atf_check rump.ifconfig shmif0 -linkstr
73 1.1.2.2 martin atf_check -o match:'linkstate: unknown' \
74 1.1.2.2 martin -o match:"media: $auto" \
75 1.1.2.2 martin -o not-match:"<UP" rump.ifconfig -v shmif0
76 1.1.2.2 martin
77 1.1.2.2 martin rump_server_destroy_ifaces
78 1.1.2.2 martin }
79 1.1.2.2 martin
80 1.1.2.2 martin shmif_linkstate_cleanup()
81 1.1.2.2 martin {
82 1.1.2.2 martin
83 1.1.2.2 martin $DEBUG && dump
84 1.1.2.2 martin cleanup
85 1.1.2.2 martin }
86 1.1.2.2 martin
87 1.1.2.2 martin atf_test_case shmif_linkstate_down cleanup
88 1.1.2.2 martin shmif_linkstate_down_head()
89 1.1.2.2 martin {
90 1.1.2.2 martin atf_set "descr" "tests of behaviors of down shmif"
91 1.1.2.2 martin atf_set "require.progs" "rump_server"
92 1.1.2.2 martin }
93 1.1.2.2 martin
94 1.1.2.2 martin shmif_linkstate_down_body()
95 1.1.2.2 martin {
96 1.1.2.2 martin
97 1.1.2.2 martin rump_server_start $RUMP_SERVER1
98 1.1.2.2 martin rump_server_start $RUMP_SERVER2
99 1.1.2.2 martin rump_server_add_iface $RUMP_SERVER1 shmif0 bus1
100 1.1.2.2 martin rump_server_add_iface $RUMP_SERVER2 shmif0 bus1
101 1.1.2.2 martin
102 1.1.2.2 martin export RUMP_SERVER=$RUMP_SERVER1
103 1.1.2.2 martin atf_check rump.sysctl -q -w net.inet.ip.dad_count=0
104 1.1.2.2 martin atf_check rump.ifconfig shmif0 10.0.0.1/24 up
105 1.1.2.2 martin export RUMP_SERVER=$RUMP_SERVER2
106 1.1.2.2 martin atf_check rump.sysctl -q -w net.inet.ip.dad_count=0
107 1.1.2.2 martin atf_check rump.ifconfig shmif0 10.0.0.2/24 up
108 1.1.2.2 martin
109 1.1.2.2 martin export RUMP_SERVER=$RUMP_SERVER1
110 1.1.2.2 martin atf_check -o ignore rump.ping -c 1 -w $TIMEOUT 10.0.0.2
111 1.1.2.2 martin
112 1.1.2.2 martin atf_check rump.ifconfig shmif0 media none
113 1.1.2.2 martin atf_check -o match:'linkstate: down' rump.ifconfig -v shmif0
114 1.1.2.2 martin
115 1.1.2.2 martin # shmif doesn't send any packets on link down
116 1.1.2.2 martin atf_check -s not-exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT 10.0.0.2
117 1.1.2.2 martin
118 1.1.2.2 martin atf_check rump.ifconfig shmif0 media auto
119 1.1.2.2 martin atf_check -o match:'linkstate: up' rump.ifconfig -v shmif0
120 1.1.2.2 martin
121 1.1.2.2 martin atf_check -o ignore rump.ping -c 1 -w $TIMEOUT 10.0.0.2
122 1.1.2.2 martin
123 1.1.2.2 martin rump_server_destroy_ifaces
124 1.1.2.2 martin }
125 1.1.2.2 martin
126 1.1.2.2 martin shmif_linkstate_down_cleanup()
127 1.1.2.2 martin {
128 1.1.2.2 martin
129 1.1.2.2 martin $DEBUG && dump
130 1.1.2.2 martin cleanup
131 1.1.2.2 martin }
132 1.1.2.2 martin
133 1.1.2.2 martin atf_init_test_cases()
134 1.1.2.2 martin {
135 1.1.2.2 martin
136 1.1.2.2 martin atf_add_test_case shmif_linkstate
137 1.1.2.2 martin atf_add_test_case shmif_linkstate_down
138 1.1.2.2 martin }
139