teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0347-test-wait-for-user-service-or-slice-to-be-finished.patch

594167
From 1fe172a67c2bbbedfd08d6ec5a28386f197962f9 Mon Sep 17 00:00:00 2001
594167
From: Yu Watanabe <watanabe.yu+github@gmail.com>
594167
Date: Fri, 22 Jul 2022 15:45:24 +0900
594167
Subject: [PATCH] test: wait for user service or slice to be finished
594167
594167
Hopefully fixes #24040.
594167
594167
(cherry picked from commit 8015e2587045f8a58a15d4551c76521a4a3ff50c)
594167
594167
Related: #2100464
594167
---
594167
 test/units/testsuite-35.sh | 27 ++++++++++++++++++++++-----
594167
 1 file changed, 22 insertions(+), 5 deletions(-)
594167
594167
diff --git a/test/units/testsuite-35.sh b/test/units/testsuite-35.sh
594167
index d9eccee84f..d55ad6103e 100755
594167
--- a/test/units/testsuite-35.sh
594167
+++ b/test/units/testsuite-35.sh
594167
@@ -221,15 +221,32 @@ test_shutdown() {
594167
 cleanup_session() (
594167
     set +ex
594167
 
594167
-    systemctl stop getty@tty2.service
594167
-    rm -rf /run/systemd/system/getty@tty2.service.d
594167
-    systemctl daemon-reload
594167
+    local uid
594167
+
594167
+    uid=$(id -u logind-test-user)
594167
 
594167
     loginctl disable-linger logind-test-user
594167
 
594167
-    pkill -u "$(id -u logind-test-user)"
594167
+    systemctl stop getty@tty2.service
594167
+
594167
+    pkill -u "$uid"
594167
     sleep 1
594167
-    pkill -KILL -u "$(id -u logind-test-user)"
594167
+    pkill -KILL -u "$uid"
594167
+
594167
+    if ! timeout 30 bash -c "while systemctl is-active --quiet user@${uid}.service; do sleep 1; done"; then
594167
+        echo "WARNING: user@${uid}.service is still active, ignoring."
594167
+    fi
594167
+
594167
+    if ! timeout 30 bash -c "while systemctl is-active --quiet user-runtime-dir@${uid}.service; do sleep 1; done"; then
594167
+        echo "WARNING: user-runtime-dir@${uid}.service is still active, ignoring."
594167
+    fi
594167
+
594167
+    if ! timeout 30 bash -c "while systemctl is-active --quiet user-${uid}.slice; do sleep 1; done"; then
594167
+        echo "WARNING: user-${uid}.slice is still active, ignoring."
594167
+    fi
594167
+
594167
+    rm -rf /run/systemd/system/getty@tty2.service.d
594167
+    systemctl daemon-reload
594167
 
594167
     return 0
594167
 )