summaryrefslogtreecommitdiff
blob: f870df4b7a127585f3025a2657d653333416812b (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
#!/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