Cleanups for test/units directory (#38807)

This commit is contained in:
Yu Watanabe
2025-09-04 18:11:27 +09:00
committed by GitHub
77 changed files with 46 additions and 59 deletions
@@ -1,14 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
assert_eq "$LISTEN_FDS" "$1"
assert_eq "$LISTEN_FDNAMES" "$2"
for ((i = 3; i < 3 + LISTEN_FDS; i++)); do
assert_eq "$(cat /proc/self/fd/"$i")" "${!i}" # Dereference $i to get i'th arg
done
@@ -1,15 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
assert_eq "$LISTEN_FDS" "$1"
assert_eq "$LISTEN_FDNAMES" "$2"
for ((i = 3; i < 3 + LISTEN_FDS; i++)); do
read -r -u "$i" text
assert_eq "$text" "${!i}" # Dereference $i to get i'th arg
done
@@ -1,18 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -ex
if [ -f /tmp/TEST-23-UNIT-FILE.counter ] ; then
read -r counter < /tmp/TEST-23-UNIT-FILE.counter
counter=$((counter + 1))
else
counter=0
fi
echo "$counter" >/tmp/TEST-23-UNIT-FILE.counter
if [ "$counter" -eq 5 ] ; then
systemctl kill --kill-whom=main -sUSR1 TEST-23-UNIT-FILE.service
fi
exec sleep 1.5
@@ -31,8 +31,8 @@ busctl call \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" "$TEST_UNIT" replace 4 \
ExecStart "a(sasb)" 1 \
/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh \
5 /usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh 2 "test:other" "Hello" "Extra" \
/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh \
5 /usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-ExtraFileDescriptors-child.sh 2 "test:other" "Hello" "Extra" \
true \
RemainAfterExit "b" true \
Type "s" oneshot \
+2 -2
View File
@@ -28,7 +28,7 @@ systemd-run -p DynamicUser=yes -p EnvironmentFile=-/usr/lib/systemd/systemd-asan
-p RemainAfterExit=yes \
--unit=test-23-openfile-existing.service \
--service-type=oneshot \
/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-openfile-child.sh 2 "open.txt:colon" "Open" "File"
/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-openfile-child.sh 2 "open.txt:colon" "Open" "File"
cmp <(systemctl show -p OpenFile test-23-openfile-existing.service) <<EOF
OpenFile=/tmp/test-open-file/open.txt::read-only
@@ -43,7 +43,7 @@ systemctl start TEST-23-UNIT-FILE-openfile-server.socket
systemd-run -p OpenFile=/tmp/test.sock:socket:read-only \
--wait \
/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-openfile-child.sh 1 "socket" "Socket"
/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-openfile-child.sh 1 "socket" "Socket"
systemctl stop TEST-23-UNIT-FILE-openfile-server.socket
-3
View File
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
ExecStart=sleep 3600
-10
View File
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Create a lot of memory pressure
[Service]
# A VERY small memory.high will cause the 'stress-ng' (trying to use a lot of memory)
# to throttle and be put under heavy pressure.
MemoryHigh=3M
Slice=TEST-55-OOMD-workload.slice
ExecStart=stress-ng --timeout 3m --vm 10 --vm-bytes 200M --vm-keep
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=No memory pressure
[Service]
MemoryHigh=3M
Slice=TEST-55-OOMD-workload.slice
ExecStart=sleep infinity
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Create some memory pressure
[Service]
MemoryHigh=12M
Slice=TEST-55-OOMD-workload.slice
ExecStart=stress-ng --timeout 3m --vm 10 --vm-bytes 200M --vm-keep
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Test slice for memory pressure kills
[Slice]
MemoryAccounting=true
IOAccounting=true
TasksAccounting=true
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Slice]
# Fedora and friends has a drop-in config for the settings in
# /usr/lib/systemd/user/slice.d/ . Hence, settings in the main .slice may be
# overridden. Let's set below in a drop-in with higher decimal prefix.
ManagedOOMMemoryPressure=kill
ManagedOOMMemoryPressureLimit=20%
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-62-RESTRICT-IFACES-all-pings-work
[Service]
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.1'
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.5'
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.9'
RestrictNetworkInterfaces=
Type=oneshot
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-62-RESTRICT-IFACES-allow-list
[Service]
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.1'
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.5'
ExecStart=sh -c '! ping -c 1 -W 0.2 192.168.113.9'
RestrictNetworkInterfaces=veth0
RestrictNetworkInterfaces=veth1
Type=oneshot
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-62-RESTRICT-IFACES-deny-list
[Service]
ExecStart=sh -c '! ping -c 1 -W 0.2 192.168.113.1'
ExecStart=sh -c '! ping -c 1 -W 0.2 192.168.113.5'
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.9'
RestrictNetworkInterfaces=~veth0
RestrictNetworkInterfaces=~veth1
Type=oneshot
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-62-RESTRICT-IFACES-empty-assignment
[Service]
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.1'
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.5'
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.9'
RestrictNetworkInterfaces=veth0
RestrictNetworkInterfaces=
Type=oneshot
@@ -1,11 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-62-RESTRICT-IFACES-invert-assignment
[Service]
ExecStart=sh -c '! ping -c 1 -W 0.2 192.168.113.1'
ExecStart=sh -c 'ping -c 1 -W 0.2 192.168.113.5'
ExecStart=sh -c '! ping -c 1 -W 0.2 192.168.113.9'
RestrictNetworkInterfaces=veth0
RestrictNetworkInterfaces=veth0 veth1
RestrictNetworkInterfaces=~veth0
Type=oneshot
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-62-RESTRICT-IFACES-altname
[Service]
ExecStart=/bin/sh -c 'ping -c 1 -W 0.2 192.168.113.1'
ExecStart=/bin/sh -c 'ping -c 1 -W 0.2 192.168.113.5'
ExecStart=/bin/sh -c '! ping -c 1 -W 0.2 192.168.113.9'
RestrictNetworkInterfaces=veth0-altname-with-more-than-15-chars
RestrictNetworkInterfaces=veth1-altname-with-more-than-15-chars
Type=oneshot
+6
View File
@@ -510,6 +510,12 @@ systemd-analyze verify /tmp/testwarnings.service
rm /tmp/testwarnings.service
TESTDATA=/usr/lib/systemd/tests/testdata/TEST-65-ANALYZE.units
systemd-analyze verify "${TESTDATA}/loopy.service"
systemd-analyze verify "${TESTDATA}/loopy2.service"
systemd-analyze verify "${TESTDATA}/loopy3.service"
systemd-analyze verify "${TESTDATA}/loopy4.service"
# Added an additional "INVALID_ID" id to the .json to verify that nothing breaks when input is malformed
# The PrivateNetwork id description and weight was changed to verify that 'security' is actually reading in
# values from the .json file when required. The default weight for "PrivateNetwork" is 2500, and the new weight
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Service that uses device isolation
[Service]
DevicePolicy=strict
DeviceAllow=/dev/null r
StandardOutput=file:/tmp/TEST-66-DEVICE-ISOLATION.serviceresults
ExecStartPre=rm -f /tmp/TEST-66-DEVICE-ISOLATION.serviceresults
ExecStart=bash -c "while true; do sleep 0.01 && echo meow >/dev/null && echo thisshouldnotbehere; done"
-9
View File
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=A conjugate
Requires=a.service
After=a.service
Before=a.service
[Service]
ExecStart=true
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=A
Requires=b.service
Before=b.service
[Service]
ExecStart=true
+11
View File
@@ -1,4 +1,15 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# We use a custom autorelabel service instead of the SELinux provided set of
# units & a generator, since the generator overrides the default target to the
# SELinux one when it detects /.autorelabel. However, we use systemd.unit= on
# the kernel command cmdline which always takes precedence, rendering all
# SELinux efforts useless. Also, pulling in selinux-autorelabel.service
# explicitly doesn't work either, as it doesn't check for the presence of
# /.autorelabel and does the relabeling unconditionally which always ends with
# a reboot, so we end up in a reboot loop (and it also spews quite a lot of
# errors as it wants /etc/fstab and dracut-initramfs-restore).
[Unit]
Description=Relabel all filesystems
DefaultDependencies=no
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=B
Wants=f.service
[Service]
ExecStart=true
-22
View File
@@ -1,22 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Basic System
Documentation=man:systemd.special(7)
Requires=sysinit.target
Wants=sockets.target timers.target paths.target slices.target
After=sysinit.target sockets.target paths.target slices.target tmp.mount
# We support /var, /tmp, /var/tmp, being on NFS, but we don't pull in
# remote-fs.target by default, hence pull them in explicitly here. Note that we
# require /var and /var/tmp, but only add a Wants= type dependency on /tmp, as
# we support that unit being masked, and this should not be considered an error.
RequiresMountsFor=/var /var/tmp
Wants=tmp.mount
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=C
Requires=a.service
[Service]
ExecStart=true
-9
View File
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=D:Cyclic
After=b.service
Before=a.service
Requires=a.service
[Service]
ExecStart=true
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Daughter Service
[Service]
Slice=parent.slice
Type=oneshot
ExecStart=true
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML discard empty service
[Service]
Slice=dml-discard.slice
Type=oneshot
ExecStart=true
-9
View File
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML discard set ml service
[Service]
Slice=dml-discard.slice
Type=oneshot
ExecStart=true
MemoryLow=15
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML discard slice
[Slice]
DefaultMemoryLow=
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML override empty service
[Service]
Slice=dml-override.slice
Type=oneshot
ExecStart=true
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML override slice
[Slice]
DefaultMemoryLow=10
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML passthrough empty service
[Service]
Slice=dml-passthrough.slice
Type=oneshot
ExecStart=true
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML passthrough set DML service
[Service]
Slice=dml-passthrough.slice
Type=oneshot
ExecStart=true
DefaultMemoryLow=15
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML passthrough set ML service
[Service]
Slice=dml-passthrough.slice
Type=oneshot
ExecStart=true
MemoryLow=0
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML passthrough slice
[Slice]
MemoryLow=100
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=DML slice
[Slice]
DefaultMemoryLow=50
-9
View File
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=E:Cyclic
After=b.service
Before=a.service
Wants=a.service
[Service]
ExecStart=true
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=F
[Service]
ExecStart=true
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=G
Conflicts=e.service
[Service]
ExecStart=true
-8
View File
@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Grandchild Service
[Service]
Slice=parent-deep.slice
Type=oneshot
ExecStart=true
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=H
Wants=g.service
[Service]
ExecStart=true
-9
View File
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=I
Conflicts=a.service d.service
Wants=b.service
After=b.service
[Service]
ExecStart=true
-3
View File
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
ExecStart=true
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
BindsTo=loopy2.service
[Install]
Also=loopy2.service
-3
View File
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
ExecStart=true
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
ExecStart=true
[Unit]
Conflicts=loopy4.service
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
ExecStart=true
[Unit]
Conflicts=loopy4.service
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Nomem Parent Slice
[Slice]
DisableControllers=memory
-10
View File
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Nomem Leaf Service
[Service]
Slice=nomem.slice
Type=oneshot
ExecStart=true
IOWeight=200
MemoryAccounting=true
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Deeper Parent Slice
[Slice]
MemoryAccounting=yes
-6
View File
@@ -1,6 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Parent Slice
[Slice]
IOWeight=200
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Bad sched priority for Idle
[Service]
ExecStart=true
CPUSchedulingPriority=1
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Sched idle with prio 0
[Service]
ExecStart=true
CPUSchedulingPriority=0
-9
View File
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Bad sched priority for RR
[Service]
ExecStart=true
CPUSchedulingPriority=-1
CPUSchedulingPriority=100
CPUSchedulingPolicy=rr
-10
View File
@@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Change prio
[Service]
ExecStart=true
CPUSchedulingPriority=1
CPUSchedulingPriority=2
CPUSchedulingPriority=99
CPUSchedulingPolicy=rr
-7
View File
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Default prio for RR
[Service]
ExecStart=true
CPUSchedulingPolicy=rr
-14
View File
@@ -1,14 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Shutdown
Documentation=man:systemd.special(7)
DefaultDependencies=no
RefuseManualStart=yes
-12
View File
@@ -1,12 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Sockets
Documentation=man:systemd.special(7)
-9
View File
@@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Son Service
[Service]
Slice=parent.slice
Type=oneshot
ExecStart=true
CPUWeight=100
@@ -1,3 +0,0 @@
[Service]
Type=notify
ExecStart=bash -c "echo failure >> /tmp/success-failure-test-result && systemd-notify --ready && sleep infinity"
@@ -1,3 +0,0 @@
[Service]
Type=notify
ExecStart=bash -c "echo success >> /tmp/success-failure-test-result && systemd-notify --ready && sleep infinity"
-9
View File
@@ -1,9 +0,0 @@
[Unit]
OnSuccess=success-failure-test-success.service
OnFailure=success-failure-test-failure.service
[Service]
Type=notify
Restart=always
ExecStart=bash -c 'test -f /tmp/success-failure-test-ran && touch /tmp/success-failure-test-ran2 && systemd-notify --ready && sleep infinity'
ExecStopPost=touch /tmp/success-failure-test-ran
-15
View File
@@ -1,15 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=System Initialization
Documentation=man:systemd.special(7)
Conflicts=emergency.service emergency.target
Wants=local-fs.target swap.target
After=local-fs.target swap.target emergency.service emergency.target
-15
View File
@@ -1,15 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Timers
Documentation=man:systemd.special(7)
DefaultDependencies=no
Conflicts=shutdown.target
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=override0
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Documentation=man:override1
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Documentation=man:override2
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Documentation=man:override3
@@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=A unit with multiple dashes
Documentation=man:test
[Service]
ExecStart=true
@@ -1,3 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=override4