Merge pull request #32766 from DaanDeMeyer/test

Various test improvements
This commit is contained in:
Daan De Meyer
2024-05-14 14:45:35 +02:00
committed by GitHub
482 changed files with 1692 additions and 1298 deletions

View File

@@ -71,7 +71,7 @@ jobs:
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: systemd/mkosi@22d212dcb229b553572578ef16c809f9a9961ee8
- uses: systemd/mkosi@55f17a8ae67ece9712324c3107804daad94ad0d9
# Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
# immediately, we remove the files in the background. However, we first move them to a different location

View File

@@ -40,6 +40,9 @@ KernelCommandLine=systemd.crash_shell
panic=-1
softlockup_panic=1
panic_on_warn=1
# These don't ship proper units with [Install] directives so we have to mask them instead.
systemd.mask=isc-dhcp-server.service
systemd.mask=mdmonitor.service
[Host]
Credentials=journal.storage=persistent

View File

@@ -2,6 +2,7 @@
[Config]
Dependencies=minimal-base
ConfigureScripts=
[Distribution]
CacheOnly=always

View File

@@ -2,6 +2,7 @@
[Config]
Dependencies=minimal-base
ConfigureScripts=
[Distribution]
CacheOnly=always

View File

@@ -1,5 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Config]
ConfigureScripts=
[Output]
Format=directory

View File

@@ -20,7 +20,7 @@ ExtraTrees=
%O/minimal-1.root-%a.raw:/usr/share/minimal_1.raw
%O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity
%O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig
%O/minimal-base:/usr/share/testsuite-13-container-template
%O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template
Packages=
acl
@@ -42,7 +42,9 @@ Packages=
kmod
knot
less
lvm2
man
mdadm
mtools
nano
nftables

View File

@@ -30,6 +30,8 @@ Packages=
iputils
linux
man-db
multipath-tools
open-iscsi
openbsd-netcat
openssh
openssl
@@ -44,6 +46,7 @@ Packages=
shadow
squashfs-tools
stress
tgt
tpm2-tools
tpm2-tss
vim

View File

@@ -24,6 +24,8 @@ Packages=
bind-utils
bpftool
cryptsetup
device-mapper-event
device-mapper-multipath
dfuzzer
dhcp-server
dnf
@@ -35,7 +37,9 @@ Packages=
iproute
iproute-tc
iputils
iscsi-initiator-utils
kernel-core
kernel-modules # For squashfs and megasas2
libasan
libcap-ng-utils
libubsan

View File

@@ -9,4 +9,3 @@ RepartDirectories=mkosi.repart
[Content]
Packages=
rpmautospec-rpm-macros
kernel-modules # For squashfs

View File

@@ -54,7 +54,9 @@ Packages=
libtss2-tcti-device0
locales
man-db
multipath-tools
netcat-openbsd
open-iscsi
openssh-client
openssh-server
passwd
@@ -66,6 +68,7 @@ Packages=
sbsigntool
squashfs-tools
stress
tgt
tpm2-tools
tzdata
xxd

View File

@@ -2,3 +2,7 @@
[Match]
Distribution=debian
[Content]
Packages=
linux-image-generic

View File

@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Architecture=x86-64
[Content]
Packages=
linux-image-cloud-amd64

View File

@@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Architecture=arm64
[Content]
Packages=
linux-image-cloud-arm64

View File

@@ -7,8 +7,9 @@ Distribution=fedora
Packages=
btrfs-progs
compsize
f2fs-tools
dnf5
f2fs-tools
scsi-target-utils
InitrdPackages=
btrfs-progs

View File

@@ -50,6 +50,8 @@ Packages=
libasan8
libkmod2
libubsan1
multipath-tools
open-iscsi
openssh-clients
openssh-server
pam
@@ -65,6 +67,7 @@ Packages=
sed
shadow
squashfs
tgt
timezone
tpm2.0-tools
user(bin)

View File

@@ -0,0 +1 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

View File

@@ -0,0 +1,3 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
iscsid.startup = /usr/bin/systemctl start iscsid.socket

View File

@@ -31,3 +31,6 @@ disable auditd.service
# systemd-timesyncd is not enabled by default in the default systemd preset so enable it here instead.
enable systemd-timesyncd.service
# Skipped if selinux is not enabled, required for TEST-06-SELINUX.
enable autorelabel.service

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : 'TEST-01-BASIC',
},
]

View File

@@ -16,14 +16,4 @@ KERNEL_APPEND="foo -- -z bar --- baz $KERNEL_APPEND"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
local dst
# Install tests manually so the test is functional even when -Dinstall-tests=false
dst="$workspace/usr/lib/systemd/tests/testdata/units/"
mkdir -p "$dst"
cp -v "$TEST_UNITS_DIR"/{testsuite-01,end}.service "$TEST_UNITS_DIR/testsuite.target" "$dst"
}
do_test "$@"

