summaryrefslogtreecommitdiff
path: root/tests/fake_rc_update_test
blob: 2a359c5f9c9e8602a26c1f9eab16e0230baad2ec (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_env.sh
init_tests \
	rc_update_usage \
	rc_update_add \
	rc_update_add_quiet \
	rc_update_del \
	rc_update_del_quiet \
	rc_update_runlevel

rc_update_usage_body() {
	test_usage rc-update
}

rc_update_add_body() {
	init_env
	atf_check -s exit:0 \
		-o match:"service foo added to runlevel default" \
		-e empty \
		rc-update add foo
	test -L etc/runlevels/default/foo || atf_fail "symlink not created"

	atf_check -s exit:0 \
		-o match:"foo already installed" \
		-e empty \
		rc-update add foo
}

rc_update_add_quiet_body() {
	init_env
	atf_check -s exit:0 \
		-o empty \
		-e empty \
		rc-update add --quiet foo
	test -L etc/runlevels/default/foo || atf_fail "symlink not created"

	atf_check -s exit:0 \
		-o empty \
		-e empty \
		rc-update add --quiet foo
}

rc_update_del_body() {
	init_env
	rc-update --quiet add foo
	atf_check -s exit:0 \
		-o match:"service foo removed from runlevel default" \
		-e empty \
		rc-update del foo

	if test -L etc/runlevels/default/foo; then
		atf_fail "symlink not removed"
	fi

	atf_check -s exit:1 \
		-o empty \
		-e match:"is not in the runlevel" \
		rc-update del foo
}

rc_update_del_quiet_body() {
	init_env
	rc-update --quiet add foo
	atf_check -s exit:0 \
		-o empty \
		-e empty \
		rc-update del --quiet foo

	if test -L etc/runlevels/default/foo; then
		atf_fail "symlink not removed"
	fi

	atf_check -s exit:1 \
		-o empty \
		-e empty \
		rc-update del --quiet foo
}

rc_update_runlevel_body() {
	init_env

	atf_check -s exit:0 \
		-o empty \
		-e empty \
		rc-update add --quiet foo sysinit

	test -L etc/runlevels/sysinit/foo || atf_fail "symlink not created in sysinit"

	atf_check -s exit:0 \
		-o match:"service foo removed from runlevel sysinit" \
		-e empty \
		rc-update delete foo sysinit

	if test -L etc/runlevels/sysinit/foo; then
		atf_fail "symlink not removed"
	fi
}