]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add a testcase for reexecuting with background mount job 23893/head
authorlicunlong <licunlong1@huawei.com>
Fri, 1 Jul 2022 17:41:40 +0000 (02:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 20 Jul 2022 12:06:54 +0000 (21:06 +0900)
test/units/testsuite-60.sh

index 3c391c8efa6ddf488eab3ebc9ce1e7c34cc570e7..186a05686cef5666e3bea5d51b24b8de26e09e84 100755 (executable)
@@ -53,6 +53,45 @@ EOF
     }
 }
 
+test_issue_23796() {
+    local mount_path mount_mytmpfs
+
+    mount_path="$(command -v mount 2>/dev/null)"
+    mount_mytmpfs="${mount_path/\/bin/\/sbin}.mytmpfs"
+    cat >"$mount_mytmpfs" <<EOF
+#!/bin/bash
+sleep ".\$RANDOM"
+exec -- $mount_path -t tmpfs tmpfs "\$2"
+EOF
+    chmod +x "$mount_mytmpfs"
+
+    mkdir -p /run/systemd/system
+    cat >/run/systemd/system/tmp-hoge.mount <<EOF
+[Mount]
+What=mytmpfs
+Where=/tmp/hoge
+Type=mytmpfs
+EOF
+
+    # shellcheck disable=SC2064
+    trap "rm -f /run/systemd/system/tmp-hoge.mount '$mount_mytmpfs'" RETURN
+
+    for ((i = 0; i < 10; i++)); do
+        systemctl --no-block start tmp-hoge.mount
+        sleep ".$RANDOM"
+        systemctl daemon-reexec
+
+        sleep 1
+
+        if [[ "$(systemctl is-failed tmp-hoge.mount)" == "failed" ]] || \
+           journalctl -u tmp-hoge.mount -q --grep "but there is no mount"; then
+                exit 1
+        fi
+
+        systemctl stop tmp-hoge.mount
+    done
+}
+
 : >/failed
 
 systemd-analyze log-level debug
@@ -111,6 +150,9 @@ timeout 2m bash -c 'while systemctl list-units -t mount tmp-meow* | grep -q tmp-
 # test that handling of mount start jobs is delayed when /proc/self/mouninfo monitor is rate limited
 test_issue_20329
 
+# test for reexecuting with background mount job
+test_issue_23796
+
 systemd-analyze log-level info
 
 touch /testok