]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: wait for user service or slice to be finished
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Jul 2022 06:45:24 +0000 (15:45 +0900)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 22 Jul 2022 19:47:09 +0000 (19:47 +0000)
Hopefully fixes #24040.

test/units/testsuite-35.sh

index d2cd36005afc05700ec43c8d2b84ebdf221b9b25..6e556519b478e55f2f4b23b79a37c2275aa7c609 100755 (executable)
@@ -221,15 +221,32 @@ test_shutdown() {
 cleanup_session() (
     set +ex
 
-    systemctl stop getty@tty2.service
-    rm -rf /run/systemd/system/getty@tty2.service.d
-    systemctl daemon-reload
+    local uid
+
+    uid=$(id -u logind-test-user)
 
     loginctl disable-linger logind-test-user
 
-    pkill -u "$(id -u logind-test-user)"
+    systemctl stop getty@tty2.service
+
+    pkill -u "$uid"
     sleep 1
-    pkill -KILL -u "$(id -u logind-test-user)"
+    pkill -KILL -u "$uid"
+
+    if ! timeout 30 bash -c "while systemctl is-active --quiet user@${uid}.service; do sleep 1; done"; then
+        echo "WARNING: user@${uid}.service is still active, ignoring."
+    fi
+
+    if ! timeout 30 bash -c "while systemctl is-active --quiet user-runtime-dir@${uid}.service; do sleep 1; done"; then
+        echo "WARNING: user-runtime-dir@${uid}.service is still active, ignoring."
+    fi
+
+    if ! timeout 30 bash -c "while systemctl is-active --quiet user-${uid}.slice; do sleep 1; done"; then
+        echo "WARNING: user-${uid}.slice is still active, ignoring."
+    fi
+
+    rm -rf /run/systemd/system/getty@tty2.service.d
+    systemctl daemon-reload
 
     return 0
 )