summaryrefslogtreecommitdiffstats
path: root/test/TEST-07-PID1
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
commitfc53809803cd2bc2434e312b19a18fa36776da12 (patch)
treeb4b43bd6538f51965ce32856e9c053d0f90919c8 /test/TEST-07-PID1
parentAdding upstream version 255.5. (diff)
downloadsystemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz
systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/TEST-07-PID1')
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.service16
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service8
-rwxr-xr-xtest/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.sh6
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service10
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service10
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service10
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue2467.service10
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue2467.socket7
l---------test/TEST-07-PID1/TEST-07-PID1.units/issue2730-alias.mount1
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue2730.mount8
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue27953.service7
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/issue3166-fail-on-restart.service10
l---------test/TEST-07-PID1/TEST-07-PID1.units/local-fs.target.wants/issue2730.mount1
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-no.socket35
-rw-r--r--test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-yes.socket36
-rw-r--r--test/TEST-07-PID1/meson.build10
-rwxr-xr-xtest/TEST-07-PID1/test.sh25
17 files changed, 185 insertions, 25 deletions
diff --git a/test/TEST-07-PID1/TEST-07-PID1.service b/test/TEST-07-PID1/TEST-07-PID1.service
new file mode 100644
index 0000000..53dd54c
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.service
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=TEST-07-PID1
+Wants=basic.target multi-user.target
+After=basic.target
+Before=getty-pre.target
+
+[Service]
+Type=oneshot
+ExecStartPre=rm -f /failed /testok
+ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
+NotifyAccess=all
+# Issue: https://github.com/systemd/systemd/issues/2691
+ExecStop=sh -c 'kill -SEGV $$$$'
+RemainAfterExit=yes
+TimeoutStopSec=270s
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service b/test/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service
new file mode 100644
index 0000000..757f978
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.service
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Issue 14566 Repro
+
+[Service]
+ExecStart=/usr/lib/systemd/tests/testdata/TEST-07-PID1.units/%N.sh
+ExecStopPost=/bin/true
+KillMode=mixed
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.sh b/test/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.sh
new file mode 100755
index 0000000..74fa760
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue14566-repro.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+sleep infinity &
+echo $! >/leakedtestpid
+wait $!
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service b/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service
new file mode 100644
index 0000000..90252b3
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-1.service
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Issue 16115 Repro with on-abnormal
+
+[Service]
+Type=simple
+Restart=on-abnormal
+ExecCondition=/bin/false
+ExecStart=sleep 100
+RestartSec=1
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service b/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service
new file mode 100644
index 0000000..7c65691
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-2.service
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Issue 16115 Repro with on-failure
+
+[Service]
+Type=simple
+Restart=on-failure
+ExecCondition=/bin/false
+ExecStart=sleep 100
+RestartSec=1
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service b/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service
new file mode 100644
index 0000000..c68f93d
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue16115-repro-3.service
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Issue 22257 Repro with Restart=always
+
+[Service]
+Type=simple
+Restart=always
+ExecCondition=/bin/false
+ExecStart=sleep 100
+RestartSec=1
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue2467.service b/test/TEST-07-PID1/TEST-07-PID1.units/issue2467.service
new file mode 100644
index 0000000..99d886f
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue2467.service
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Requires=issue2467.socket
+ConditionPathExistsGlob=/tmp/nonexistent
+# Make sure we hit the socket trigger limit in the test and not the service start limit.
+StartLimitInterval=1000
+StartLimitBurst=1000
+
+[Service]
+ExecStart=true
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue2467.socket b/test/TEST-07-PID1/TEST-07-PID1.units/issue2467.socket
new file mode 100644
index 0000000..209b6bb
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue2467.socket
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Socket]
+ListenStream=/run/test.ctl
+# We might not be fast enough to hit the default limit (20 triggers per 2 secs)
+# in certain environments, i.e. when running without KVM or when collecting
+# coverage. Let's help it a bit in such cases by lowering the limit to 10 seconds.
+TriggerLimitIntervalSec=10
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue2730-alias.mount b/test/TEST-07-PID1/TEST-07-PID1.units/issue2730-alias.mount
new file mode 120000
index 0000000..802f026
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue2730-alias.mount
@@ -0,0 +1 @@
+issue2730.mount \ No newline at end of file
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue2730.mount b/test/TEST-07-PID1/TEST-07-PID1.units/issue2730.mount
new file mode 100644
index 0000000..2ac76c0
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue2730.mount
@@ -0,0 +1,8 @@
+[Mount]
+What=tmpfs
+Where=/issue2730
+Type=tmpfs
+
+[Install]
+WantedBy=local-fs.target
+Alias=issue2730-alias.mount
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue27953.service b/test/TEST-07-PID1/TEST-07-PID1.units/issue27953.service
new file mode 100644
index 0000000..f441067
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue27953.service
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=This unit should not remain active once the shell process exits
+
+[Service]
+Type=oneshot
+ExecStart=sh -c 'sleep infinity & exit 0'
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/issue3166-fail-on-restart.service b/test/TEST-07-PID1/TEST-07-PID1.units/issue3166-fail-on-restart.service
new file mode 100644
index 0000000..b8695d8
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/issue3166-fail-on-restart.service
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Fail on restart
+StartLimitIntervalSec=1m
+StartLimitBurst=3
+
+[Service]
+Type=exec
+ExecStart=false
+Restart=always
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/local-fs.target.wants/issue2730.mount b/test/TEST-07-PID1/TEST-07-PID1.units/local-fs.target.wants/issue2730.mount
new file mode 120000
index 0000000..70a8534
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/local-fs.target.wants/issue2730.mount
@@ -0,0 +1 @@
+../issue2730.mount \ No newline at end of file
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-no.socket b/test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-no.socket
new file mode 100644
index 0000000..8b7964b
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-no.socket
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Test if ExecXYZ= commands don't inherit listen FDs when PassFileDescriptorsToExec= is unset
+
+[Socket]
+# With Accept= set we don't need a corresponding service unit
+Accept=yes
+FileDescriptorName=foo
+ListenStream=127.0.0.1:1234
+ListenStream=[::1]:1234
+PassFileDescriptorsToExec=no
+ExecStartPre=\
+ test ExecStartPre -a \
+ -z ${LISTEN_FDS} -a \
+ -z ${LISTEN_FDNAMES} -a \
+ ! -e /dev/fd/3 -a \
+ ! -e /dev/fd/4
+ExecStartPost=\
+ test ExecStartPost -a \
+ -z ${LISTEN_FDS} -a \
+ -z ${LISTEN_FDNAMES} -a \
+ ! -e /dev/fd/3 -a \
+ ! -e /dev/fd/4
+ExecStopPre=\
+ test ExecStopPre -a \
+ -z ${LISTEN_FDS} -a \
+ -z ${LISTEN_FDNAMES} -a \
+ ! -e /dev/fd/3 -a \
+ ! -e /dev/fd/4
+ExecStopPost=\
+ test ExecStopPost -a \
+ -z ${LISTEN_FDS} -a \
+ -z ${LISTEN_FDNAMES} -a \
+ ! -e /dev/fd/3 -a \
+ ! -e /dev/fd/4
diff --git a/test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-yes.socket b/test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-yes.socket
new file mode 100644
index 0000000..bff192d
--- /dev/null
+++ b/test/TEST-07-PID1/TEST-07-PID1.units/pass-fds-to-exec-yes.socket
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Test if ExecXYZ= commands inherit listen FDs when PassFileDescriptorsToExec= is set
+
+[Socket]
+# With Accept= set we don't need a corresponding service unit
+Accept=yes
+FileDescriptorName=foo
+ListenStream=127.0.0.1:1234
+ListenStream=[::1]:1234
+PassFileDescriptorsToExec=yes
+# ExecStartPre runs before we create sockets. Nothing to pass.
+ExecStartPre=\
+ test ExecStartPre -a \
+ -z ${LISTEN_FDS} -a \
+ -z ${LISTEN_FDNAMES} -a \
+ ! -e /dev/fd/3 -a \
+ ! -e /dev/fd/4
+ExecStartPost=\
+ test ExecStartPost -a \
+ ${LISTEN_FDS} = 2 -a \
+ ${LISTEN_FDNAMES} = foo:foo -a \
+ -S /dev/fd/3 -a \
+ -S /dev/fd/4
+ExecStopPre=\
+ test "ExecStopPre" -a \
+ ${LISTEN_FDS} = 2 -a \
+ ${LISTEN_FDNAMES} = foo:foo -a \
+ -S /dev/fd/3 -a \
+ -S /dev/fd/4
+ExecStopPost=\
+ test "ExecStopPost" -a \
+ ${LISTEN_FDS} = 2 -a \
+ ${LISTEN_FDNAMES} = foo:foo -a \
+ -S /dev/fd/3 -a \
+ -S /dev/fd/4
diff --git a/test/TEST-07-PID1/meson.build b/test/TEST-07-PID1/meson.build
new file mode 100644
index 0000000..311860d
--- /dev/null
+++ b/test/TEST-07-PID1/meson.build
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+integration_tests += [
+ integration_test_template + {
+ 'name' : fs.name(meson.current_source_dir()),
+ 'unit' : files('TEST-07-PID1.service'),
+ },
+]
+
+testdata_subdirs += [meson.current_source_dir() / 'TEST-07-PID1.units']
diff --git a/test/TEST-07-PID1/test.sh b/test/TEST-07-PID1/test.sh
index cc8a81f..2513406 100755
--- a/test/TEST-07-PID1/test.sh
+++ b/test/TEST-07-PID1/test.sh
@@ -11,31 +11,6 @@ NSPAWN_ARGUMENTS="--capability=CAP_NET_ADMIN"
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
- local workspace="${1:?}"
-
- # We might not be fast enough to hit the limit (20 triggers per 2 secs)
- # in certain environments, i.e. when running without KVM or when collecting
- # coverage. Let's help it a bit in such case.
- if ! get_bool "$QEMU_KVM" || get_bool "$IS_BUILT_WITH_COVERAGE"; then
- mkdir -p "$workspace/etc/systemd/system/issue2467.socket.d"
- printf "[Socket]\nTriggerLimitIntervalSec=10\n" >"$workspace/etc/systemd/system/issue2467.socket.d/TriggerLimitInterval.conf"
- fi
-
- # Issue: https://github.com/systemd/systemd/issues/2730
- mkdir -p "$workspace/etc/systemd/system/"
- cat >"$workspace/etc/systemd/system/issue2730.mount" <<EOF
-[Mount]
-What=tmpfs
-Where=/issue2730
-Type=tmpfs
-
-[Install]
-WantedBy=local-fs.target
-Alias=issue2730-alias.mount
-EOF
- "${SYSTEMCTL:?}" enable --root="$workspace" issue2730.mount
- ln -svrf "$workspace/etc/systemd/system/issue2730.mount" "$workspace/etc/systemd/system/issue2730-alias.mount"
-
image_install logger socat
}