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
|
#!/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_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
}
|