You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
systemd/SOURCES/0190-test-systemctl-enable-...

80 lines
3.6 KiB

From 2a11a51491d3113f8d198c7d30ead8b555e60a61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 15 Mar 2022 17:45:34 +0100
Subject: [PATCH] test-systemctl-enable: enhance the test for unit file linking
Current behaviour is wrong, but it cannot be shown in this test, because we
don't have a running systemd instance here.
(cherry picked from commit 85516075a24fd2f1316575570d7d5f5a37f43dbd)
Related: #2082131
---
test/test-systemctl-enable.sh | 39 ++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/test/test-systemctl-enable.sh b/test/test-systemctl-enable.sh
index 0a0123b9d7..220ebfdab7 100644
--- a/test/test-systemctl-enable.sh
+++ b/test/test-systemctl-enable.sh
@@ -401,7 +401,7 @@ test ! -h "$root/etc/systemd/system/link4.service"
test ! -h "$root/etc/systemd/system/link4alias.service"
test ! -h "$root/etc/systemd/system/link4alias2.service"
-: -------issue 661: link and enable on unit file--------------
+: -------issue 661: enable on unit file--------------
test ! -e "$root/etc/systemd/system/link5.service"
cat >"$root/etc/systemd/system/link5.service" <<EOF
[Install]
@@ -412,8 +412,6 @@ EOF
"$systemctl" --root="$root" enable 'link5.service'
test ! -h "$root/etc/systemd/system/link5.service" # this is our file
-# FIXME/CLARIFYME: will systemd think that link5alias2, link5alias, link5 are all aliases?
-# https://github.com/systemd/systemd/issues/661#issuecomment-1057931149
islink "$root/etc/systemd/system/link5alias.service" "/etc/systemd/system/link5.service"
islink "$root/etc/systemd/system/link5alias2.service" "/etc/systemd/system/link5.service"
@@ -421,6 +419,41 @@ islink "$root/etc/systemd/system/link5alias2.service" "/etc/systemd/system/link5
test ! -h "$root/etc/systemd/system/link5alias.service"
test ! -h "$root/etc/systemd/system/link5alias2.service"
+: -------issue 661: link and enable on unit file--------------
+test ! -e "$root/etc/systemd/system/link5copy.service"
+cat >"$root/link5copy.service" <<EOF
+[Install]
+Alias=link5copy.service
+Alias=link5alias.service
+Alias=link5alias2.service
+EOF
+
+test ! -e "$root/etc/systemd/system/link5copy.service"
+
+"$systemctl" --root="$root" link '/link5copy.service'
+islink "$root/etc/systemd/system/link5copy.service" '/link5copy.service'
+test ! -h "$root/etc/systemd/system/link5alias.service"
+test ! -h "$root/etc/systemd/system/link5alias2.service"
+
+# FIXME: we must create link5alias2 and link5alias as relative links to link5.service
+# When they are independent links to /link5.service, systemd doesn't know that
+# they are aliases, because we do not follow symlinks outside of the search paths.
+
+"$systemctl" --root="$root" disable 'link5copy.service'
+test ! -h "$root/etc/systemd/system/link5copy.service"
+test ! -h "$root/etc/systemd/system/link5alias.service"
+test ! -h "$root/etc/systemd/system/link5alias2.service"
+
+"$systemctl" --root="$root" enable '/link5copy.service'
+islink "$root/etc/systemd/system/link5copy.service" '/link5copy.service'
+islink "$root/etc/systemd/system/link5alias.service" '/link5copy.service'
+islink "$root/etc/systemd/system/link5alias2.service" '/link5copy.service'
+
+"$systemctl" --root="$root" disable 'link5copy.service'
+test ! -h "$root/etc/systemd/system/link5copy.service"
+test ! -h "$root/etc/systemd/system/link5alias.service"
+test ! -h "$root/etc/systemd/system/link5alias2.service"
+
: ----issue 19437: plain templates in .wants/ or .requires/---
test ! -e "$root/etc/systemd/system/link5@.path"
cat >"$root/etc/systemd/system/link5@.path" <<EOF