summaryrefslogtreecommitdiff
path: root/eclass/tests/daemons.sh
blob: ccd0ded8107da404be31d252181f58cef7f01601 (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
#!/bin/bash
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

GENTOO_REPO=$(portageq get_repo_path / gentoo) || exit
source "${GENTOO_REPO:?}"/eclass/tests/tests-common.sh || exit
TESTS_ECLASS_SEARCH_PATHS+=( "${GENTOO_REPO:?}"/eclass )

declare -A DAEMONS_REQ_USE=(
	[ceph]="ssl"
	[postgresql]="xml"
)

inherit daemons

test_depend() {
	tbegin "if \${DAEMONS_DEPEND} is defined"
	declare -p DAEMONS_DEPEND &>/dev/null
	tend $?

	tbegin "if \${DAEMONS_DEPEND} contains Pifpaf"
	[[ "${DAEMONS_DEPEND[*]}" == *"dev-util/pifpaf"* ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[ceph]}"
	[[ "${DAEMONS_DEPEND[ceph]}" == *"sys-cluster/ceph[ssl]" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[consul]}"
	[[ "${DAEMONS_DEPEND[consul]}" == *"app-admin/consul" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[httpbin]}"
	[[ "${DAEMONS_DEPEND[httpbin]}" == *"dev-python/httpbin" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[kafka]}"
	[[ "${DAEMONS_DEPEND[kafka]}" == *"net-misc/kafka-bin" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[memcached]}"
	[[ "${DAEMONS_DEPEND[memcached]}" == *"net-misc/memcached" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[mysql]}"
	[[ "${DAEMONS_DEPEND[mysql]}" == *"virtual/mysql[server]" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[postgresql]}"
	[[ "${DAEMONS_DEPEND[postgresql]}" == *"dev-db/postgresql[server,xml]" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[redis]}"
	[[ "${DAEMONS_DEPEND[redis]}" == *"dev-db/redis" ]]
	tend $?

	tbegin "\${DAEMONS_DEPEND[vault]}"
	[[ "${DAEMONS_DEPEND[vault]}" == *"app-admin/vault" ]]
	tend $?
}

test_daemons_enable() {
	local IUSE= RESTRICT= BDEPEND=
	local svc=${1?}

	IUSE= RESTRICT= BDEPEND=
	tbegin "'daemons_enable ${svc} test'"
	daemons_enable ${svc} test && [[ ${BDEPEND} && ${IUSE} && ${RESTRICT} ]]
	tend $?

	IUSE= RESTRICT= BDEPEND=
	tbegin "'daemons_enable ${svc} test-db'"
	daemons_enable ${svc} test-db && [[ ${BDEPEND} && ${IUSE} && ! ${RESTRICT} ]]
	tend $?
}

einfo "Testing dependency strings"
eindent
test_depend
eoutdent

einfo "Testing daemons_enable"
eindent
for svc in "${!DAEMONS_DEPEND[@]}"; do
	test_daemons_enable ${svc}
done
eoutdent

texit