summaryrefslogtreecommitdiff
path: root/tests/setup_devd_test
blob: 923c29578ae17ff11a35c47f384bb24ba901021e (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
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_env.sh
init_tests \
	setup_devd_usage \
	setup_devd_mdev \
	setup_devd_mdevd \
	setup_devd_udev

setup_devd_usage_body() {
	test_usage setup-devd
}

init_mdev() {
	# make sure `rc-service --exist mdev` returns true
	mkdir -p etc/init.d
	touch etc/init.d/mdev
	rc-service mdev start
	rc-service hwdrivers start
}

setup_devd_mdev_body() {
	init_env
	init_mdev
	atf_check -s exit:0 \
		-o empty \
		-e empty \
		setup-devd mdev
}

setup_devd_mdevd_body() {
	init_env
	init_mdev

	atf_check -s exit:0 \
		-o match:"apk add.*mdevd" \
		-o match:"Starting mdevd" \
		-e empty \
		setup-devd mdevd

	atf_check \
		-o match:"started" \
		rc-service mdevd status

	atf_check -s exit:3 \
		-o match:"stopped" \
		rc-service mdev status

	atf_check -s exit:3 \
		-o match:"stopped" \
		rc-service hwdrivers status
}

setup_devd_udev_body() {
	init_env
	init_mdev
	atf_check -s exit:0 \
		-o match:"apk add.*eudev" \
		-o match:"Starting udev" \
		-o match:"Starting udev-trigger" \
		-o match:"Starting udev-settle" \
		-o match:"Starting udev-postmount" \
		-e empty \
		setup-devd udev

	atf_check \
		-o match:"started" \
		rc-service udev status

	atf_check -s exit:3 \
		-o match:"stopped" \
		rc-service mdev status

	atf_check -s exit:3 \
		-o match:"stopped" \
		rc-service hwdrivers status
}