summaryrefslogtreecommitdiff
path: root/tests/setup_interfaces_test
blob: fc652c161774314104711308ae6571a0e1139949 (plain)
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
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_env.sh
init_tests \
	setup_interfaces_usage \
	setup_interfaces_interactive_dhcp

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
}