teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0187-test-systemctl-enable-extend-the-test-for-repeated-W.patch

8d419f
From 8bd34d04ce8ca0ec4a501973771634083180ecc0 Mon Sep 17 00:00:00 2001
8d419f
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
8d419f
Date: Tue, 15 Mar 2022 10:13:18 +0100
8d419f
Subject: [PATCH] test-systemctl-enable: extend the test for repeated
8d419f
 WantedBy/RequiredBy
8d419f
8d419f
I was considering deduplicating the list of target units in
8d419f
WantedBy/RequiredBy. But to do this meaningfully, we'd need to do alias
8d419f
expansion first, i.e. after the initial parsing is done. This seems to be
8d419f
more trouble than it would be worth.
8d419f
8d419f
Instead, I added tests that we're doing the right thing and creating symlinks
8d419f
as expected. For duplicate links, we create the link, and on the second time we
8d419f
see that the link is already there, so the output is correct.
8d419f
8d419f
(cherry picked from commit 0c003e8305188f25429938c7c4d09c0a5dfc961b)
8d419f
8d419f
Related: #2082131
8d419f
---
8d419f
 test/test-systemctl-enable.sh | 22 ++++++++++++++++++----
8d419f
 1 file changed, 18 insertions(+), 4 deletions(-)
8d419f
8d419f
diff --git a/test/test-systemctl-enable.sh b/test/test-systemctl-enable.sh
8d419f
index 0ed08a9da3..0a0123b9d7 100644
8d419f
--- a/test/test-systemctl-enable.sh
8d419f
+++ b/test/test-systemctl-enable.sh
8d419f
@@ -285,39 +285,53 @@ test ! -h "$root/etc/systemd/system/services.target.wants/templ1@one.service"
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@two.service"
8d419f
 
8d419f
 : -------template enablement w/ default instance--------------
8d419f
-cat >>"$root/etc/systemd/system/templ1@.service" <
8d419f
+cat >"$root/etc/systemd/system/templ1@.service" <
8d419f
+[Install]
8d419f
+# check enablement with
8d419f
+WantedBy=services.target services.target
8d419f
+RequiredBy=other@templ1.target other@%p.target
8d419f
 DefaultInstance=333
8d419f
 EOF
8d419f
-# FIXME: should we deduplicate the target? Right now we warn twice if WantedBy= is repeated.
8d419f
-# WantedBy=services.target services.target
8d419f
 
8d419f
 "$systemctl" --root="$root" enable 'templ1@.service'
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
 
8d419f
 "$systemctl" --root="$root" enable 'templ1@one.service'
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@one.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@one.service" "/etc/systemd/system/templ1@.service"
8d419f
 
8d419f
 "$systemctl" --root="$root" enable 'templ1@two.service'
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@one.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@one.service" "/etc/systemd/system/templ1@.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@two.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@two.service" "/etc/systemd/system/templ1@.service"
8d419f
 
8d419f
 "$systemctl" --root="$root" disable 'templ1@one.service'
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@333.service" "/etc/systemd/system/templ1@.service"
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@one.service"
8d419f
+test ! -h "$root/etc/systemd/system/other@templ1.target.requires/templ1@one.service"
8d419f
 islink "$root/etc/systemd/system/services.target.wants/templ1@two.service" "/etc/systemd/system/templ1@.service"
8d419f
+islink "$root/etc/systemd/system/other@templ1.target.requires/templ1@two.service" "/etc/systemd/system/templ1@.service"
8d419f
 
8d419f
-# disable both remaining links here
8d419f
+# disable remaining links here
8d419f
 "$systemctl" --root="$root" disable 'templ1@.service'
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@.service"
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@333.service"
8d419f
+test ! -h "$root/etc/systemd/system/other@templ1.target.requires/templ1@333.service"
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@one.service"
8d419f
+test ! -h "$root/etc/systemd/system/other@templ1.target.requires/templ1@one.service"
8d419f
 test ! -h "$root/etc/systemd/system/services.target.wants/templ1@two.service"
8d419f
+test ! -h "$root/etc/systemd/system/other@templ1.target.requires/templ1@two.service"
8d419f
 
8d419f
 : -------template enablement for another template-------------
8d419f
 cat >"$root/etc/systemd/system/templ2@.service" <