summaryrefslogtreecommitdiff
path: root/tests/setup_alpine_test
blob: 4b26a5ddbe7717d912d4d5ae2f7a9ccd55361609 (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
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
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_env.sh
init_tests \
	setup_alpine_usage \
	setup_alpine_quick \
	setup_alpine_create_answerfile \
	setup_alpine_kvm_clock

setup_alpine_usage_body() {
	test_usage setup-alpine
}

setup_alpine_quick_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
	echo down >sys/class/net/lo/operstate
	echo down >sys/class/net/eth0/operstate
	atf_check -s exit:0 \
		-o match:"openrc boot" \
		-o match:"openrc default" \
		-e empty \
		setup-alpine -q
}

setup_alpine_create_answerfile_body() {
	init_env
	atf_check -s exit:0 \
		-o match:"Answer file answers has been created"  \
		setup-alpine -c answers

	mkdir -p usr/share/zoneinfo/
	touch usr/share/zoneinfo/UTC

	sed -i -e 's/^USERSSHKEY=.*/USERSSHKEY="ssh-rsa blahbla user@example.com"/' \
		answers

	atf_check -s exit:0 \
		-o match:"Starting hostname" \
		-o match:"Starting mdev" \
		-o match:"Added mirror" \
		-o match:"adduser" \
		-o match:"apk add" \
		setup-alpine -f answers
	grep "ssh-rsa blahbla user@example.com" home/juser/.ssh/authorized_keys \
		|| atf_fail "ssh key not set for juser"
	grep home/juser etc/apk/protected_paths.d/lbu.list \
		|| atf_fail "home/juser was not added to lbu.list"
}

setup_alpine_kvm_clock_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
	echo down >sys/class/net/lo/operstate
	echo down >sys/class/net/eth0/operstate

	mkdir -p sys/devices/system/clocksource/clocksource0
	echo kvm-clock > sys/devices/system/clocksource/clocksource0/current_clocksource

	echo "none" > answers
	KEYMAPOPTS=none \
		HOSTNAMEOPTS=alpine \
		INTERFACESOPTS=done \
		DNSOPTS=none \
		TIMEZONEOPTS=none \
		PROXYOPTS=none \
		APKREPOSOPTS=none \
		USEROPTS=none \
		SSHDOPTS=none \
		DISKOPTS=none \
		LBUOPTS=none \
		APKCACHEOPTS=none \
		\
		atf_check -s exit:0 \
		-o not-match:"Which NTP client to run" \
		setup-alpine -e < answers
}