aboutsummaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorAnna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>2024-02-03 12:29:38 +0500
committerAnna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>2024-02-05 00:23:21 +0500
commite677767400dab06bbb2c3d5ef0eb2b9c344089a7 (patch)
tree0f21ceca6163de59c0737011cb2ca9e3523e8477 /eclass
parentdaemons.eclass: new eclass (diff)
downloadguru-e677767400dab06bbb2c3d5ef0eb2b9c344089a7.tar.gz
guru-e677767400dab06bbb2c3d5ef0eb2b9c344089a7.tar.bz2
guru-e677767400dab06bbb2c3d5ef0eb2b9c344089a7.zip
eclass/tests: add daemons.eclass tests
Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
Diffstat (limited to 'eclass')
-rwxr-xr-xeclass/tests/daemons.sh91
1 files changed, 91 insertions, 0 deletions
diff --git a/eclass/tests/daemons.sh b/eclass/tests/daemons.sh
new file mode 100755
index 000000000..ccd0ded81
--- /dev/null
+++ b/eclass/tests/daemons.sh
@@ -0,0 +1,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