summaryrefslogtreecommitdiff
path: root/tests/libalpine_test
blob: 993104e1b269425f69c1182a42780e008714afce (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_env.sh
init_tests \
	libalpine_isin \
	libalpine_available_ifaces \
	libalpine_available_ifaces_bond \
	libalpine_available_ifaces_bridge

libalpine=$(atf_get_srcdir)/../libalpine.sh

libalpine_isin_body() {
	. "$libalpine"
	isin a a b c || atf_fail "isin a a b c"
	! isin foo bar baz a a b c || atf_fail" isin foo bar baz a a b c"
	isin "with space" foo "with space" "other space" || atf_fail 'isin "with space" foo "with space" "other space'
}

libalpine_available_ifaces_body() {
	init_env
	mkdir -p sys/class/net/lo sys/class/net/eth0
	echo 1 >sys/class/net/lo/ifindex
	echo 2 >sys/class/net/eth0/ifindex
	atf_check \
		-o match:"lo eth0" \
		sh -c ". $libalpine; available_ifaces"
}

libalpine_available_ifaces_bond_body() {
	init_env
	mkdir -p sys/class/net/lo \
		sys/class/net/eth0/master/bonding \
		sys/class/net/bond0
	echo 1 >sys/class/net/lo/ifindex
	echo 2 >sys/class/net/eth0/ifindex
	echo 3 >sys/class/net/bond0/ifindex

	atf_check \
		-o match:"lo bond0" \
		sh -c ". $libalpine; available_ifaces"
}

libalpine_available_ifaces_bridge_body() {
	init_env
	mkdir -p sys/class/net/lo \
		sys/class/net/eth0/brport \
		sys/class/net/br0
	echo 1 >sys/class/net/lo/ifindex
	echo 2 >sys/class/net/eth0/ifindex
	echo 3 >sys/class/net/br0/ifindex

	atf_check \
		-o match:"lo br0" \
		sh -c ". $libalpine; available_ifaces"
}