test: move test units to their own directories

This also add test cases for verifying loopy.service and friends,
which was added by e66047ff62 but never
used in integration tests.
This commit is contained in:
Yu Watanabe
2025-09-04 05:12:21 +09:00
parent b419e927ee
commit 642744b492
76 changed files with 35 additions and 59 deletions

View File

@@ -32,7 +32,7 @@ TEST_RET(cgroup_mask, .sd_booted = true) {
/* Prepare the manager. */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-cgroup-mask", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);

View File

@@ -21,7 +21,7 @@ TEST_RET(default_memory_low, .sd_booted = true) {
return log_tests_skipped("cgroupfs not available");
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-cgroup-unit-default", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);

View File

@@ -89,7 +89,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-engine", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());

View File

@@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
ASSERT_OK(get_testdata_dir("test-sched-prio", &unit_dir));
ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());

View File

@@ -4,7 +4,7 @@ set -eux
set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
. "$(dirname "$0")"/../units/util.sh
assert_eq "$LISTEN_FDS" "$1"
assert_eq "$LISTEN_FDNAMES" "$2"

View File

@@ -4,7 +4,7 @@ set -eux
set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
. "$(dirname "$0")"/../units/util.sh
assert_eq "$LISTEN_FDS" "$1"
assert_eq "$LISTEN_FDNAMES" "$2"

View File

@@ -8,4 +8,4 @@ StartLimitBurst=15
StartLimitIntervalSec=1h
[Service]
ExecStart=/usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE-short-lived.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-23-UNIT-FILE.units/TEST-23-UNIT-FILE-short-lived.sh

View File

@@ -339,15 +339,18 @@ if install_tests
'auxv',
'journal-data',
'knot-data',
'test-journals',
'units',
'test-cgroup-mask',
'test-cgroup-unit-default',
'test-engine',
'test-execute',
'test-fstab-generator',
'test-path',
'test-path-util',
'test-umount',
'test-journals',
'test-network',
'test-network-generator-conversion',
'test-path',
'test-path-util',
'test-sched-prio',
'test-umount',
'integration-tests/TEST-07-PID1/TEST-07-PID1.units',
'integration-tests/TEST-03-JOBS/TEST-03-JOBS.units',
'integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units',
@@ -355,9 +358,15 @@ if install_tests
'integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.units',
'integration-tests/TEST-23-UNIT-FILE/TEST-23-UNIT-FILE.units',
'integration-tests/TEST-30-ONCLOCKCHANGE/TEST-30-ONCLOCKCHANGE.units',
'integration-tests/TEST-38-FREEZER/TEST-38-FREEZER.units',
'integration-tests/TEST-52-HONORFIRSTSHUTDOWN/TEST-52-HONORFIRSTSHUTDOWN.units',
'integration-tests/TEST-55-OOMD/TEST-55-OOMD.units',
'integration-tests/TEST-62-RESTRICT-IFACES/TEST-62-RESTRICT-IFACES.units',
'integration-tests/TEST-63-PATH/TEST-63-PATH.units',
'integration-tests/TEST-65-ANALYZE/TEST-65-ANALYZE.units',
'integration-tests/TEST-66-DEVICE-ISOLATION/TEST-66-DEVICE-ISOLATION.units',
'integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units',
'units',
]
foreach subdir : testdata_subdirs

View File

@@ -10,6 +10,8 @@
[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
After=local-fs.target swap.target
Conflicts=emergency.service emergency.target
Before=emergency.service emergency.target

View File

@@ -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 \

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

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

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

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)

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