summaryrefslogtreecommitdiff
path: root/eclass/tests
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-10-15 19:51:12 +0100
committerV3n3RiX <venerix@koprulu.sector>2022-10-15 19:51:12 +0100
commitca144cbf71b2faf598564847378fa40a0090d67c (patch)
treed9dc05cd474f9feb1649b145b41e453bbebc1ad4 /eclass/tests
parent7b0230b9f0a5cbd2779e7b25d57df8c33b6d0a88 (diff)
gentoo auto-resync : 15:10:2022 - 19:51:12
Diffstat (limited to 'eclass/tests')
-rwxr-xr-xeclass/tests/systemd.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/eclass/tests/systemd.sh b/eclass/tests/systemd.sh
new file mode 100755
index 000000000000..f870df4b7a12
--- /dev/null
+++ b/eclass/tests/systemd.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+source tests-common.sh || exit
+
+inherit systemd
+
+test_system_dir() {
+ local exp1="${EPREFIX}$1"
+ local exp2="${EPREFIX}/usr$1"
+ shift
+ tbegin "$@"
+ local act=$("$@")
+ [[ ${act} == ${exp1} || ${act} == ${exp2} ]]
+ tend $?
+}
+
+test_user_dir() {
+ local exp="${EPREFIX}$1"
+ shift
+ tbegin "$@"
+ local act=$("$@")
+ [[ ${act} == ${exp} ]]
+ tend $?
+}
+
+test_systemd_unprefix() {
+ local exp=$1
+ local EPREFIX=$2
+ shift 2
+ tbegin "EPREFIX=${EPREFIX} _systemd_unprefix $@"
+ [[ "$(_systemd_unprefix "$@")" == "${exp}" ]]
+ tend $?
+}
+
+test_system_dir /lib/systemd/system systemd_get_systemunitdir
+test_system_dir /lib/systemd systemd_get_utildir
+test_system_dir /lib/systemd/system-generators systemd_get_systemgeneratordir
+test_system_dir /lib/systemd/system-preset systemd_get_systempresetdir
+test_system_dir /lib/systemd/system-sleep systemd_get_sleepdir
+
+test_user_dir /usr/lib/systemd/user systemd_get_userunitdir
+
+test_systemd_unprefix /lib/systemd /prefix echo /prefix/lib/systemd
+test_systemd_unprefix /lib/systemd '' echo /lib/systemd
+test_systemd_unprefix /lib/systemd '/*' echo '/*/lib/systemd'
+
+texit