File: ifquery_test

package info (click to toggle)
ifupdown-ng 0.12.1-9~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 968 kB
  • sloc: ansic: 3,572; sh: 980; makefile: 233
file content (296 lines) | stat: -rwxr-xr-x 8,357 bytes parent folder | download | duplicates (4)
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_env.sh

tests_init \
	noargs \
	loopback_always_configured \
	static_dual_stack \
	static_ipv4 \
	static_ipv6 \
	dhcp_ipv4 \
	use_dhcp \
	state_query_home \
	state_query_work \
	state_print \
	learned_dependency \
	learned_dependency_2 \
	learned_executor \
	inheritance_0 \
	inheritance_1 \
	implicit_vlan \
	vrf_dependency \
	vrf_ifupdown2_rewrite \
	vrf_ifupdown2_dependency \
	vrf_implicit_static_gateway \
	ppp_dependency \
	ppp_legacy_rewrite \
	tunnel_dependency \
	tunnel_legacy_dependency \
	tunnel_legacy_rewrite \
	tunnel_ifupdown2_dependency \
	tunnel_ifupdown2_rewrite \
	gre_dependency \
	vlan_explicit_learned_dependency \
	vlan_guessed_learned_dependency \
	vlan_complex_learned_dependency \
	wireguard \
	allow_undefined_positive \
	allow_undefined_negative \
	default_netmask_v4 \
	default_netmask_v6 \
	stanza_merging_with_cidr \
	stanza_merging_without_cidr \
	dhcp_hostname_rewrite \
	dhcp_hostname_inference \
	dhcp_hostname_replacement

noargs_body() {
	atf_check -s exit:1 -e ignore ifquery -S/dev/null
}

loopback_always_configured_body() {
	atf_check -s exit:0 -o match:"use loopback" \
		ifquery -S/dev/null -i $FIXTURES/static-eth0.interfaces lo
}

static_dual_stack_body() {
	atf_check -s exit:0 -o match:"address 203.0.113.2/24" \
		  -o match:"address 2001:db8:1000:2::2/64" \
		  -o match:"gateway 203.0.113.1" \
		  -o match:"gateway 2001:db8:1000:2::1" \
		  ifquery -S/dev/null -i $FIXTURES/static-eth0.interfaces eth0
}

static_ipv4_body() {
	atf_check -s exit:0 -o match:"address 203.0.113.2/24" \
		  -o match:"gateway 203.0.113.1" \
		  ifquery -S/dev/null -i $FIXTURES/static-eth0-v4.interfaces eth0
}

static_ipv6_body() {
	atf_check -s exit:0 -o match:"address 2001:db8:1000:2::2/64" \
		  -o match:"gateway 2001:db8:1000:2::1" \
		  ifquery -S/dev/null -i $FIXTURES/static-eth0-v6.interfaces eth0
}

dhcp_ipv4_body() {
	atf_check -s exit:0 -o match:"use dhcp" \
		  ifquery -S/dev/null -i $FIXTURES/dhcp-eth0.interfaces eth0
}

use_dhcp_body() {
	atf_check -s exit:0 -o match:"use dhcp" \
		  ifquery -S/dev/null -i $FIXTURES/use-dhcp-eth0.interfaces eth0
}

state_query_home_body() {
	atf_check -s exit:0 -o match:"iface home" \
		  ifquery -S $FIXTURES/alias-home.ifstate -i $FIXTURES/alias-home-work.interfaces wlan0
}

state_query_work_body() {
	atf_check -s exit:0 -o match:"iface work" \
		  ifquery -S $FIXTURES/alias-work.ifstate -i $FIXTURES/alias-home-work.interfaces wlan0
}

state_print_body() {
	atf_check -s exit:0 -o match:"wlan0=home" \
		  ifquery -S $FIXTURES/alias-home.ifstate -i $FIXTURES/alias-home-work.interfaces -s
	atf_check -s exit:0 -o match:"wlan0=work" \
		  ifquery -S $FIXTURES/alias-work.ifstate -i $FIXTURES/alias-home-work.interfaces -s
}

learned_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0 eth1 eth2 eth3 eth4" \
		ifquery -E $EXECUTORS -i $FIXTURES/mock-dependency-generator.interfaces br0
}

learned_dependency_2_body() {
	atf_check -s exit:0 -o match:"requires bond0" \
		ifquery -E $EXECUTORS -i $FIXTURES/mock-dependency-generator-2.interfaces br0
}

learned_executor_body() {
	atf_check -s exit:0 -o match:"use mock" \
		ifquery -E $EXECUTORS -i $FIXTURES/mock-dependency-generator-2.interfaces br0
}

inheritance_0_body() {
	atf_check -s exit:0 -o match:"inherit base0" \
		-o match:"address 203.0.113.2/24" \
		-o match:"address 203.0.113.3/24" \
		-o match:"address 2001:db8:1000:2::2/64" \
		ifquery -E $EXECUTORS -i $FIXTURES/inheritance.interfaces inherit0
}