View File

@@ -1,15 +1,16 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'mkosi_args': test_params['mkosi_args'] + [
'--kernel-command-line-extra=' + ' '.join([
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'cmdline' : integration_test_template['cmdline'] + [
'''
frobnicate!
systemd.setenv=TEST_CMDLINE_NEWLINE=foo
''',
'''
systemd.setenv=TEST_CMDLINE_NEWLINE=bar
''',
]),
],
}
''',
],
},
]

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-03.units/succeeds-on-restart.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-03-JOBS.units/succeeds-on-restart.sh
Restart=on-failure
RestartMode=direct

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-03.units/succeeds-on-restart.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-03-JOBS.units/succeeds-on-restart.sh
Restart=on-failure
RestartMode=normal

View File

@@ -0,0 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
},
]
testdata_subdirs += [meson.current_source_dir() / 'TEST-03-JOBS.units']

View File

@@ -1,5 +1,12 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'storage': 'persistent',
}
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'storage' : 'persistent',
},
]
testdata_subdirs += [meson.current_source_dir() / 'TEST-04-JOURNAL.units']

View File

@@ -20,7 +20,7 @@ test_append_files() {
# Since we nuke the journal repeatedly during this test, let's redirect
# stdout/stderr to the console as well to make the test a bit more debug-able.
if ! get_bool "${INTERACTIVE_DEBUG:-}"; then
dropin_dir="${workspace:?}/etc/systemd/system/testsuite-04.service.d/"
dropin_dir="${workspace:?}/etc/systemd/system/TEST-04-JOURNAL.service.d/"
mkdir -p "$dropin_dir"
printf '[Service]\nStandardOutput=journal+console\nStandardError=journal+console' >"$dropin_dir/99-stdout.conf"
fi

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : 'TEST-05-RLIMITS',
},
]

View File

@@ -1,7 +1,12 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'mkosi_args' : ['--kernel-command-line-extra=apparmor=0 selinux=1 enforcing=0 lsm=selinux systemd.wants=autorelabel.service systemd.wants=firstboot-autorelabel.service'],
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
}
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'cmdline' : integration_test_template['cmdline'] + ['selinux=1', 'lsm=selinux'],
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
},
]
testdata_subdirs += [meson.current_source_dir() / 'TEST-06-SELINUX.units']

View File

@@ -1,6 +1,9 @@
# 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

View File

@@ -3,6 +3,6 @@
Description=Issue 14566 Repro
[Service]
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-07.units/%N.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-07-PID1.units/%N.sh
ExecStopPost=/bin/true
KillMode=mixed

View File

@@ -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']

View File

@@ -0,0 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'enabled' : false,
},
]

View File

@@ -80,7 +80,7 @@ check_result_qemu_hook() {
# Setup a one shot service in initrd that creates a dummy bind mount under /run
# to check if the mount persists though the initrd transition. The "check" part
# is in the respective testsuite-08.sh script.
# is in the respective TEST-08-INITRD.sh script.
#
# See: https://github.com/systemd/systemd/issues/28452
run_qemu_hook() {

View File

@@ -1,7 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'storage': 'persistent',
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
}
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'storage' : 'persistent',
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
},
]

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
},
]

View File

@@ -13,7 +13,7 @@ TEST_FORCE_NEWIMAGE=1
test_append_files() {
local workspace="${1:?}"
local container="$workspace/usr/share/testsuite-13-container-template"
local container="$workspace/usr/share/TEST-13-NSPAWN-container-template"
# For virtual wlan interface.
instmods mac80211_hwsim

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
},
]

View File

@@ -3,6 +3,10 @@
Description=TEST-16-EXTEND-TIMEOUT
# Testsuite: Assess all other testsuite-*.services worked as expected
Wants=basic.target multi-user.target
After=basic.target
Before=getty-pre.target
Wants=success-all.service
Wants=success-start.service
Wants=success-runtime.service

View File

@@ -10,4 +10,4 @@ TimeoutStartSec=4
TimeoutStopSec=4
RuntimeMaxSec=10
Environment=SERVICE=fail_runtime extend_timeout_interval=5 sleep_interval=7 start_intervals=0 run_intervals=2 stop_intervals=0
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-16.units/extend-timeout.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh

View File

@@ -11,4 +11,4 @@ TimeoutStartSec=10
TimeoutStopSec=4
RuntimeMaxSec=4
Environment=SERVICE=fail_start extend_timeout_interval=5 sleep_interval=7 start_intervals=2 run_intervals=0 stop_intervals=0
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-16.units/extend-timeout.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh

View File

@@ -10,7 +10,7 @@ TimeoutStartSec=4
TimeoutStopSec=10
RuntimeMaxSec=4
Environment=SERVICE=fail_stop extend_timeout_interval=5 sleep_interval=7 start_intervals=0 run_intervals=0 stop_intervals=2
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-16.units/extend-timeout.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh
# Due to 6041a7ee2c1bbff6301082f192fc1b0882400d42 SIGTERM isn't sent as the service shuts down with STOPPING=1
# This file makes the test assess.sh quicker by notifing it that this test has finished.
ExecStopPost=/bin/bash -c '[[ $SERVICE_RESULT == timeout && $EXIT_CODE == killed ]] && touch /fail_runtime.terminated'

View File

@@ -12,4 +12,4 @@ TimeoutStartSec=4
TimeoutStopSec=4
RuntimeMaxSec=4
Environment=SERVICE=success_all extend_timeout_interval=4 sleep_interval=2 start_intervals=3 run_intervals=3 stop_intervals=3
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-16.units/extend-timeout.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh

View File

@@ -11,4 +11,4 @@ TimeoutStartSec=4
TimeoutStopSec=4
RuntimeMaxSec=8
Environment=SERVICE=success_runtime extend_timeout_interval=4 sleep_interval=6 start_intervals=0 run_intervals=1 stop_intervals=0
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-16.units/extend-timeout.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh

View File

@@ -10,4 +10,4 @@ TimeoutStartSec=8
TimeoutStopSec=4
RuntimeMaxSec=4
Environment=SERVICE=success_start extend_timeout_interval=4 sleep_interval=6 start_intervals=1 run_intervals=0 stop_intervals=0
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-16.units/extend-timeout.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh

View File

@@ -10,4 +10,4 @@ TimeoutStartSec=4
TimeoutStopSec=8
RuntimeMaxSec=4
Environment=SERVICE=success_stop extend_timeout_interval=4 sleep_interval=6 start_intervals=0 run_intervals=0 stop_intervals=1
ExecStart=/usr/lib/systemd/tests/testdata/testsuite-16.units/extend-timeout.sh
ExecStart=/usr/lib/systemd/tests/testdata/TEST-16-EXTEND-TIMEOUT.units/extend-timeout.sh

View File

@@ -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-16-EXTEND-TIMEOUT.service'),
},
]
testdata_subdirs += [meson.current_source_dir() / 'TEST-16-EXTEND-TIMEOUT.units']

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
},
]

View File

@@ -1,6 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
}
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
# FIXME; Figure out why reboot sometimes hangs with 'linux' firmware.
'firmware' : 'uefi',
},
]

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
},
]

View File

@@ -1,7 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
test_params += {
'timeout' : 3600,
'priority' : -50,
'slow' : true,
}
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
'timeout' : 3600,
'priority' : -50,
'slow' : true,
},
]

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
},
]

View File

@@ -1,10 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Unit with BindsTo=
BindsTo=testsuite-23-bound-by.service
After=testsuite-23-bound-by.service
BindsTo=TEST-23-UNIT-FILE-bound-by.service
After=TEST-23-UNIT-FILE-bound-by.service
[Service]
ExecStart=sleep infinity
# --kill-who= (no 'm') to check that the short form is accepted
ExecStopPost=systemctl kill --kill-whom=main -sRTMIN+1 testsuite-23.service
ExecStopPost=systemctl kill --kill-whom=main -sRTMIN+1 TEST-23-UNIT-FILE.service

View File

@@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Failing unit
OnFailure=testsuite-23-uphold.service
OnFailure=TEST-23-UNIT-FILE-uphold.service
[Service]
ExecStart=false

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
JoinsNamespaceOf=testsuite-23-joins-namespace-of-1.service
JoinsNamespaceOf=TEST-23-UNIT-FILE-joins-namespace-of-1.service
[Service]
Type=oneshot

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
JoinsNamespaceOf=testsuite-23-joins-namespace-of-1.service
JoinsNamespaceOf=TEST-23-UNIT-FILE-joins-namespace-of-1.service
[Service]
Type=oneshot

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
JoinsNamespaceOf=testsuite-23-joins-namespace-of-5.service
JoinsNamespaceOf=TEST-23-UNIT-FILE-joins-namespace-of-5.service
[Service]
Type=notify

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
JoinsNamespaceOf=testsuite-23-joins-namespace-of-8.service
JoinsNamespaceOf=TEST-23-UNIT-FILE-joins-namespace-of-8.service
[Service]
Type=notify

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
JoinsNamespaceOf=testsuite-23-joins-namespace-of-8.service
JoinsNamespaceOf=TEST-23-UNIT-FILE-joins-namespace-of-8.service
[Service]
Type=oneshot

Some files were not shown because too many files have changed in this diff Show More