test: merge TEST-49-RUNTIME-BIND-PATHS into TEST-23-UNIT-FILE
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
# shellcheck disable=SC2016
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
# Test adding new BindPaths while unit is already running
|
||||
|
||||
at_exit() {
|
||||
set +e
|
||||
|
||||
rm -f /run/testsuite-23-marker-{fixed,runtime}
|
||||
rm -fr /run/inaccessible
|
||||
}
|
||||
|
||||
trap at_exit EXIT
|
||||
|
||||
echo "MARKER_FIXED" >/run/testsuite-23-marker-fixed
|
||||
mkdir /run/inaccessible
|
||||
|
||||
systemctl start testsuite-23-namespaced.service
|
||||
|
||||
# Ensure that inaccessible paths aren't bypassed by the runtime setup,
|
||||
(! systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-fixed /run/inaccessible/testfile-marker-fixed)
|
||||
|
||||
echo "MARKER_RUNTIME" >/run/testsuite-23-marker-runtime
|
||||
|
||||
systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime
|
||||
|
||||
timeout 10 sh -xec 'while [[ "$(systemctl show -P SubState testsuite-23-namespaced.service)" == running ]]; do sleep .5; done'
|
||||
systemctl is-active testsuite-23-namespaced.service
|
||||
|
||||
# Now test that systemctl bind fails when attempted on a non-namespaced unit
|
||||
systemctl start testsuite-23-non-namespaced.service
|
||||
|
||||
(! systemctl bind --mkdir testsuite-49-non-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime)
|
||||
|
||||
timeout 10 sh -xec 'while [[ "$(systemctl show -P SubState testsuite-23-non-namespaced.service)" == running ]]; do sleep .5; done'
|
||||
(! systemctl is-active testsuite-23-non-namespaced.service)
|
||||
@@ -1,13 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Service]
|
||||
RuntimeMaxSec=300
|
||||
# Adding a new mounts at runtime works if the unit is in the active state,
|
||||
# so use Type=notify to make sure there's no race condition in the test
|
||||
Type=notify
|
||||
RemainAfterExit=yes
|
||||
MountAPIVFS=yes
|
||||
PrivateTmp=yes
|
||||
BindPaths=/run/testservice-49-fixed:/tmp/testfile_fixed
|
||||
InaccessiblePaths=/run/inaccessible
|
||||
ExecStartPre=grep -q -F MARKER_FIXED /tmp/testfile_fixed
|
||||
ExecStart=/bin/sh -c 'systemd-notify --ready; while ! grep -q -F MARKER_RUNTIME /tmp/testfile_runtime; do sleep 0.1; done; test ! -f /run/inaccessible/testfile_fixed'
|
||||
@@ -1,6 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Service]
|
||||
RuntimeMaxSec=10
|
||||
Type=notify
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/bin/sh -c 'systemd-notify --ready; while ! grep -q -F MARKER_RUNTIME /tmp/testfile_runtime; do sleep 0.1; done; exit 0'
|
||||
@@ -1,8 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Unit]
|
||||
Description=TEST-49-RUNTIME-BIND-PATHS
|
||||
|
||||
[Service]
|
||||
ExecStartPre=rm -f /failed /testok
|
||||
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
|
||||
Type=oneshot
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eux
|
||||
|
||||
echo "MARKER_FIXED" >/run/testservice-49-fixed
|
||||
mkdir -p /run/inaccessible
|
||||
|
||||
systemctl start testsuite-49-namespaced.service
|
||||
|
||||
# Ensure that inaccessible paths aren't bypassed by the runtime setup
|
||||
set +e
|
||||
systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-fixed /run/inaccessible/testfile_fixed && exit 1
|
||||
set -e
|
||||
|
||||
echo "MARKER_RUNTIME" >/run/testservice-49-runtime
|
||||
|
||||
systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-runtime /tmp/testfile_runtime
|
||||
|
||||
while systemctl show -P SubState testsuite-49-namespaced.service | grep -q running
|
||||
do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
systemctl is-active testsuite-49-namespaced.service
|
||||
|
||||
# Now test that systemctl bind fails when attempted on a non-namespaced unit
|
||||
systemctl start testsuite-49-non-namespaced.service
|
||||
|
||||
set +e
|
||||
systemctl bind --mkdir testsuite-49-non-namespaced.service /run/testservice-49-runtime /tmp/testfile_runtime && exit 1
|
||||
set -e
|
||||
|
||||
while systemctl show -P SubState testsuite-49-non-namespaced.service | grep -q running
|
||||
do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
set +e
|
||||
systemctl is-active testsuite-49-non-namespaced.service && exit 1
|
||||
set -e
|
||||
|
||||
echo OK >/testok
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user