teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

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

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