inheritance_1_body() {
	atf_check -s exit:0 -o match:"inherit base0" \
		-o match:"address 203.0.113.2/24" \
		-o match:"address 203.0.113.4/24" \
		-o match:"address 2001:db8:1000:2::2/64" \
		ifquery -E $EXECUTORS -i $FIXTURES/inheritance.interfaces inherit1
}

implicit_vlan_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		-o match:"use vlan" \
		ifquery -E $EXECUTORS -i $FIXTURES/vlan.interfaces eth0.8
}

vrf_dependency_body() {
	atf_check -s exit:0 -o match:"requires vrf-red" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vrf.interfaces eth0
}

vrf_ifupdown2_rewrite_body() {
	atf_check -s exit:0 -o match:"vrf-member vrf-red" \
		ifquery -E $EXECUTORS -i $FIXTURES/vrf-ifupdown2.interfaces eth0
}

vrf_ifupdown2_dependency_body() {
	atf_check -s exit:0 -o match:"requires vrf-red" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vrf-ifupdown2.interfaces eth0
}

vrf_implicit_static_gateway_body() {
	atf_check -s exit:0 -o match:"use static" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vrf.interfaces vrf-red
}

ppp_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/ppp.interfaces ppp0
}

ppp_legacy_rewrite_body() {
	atf_check -s exit:0 -o match:"ppp-provider someisp" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/ppp-legacy.interfaces ppp0
}

tunnel_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel.interfaces tun0
}

tunnel_legacy_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-legacy.interfaces tun0
}

tunnel_ifupdown2_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-ifupdown2.interfaces tun0
}

tunnel_legacy_rewrite_body() {
	atf_check -s exit:0 \
		-o match:"tunnel-local 203.0.113.2" \
		-o match:"tunnel-remote 203.0.113.1" \
		-o match:"tunnel-mode gre" \
		-o match:"tunnel-ttl 255" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-legacy.interfaces tun0
}

tunnel_ifupdown2_rewrite_body() {
	atf_check -s exit:0 \
		-o match:"tunnel-local 203.0.113.2" \
		-o match:"tunnel-remote 203.0.113.1" \
		-o match:"tunnel-mode gre" \
		-o match:"tunnel-ttl 255" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-ifupdown2.interfaces tun0
}

gre_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/gre.interfaces tun0
}

vlan_explicit_learned_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		-o match:"use vlan" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vlan-named.interfaces servers
}

vlan_guessed_learned_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		-o match:"use vlan" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vlan.interfaces eth0.8
}

vlan_complex_learned_dependency_body() {
	atf_check -s exit:0 -o match:"requires eth0" \
		-o match:"use vlan" \
		-o match:"address 1.2.10.4/24" \
		-o match:"gateway 1.2.10.1" \
		-o match:"address abcd:ef12:3456:10::4/64" \
		-o match:"gateway abcd:ef12:3456:10::1" \
		-o match:"vlan-raw-device eth0" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vlan-complex.interfaces servers
}

wireguard_body() {
	atf_check -s exit:0 \
		-o match:"requires eth0" \
		-o match:"use wireguard" \
		ifquery -E $EXECUTORS_LINUX -i $FIXTURES/wireguard.interfaces wg0
}

allow_undefined_positive_body() {
	atf_check -s exit:0 \
		-o ignore \
		-e ignore \
		ifquery -U -i /dev/null -p address foo
}

allow_undefined_negative_body() {
	atf_check -s exit:1 \
		-o ignore \
		-e ignore \
		ifquery -i /dev/null -p address foo
}

default_netmask_v4_body() {
	atf_check -s exit:0 \
		-o match:"203.0.113.2/24" \
		ifquery -i $FIXTURES/without-netmask.interfaces -p address v4
}

default_netmask_v6_body() {
	atf_check -s exit:0 \
		-o match:"2001:470:1f10::1/64" \
		ifquery -i $FIXTURES/without-netmask.interfaces -p address v6
}

stanza_merging_with_cidr_body() {
	atf_check -s exit:0 \
		-o match:"203.0.113.1/32" \
		-o match:"203.0.113.2/24" \
		ifquery -i $FIXTURES/stanza-merging.interfaces -p address cidr
}

stanza_merging_without_cidr_body() {
	atf_check -s exit:0 \
		-o match:"203.0.113.1/32" \
		-o match:"203.0.113.2/24" \
		ifquery -i $FIXTURES/stanza-merging.interfaces -p address without-cidr
}

dhcp_hostname_rewrite_body() {
	atf_check -s exit:0 \
		-o match:"dhcp-hostname foo" \
		ifquery -i $FIXTURES/dhcp-hostname-rewrite.interfaces -P eth0
}

dhcp_hostname_inference_body() {
	hostname=$(uname -n)
	atf_check -s exit:0 \
		-o match:"dhcp-hostname $hostname" \
		ifquery -i $FIXTURES/dhcp-hostname-rewrite.interfaces -P eth1
}

dhcp_hostname_replacement_body() {
	atf_check -s exit:0 \
		-o match:"dhcp-hostname bar" \
		ifquery -i $FIXTURES/dhcp-hostname-rewrite.interfaces -P eth2
}