1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
init_tests \
setup_interfaces_usage \
setup_interfaces_interactive_dhcp \
setup_interfaces_interactive_vlan \
setup_interfaces_interactive_vlan_ng \
setup_interfaces_interactive_vlan0_ng \
setup_interfaces_interactive_br0 \
setup_interfaces_interactive_bond0 \
setup_interfaces_interactive_wlan0_psk \
setup_interfaces_interactive_wlan0_none
setup_interfaces_usage_body() {
test_usage setup-interfaces
}
create_fake_ifaces() {
local n=1
for i; do
mkdir -p sys/class/net/$i
echo $n > sys/class/net/$i/ifindex
echo down >sys/class/net/$i/operstate
n=$((n+1))
done
}
setup_interfaces_interactive_dhcp_body() {
init_env
create_fake_ifaces lo eth0
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo eth0
# Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o match:"Available interfaces are: eth0" \
setup-interfaces <answers
}
setup_interfaces_interactive_vlan_body() {
init_env
create_fake_ifaces lo eth0
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo eth0.5
# Ip address for eth0.5? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo done
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o match:"apk add.*vlan" \
setup-interfaces <answers
}
setup_interfaces_interactive_vlan_ng_body() {
init_env
create_fake_ifaces lo eth0
mkdir -p usr/libexec/ifupdown-ng
touch usr/libexec/ifupdown-ng/link
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo eth0.5
# Ip address for eth0.5? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo done
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o not-match:"apk add.*vlan" \
setup-interfaces <answers
}
setup_interfaces_interactive_vlan0_ng_body() {
init_env
create_fake_ifaces lo eth0
mkdir -p usr/libexec/ifupdown-ng
touch usr/libexec/ifupdown-ng/link
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo vlan0
# Which one do you want use for vlan0? (or 'done') [eth0]
echo eth0
# Ip address for vlan0? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo done
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o match:"Available raw devices are: eth0" \
-o not-match:"apk add.*vlan" \
setup-interfaces <answers
}
setup_interfaces_interactive_br0_body() {
init_env
create_fake_ifaces lo eth0
mkdir -p usr/libexec/ifupdown-ng
touch usr/libexec/ifupdown-ng/bridge
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo br0
# Which port(s) do you want add to bridge br0? (or 'done') [eth0]
echo eth0
# Ip address for vlan0? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo done
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o match:"Available bridge ports are: eth0" \
-o match:"apk add.*bridge" \
setup-interfaces <answers
}
setup_interfaces_interactive_bond0_body() {
init_env
create_fake_ifaces lo eth0
mkdir -p usr/libexec/ifupdown-ng
touch usr/libexec/ifupdown-ng/bond
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo bond0
# Which slave(s) do you want add to bond0? (or 'done') [eth0]
echo eth0
# Ip address for bond0? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o match:"Available interfaces are: eth0" \
-o match:"apk add.*bonding" \
setup-interfaces <answers
}
setup_interfaces_interactive_wlan0_psk_body() {
init_env
create_fake_ifaces lo eth0 wlan2
mkdir -p sys/class/net/wlan2/phy80211
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo wlan2
# Type the wireless network name to connect to:
echo Telenor0366rar
# Type the "Telenor0366rar" network Pre-Shared Key (will not echo):
echo 0123456789
# Ip address for wlan0? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o match:"Available interfaces are: eth0 wlan2" \
-o match:"Lynx2C0CEA_5G" \
-o match:"Get-B3ED64" \
-o not-match:"x00" \
-o match:"Type the \"Telenor0366rar\" network Pre-Shared Key" \
-o match:"Ip address for wlan2" \
setup-interfaces <answers
}
setup_interfaces_interactive_wlan0_none_body() {
init_env
create_fake_ifaces lo eth0 wlan0
mkdir -p sys/class/net/wlan0/phy80211
(
# Which one do you want to initialize? (or '?' or 'done') [eth0]
echo wlan0
# Type the wireless network name to connect to:
echo Lynx2C0CEA_5G
# Ip address for wlan0? (or 'dhcp', 'none', '?') [dhcp]
echo dhcp
# Do you want to do any manual network configuration? (y/n) [n]
echo n
)>answers
atf_check -s exit:0 \
-o match:"Available interfaces are: eth0 wlan0" \
-o match:"Telenor0366rar" \
-o match:"Get-B3ED64" \
-o not-match:"x00" \
-o not-match:"Type the \"Lynx2C0CEA_5g\" network Pre-Shared Key" \
-o match:"Ip address for wlan0" \
setup-interfaces <answers
}
|