Commit Graph

6129 Commits

Author SHA1 Message Date
Yu Watanabe
8685f8edd1 TEST-64-UDEV-STORAGE: forcibly create new physical volume
When the test VM is accidentally rebooted, there exists the previously
created volume, and the command fails with the following:
```
TEST-64-UDEV-STORAGE.sh[282]: + lvm pvcreate -y /dev/md/mdlvm
TEST-64-UDEV-STORAGE.sh[442]:   Can't initialize physical volume "/dev/md127" of volume group "mdlvm_vg" without -ff
TEST-64-UDEV-STORAGE.sh[442]:   /dev/md127: physical volume not initialized.
[FAILED] Failed to start TEST-64-UDEV-STORAGE-mdadm_lvm.service.
```
Let's ignore the existence of previous volume and forcibly create new one.

Workaround for issue #38240.
2025-09-11 00:06:33 +09:00
Luca Boccassi
994af53395 test: propagate log env vars in run-unit-tests.py wrapper
To make it easier to debug unit test failures
2025-09-10 14:34:01 +01:00
Luca Boccassi
9cc9e14ed4 test: remove extension from /var/lib/extensions at the end of the test
Otherwise it remains there, and another test case accidentally
uses it on refresh, which then makes another later test fail,
as the hierarchy is already merged:

[  203.969708] TEST-50-DISSECT.sh[890]: + systemd-sysext status
[  203.981831] TEST-50-DISSECT.sh[2795]: HIERARCHY EXTENSIONS SINCE
[  203.982196] TEST-50-DISSECT.sh[2795]: /opt      app0       Mon 2025-09-08 11:49:11 UTC
[  203.982551] TEST-50-DISSECT.sh[2795]: /usr      app0       Mon 2025-09-08 11:49:11 UTC

[  204.119772] TEST-50-DISSECT.sh[2799]: Hierarchy '/usr' is already merged.

Fixes https://github.com/systemd/systemd/issues/38282
2025-09-09 08:52:37 +02:00
Luca Boccassi
28edbbdc1b test: add more debug output
The test occasionally fails with:

TEST-50-DISSECT.sh[3852]: Hierarchy '/usr' is already merged.

I can't really tell what is already merged as all previous ops
look as they are undone from the logs, so add status/list commands
just before the failing operation to hopefully give more info

For https://github.com/systemd/systemd/issues/38282
2025-09-05 12:13:25 +02:00
Luca Boccassi
7b53fd6215 Clean up redirection ops in tests (#38827) 2025-09-05 09:41:53 +01:00
Zbigniew Jędrzejewski-Szmek
e1485c0546 tests: drop pointless redirection of stderr from 'command -v'
The whole point of using 'command -v' is that it's a very portable
way to check if an executable exists. It doesn't print an error.
2025-09-05 08:29:52 +02:00
Zbigniew Jędrzejewski-Szmek
51fac9a0bf TEST-75-RESOLVED: drop whitespace after shell redirection ops 2025-09-05 08:29:52 +02:00
Daan De Meyer
cadeaef67c test: Add test for nspawn's handling of cap_net_bind_service 2025-09-05 08:24:39 +02:00
Daan De Meyer
f70754b34f TEST-13-NSPAWN: Fix typo 2025-09-05 08:24:39 +02:00
Yu Watanabe
2985840855 test: re-enable journal checks for varlink-idl and so on
Previously, we have checked journal after TEST-XX-YYYYY.sh, but it was
forgotten when we switched to mkosi.
This re-enable the check but through ExecStartPost=, and drops unnecessary
workarounds for end.service. Then, this drops unnecessary end.service
and testsuite.target.
2025-09-04 19:50:28 +09:00
Yu Watanabe
df25e4af16 test: do not call GetUserRecord without "service" argument
Otherwise, following debugging log will be saved and the checker for
the varlink-idl log triggers failure:
```
systemd-userwork: processing[3110]: varlink-6-6: Parameters for method
  io.systemd.UserDatabase.GetUserRecord() didn't pass validation on field 'service': No anode
```
2025-09-04 19:50:28 +09:00
Yu Watanabe
b10619484d Cleanups for test/units directory (#38807) 2025-09-04 18:11:27 +09:00
Daan De Meyer
67573e8b8b repart: add test case for btrfs specific options and MountPoint=, and update man page (#38756)
Closes #38749.
2025-09-04 09:00:09 +02:00
Daan De Meyer
af5dde2097 core/transaction: fix issue in dropping unmergeable jobs (#38776)
Fixes #38765.
2025-09-04 08:57:59 +02:00
Daan De Meyer
fcb90e6f55 core: fix segfault by drop-in config for masked unit (#38810) 2025-09-04 08:41:26 +02:00
Yu Watanabe
c02f570260 TEST-87-AUX-UTILS-VM: rotate journal at one more place
Follow-ups for ab56a96194.

Fixes the following failure:
```
TEST-87-AUX-UTILS-VM.sh[1196]: + systemd-run --user --wait --pipe -M testuser@.host -- coredumpctl
TEST-87-AUX-UTILS-VM.sh[1840]: Running as unit: run-p1840-i1841.service; invocation ID: 325a026377aa4cffb046c5a63a8906ab
TEST-87-AUX-UTILS-VM.sh[1853]: Hint: You are currently not seeing messages from other users and the system.
TEST-87-AUX-UTILS-VM.sh[1853]:       Users in groups 'adm', 'systemd-journal', 'wheel' can see all messages.
TEST-87-AUX-UTILS-VM.sh[1853]:       Pass -q to turn off this notice.
TEST-87-AUX-UTILS-VM.sh[1853]: Journal file /var/log/journal/6835d335b6684b6197bf071ad66f2678/user-4711.journal is truncated, ignoring file.
TEST-87-AUX-UTILS-VM.sh[1853]: No coredumps found.
TEST-87-AUX-UTILS-VM.sh[1840]:           Finished with result: exit-code
TEST-87-AUX-UTILS-VM.sh[1840]: Main processes terminated with: code=exited, status=1/FAILURE
TEST-87-AUX-UTILS-VM.sh[1840]:                Service runtime: 154ms
TEST-87-AUX-UTILS-VM.sh[1840]:              CPU time consumed: 78ms
TEST-87-AUX-UTILS-VM.sh[1840]:                    Memory peak: 21.9M (swap: 0B)
```
2025-09-04 08:39:39 +02:00
Yu Watanabe
642744b492 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.
2025-09-04 14:36:46 +09:00
Yu Watanabe
b419e927ee test: add comment about custom autorelabel.service
Salvaged from ead814a0b0.
2025-09-04 11:02:13 +09:00
Yu Watanabe
023de38782 TEST-07-PID1: add test cases for mask/unmask unit
For issue #38802.
2025-09-04 10:58:33 +09:00
Yu Watanabe
5b89cc2a5a test: add test case for issue #38765 2025-09-04 02:05:09 +09:00
Yu Watanabe
e34f8128b1 TEST-58-REPART: add test case for btrfs specific options and MountPoint= 2025-09-04 01:45:38 +09:00
Yu Watanabe
e4f15fc140 TEST-58-REPART: make sector size test as a normal test case 2025-09-04 01:34:04 +09:00
Yu Watanabe
cbbed2bd44 TEST-45-TIMEDATE: rotate journal before parsing log message
Similar to 04ade57a42.

Fixes the following failure (long line is wrapped):
```
TEST-45-TIMEDATE.sh[234]: + journalctl --sync
TEST-45-TIMEDATE.sh[234]: + for _ in {0..9}
TEST-45-TIMEDATE.sh[234]: + journalctl -q -n 1 '--since=2025-09-01 17:09:25.442936' -p info -t busctl --grep .
TEST-45-TIMEDATE.sh[363]: Sep 01 17:09:25 H busctl[351]: {"type":"signal","endian":"l","flags":1,"version":1,
  "cookie":67,"timestamp-realtime":1756746565578529,"sender":":1.11","path":"/org/freedesktop/timedate1",
  "interface":"org.freedesktop.DBus.Properties","member":"PropertiesChanged","payload":{"type":"sa{sv}as",
    "data":["org.freedesktop.timedate1",{"NTP":{"type":"b","data":false}},[]]}}
TEST-45-TIMEDATE.sh[366]: ++ journalctl -q -n 1 '--since=2025-09-01 17:09:25.442936' -p info -t busctl -o cat
TEST-45-TIMEDATE.sh[367]: ++ jq -r '.payload.data[1].NTP.data'
TEST-45-TIMEDATE.sh[366]: Journal file /run/log/journal/07946b7846564ac0ad1c86e8cabed329/system.journal is truncated, ignoring file.
TEST-45-TIMEDATE.sh[234]: + [[ '' == \f\a\l\s\e ]]
```
2025-09-02 09:38:51 +01:00
Nick Rosbrook
1be088c299 test: ensure that reload updates DNSSEC and DNSOverTLS on link scopes 2025-08-27 22:33:38 +09:00
Nick Rosbrook
f818c3d6b6 test: use numeric prefixes in resolved.conf.d overrides
There are a lot of resolved.conf.d drop-ins used in these tests. Use
proper numeric prefixes, especially to avoid confusion with sorting
relative to test.conf.

Make the test base config 10-test.conf, and use 90-*.conf elsewhere.
2025-08-27 22:33:38 +09:00
Yu Watanabe
aed28d0c57 TEST-46-HOMED: homectl unregister and friends needs the target is inactive or absent
Hence, we need to wait for the previous operation finished.
Fixes the following failure:
```
TEST-46-HOMED.sh[107]: + homectl unregister signtest
TEST-46-HOMED.sh[1449]: Failed to unregister home: Home signtest is currently being used, or an operation on home signtest is currently being executed.
```

Fixes #38643
2025-08-22 02:28:58 +09:00
Yu Watanabe
5fb7b67556 TEST-46-HOMED: cleanup homedsshtest earlier 2025-08-22 01:11:35 +09:00
Yu Watanabe
88fce09026 nspawn: fix --link-journal=host with --private-users=pick and friends
Fixes #38611.
2025-08-20 16:17:59 +09:00
Yu Watanabe
045227426e test: fix typo 2025-08-20 16:17:11 +09:00
Luca Boccassi
490aa05ca1 chase: invert CHASE_NO_AUTOFS and only set it where needed
Since c5de7b14ae
file searching implies a new mount api syscall by default,
to trigger automounts.

This is problematic in NSS plugins, as they are dlopen'ed inside
processes by glibc, for two reasons.

First of all, potentially searching on a networked filesystem
automount could lead to nasty surprises, such as the process
responsible for setting up the network filesystem trying to
search on that same filesystem.

More importantly, the new mount api syscall was never part of
the filesystem seccomp filter that we provide by default, and
given mounting/remounting/bind mounting is one of the possible
ways to bypass sandboxing it is very likely not allowed when
custom filters are used in sandboxed processes, if they don't
need to do these operations otherwise.
The filesystem seccomp mask we provide has been updated, however
this only takes effect on the next restart of a service. When
systemd is upgraded via a package upgrade, the new nss plugin is
installed and will be immediately dlopen'ed by glibc when needed,
without waiting for the process to restart, which means the existing
seccomp filter applies, causing the filter to trigger.
Given it's not really possible for any arbitrary program to
predict which NSS modules glibc will load, given programs do not
configure that and instead nsswitch is set up by the sysadmin,
it's impossible to handle at each process level. It's also not
possible to know when it will be triggered, given the plugin
is not linked in each binary tools like need-restart cannot
even pre-emptively restart services that may be affected.

This means in practice, upgrading from systemd << v258 to >= v258
requires a reboot to avoid either subtle or catastrophic system
failures.

By avoiding to trigger automounts in nss-systemd we can avoid
both issues.

userdb drop-ins are searched for in:

/etc/userdb/
/run/userdb/
/run/host/userdb/
/usr/local/lib/userdb/
/usr/lib/userdb/

none of which are supported as automounts anyway.

Note that this happens only when the userdbd service is not running,
as otherwise nss-systemd will go through the varlink IPC, rather than
doing the searches in-process.

So invert CHASE_NO_AUTOFS to CHASE_AUTOFS and set it in the places where
we do want to trigger automounts, like looking for the ESP.

Follow-up for c5de7b14ae
Fixes https://github.com/systemd/systemd/issues/38565
2025-08-19 16:48:13 +02:00
Luca Boccassi
b1cd38e893 test: also edit /etc/os-release if it's not a symlink when patching /usr/lib/os-release (#38628)
mkosi patches up /etc/os-release to add local IDs and fixup certain
issues, so when tests patch /usr/lib/ on the fly, copy to the version in
/etc/ too to avoid test failures when querying

6370s 10/98 systemd:integration-tests / TEST-07-PID1 FAIL 31.03s exit
status 1
6370s 25/98 systemd:integration-tests / TEST-29-PORTABLE FAIL 12.76s
exit status 1
6370s 33/98 systemd:integration-tests / TEST-43-PRIVATEUSER-UNPRIV FAIL
6.57s exit status 1
6370s 37/98 systemd:integration-tests / TEST-50-DISSECT FAIL 16.97s exit
status 1

This is particularly an issue when running these tests on debian unstable,
where mkosi has to fixup os-release to make it valid and avoid further
breakages:

https://github.com/systemd/mkosi/blob/main/mkosi/distributions/debian.py#L234
2025-08-19 12:32:00 +01:00
Yu Watanabe
04ade57a42 TEST-17-UDEV: rotate journal after pending journal entries in buffer before flushed
Then, expected journal entries should be in the archived journal, hence
hopefully we can safely get them.

Follow-up for 5e4115e59e.
2025-08-17 11:16:57 +01:00
Yu Watanabe
61226bd3e2 test: drop unnecessary service file
Such test service unit is now generated automatically.

Follow-up for 7eb276dced.
2025-08-16 19:22:43 +01:00
Yu Watanabe
1a360ed196 condition: fix unexpected assertion triggered
Follow-up for c154bb65ad.
Fixes oss-fuzz#438513119.
Fixes #38570.
2025-08-14 10:31:03 +01:00
Yu Watanabe
30f1d29f39 tree-wide: various terminal related fixlets (#38544)
Fixes #38524.
Fixes #38527.
Fixes #38552.
2025-08-14 03:40:44 +09:00
Yu Watanabe
660244a7fc core: do not start watchdog for frozen service on daemon-reload/-reexec (#38553)
Fixes #38551.
2025-08-14 01:18:50 +09:00
Yu Watanabe
53878b5b3e TEST-72-SYSUPDATE: fix indentation and drop space in blank line 2025-08-13 23:54:26 +09:00
Yu Watanabe
535539222d TEST-72-SYSUPDATE: make randomly generated image file not have compression header
Otherwise, the generated image may be wrongly detected as compressed,
and importing the image may fail:
```
[   35.194578] TEST-72-SYSUPDATE.sh[411]: + dd if=/dev/urandom of=/var/tmp/test-72-N7uTeO/source/part1-v5.raw bs=4096 count=2048
[   35.236342] TEST-72-SYSUPDATE.sh[1075]: 2048+0 records in
[   35.236342] TEST-72-SYSUPDATE.sh[1075]: 2048+0 records out
[   35.236342] TEST-72-SYSUPDATE.sh[1075]: 8388608 bytes (8.4 MB, 8.0 MiB) copied, 0.0408601 s, 205 MB/s
(snip)
[   35.948634] TEST-72-SYSUPDATE.sh[1085]: \ Acquiring /var/tmp/test-72-N7uTeO/source/part1-v5.raw → /proc/self/fd/3p2...
[   35.952878] TEST-72-SYSUPDATE.sh[1085]: Successfully forked off '(sd-import-raw)' as PID 1089.
[   35.958952] TEST-72-SYSUPDATE.sh[1089]: Importing '/var/tmp/test-72-N7uTeO/source/part1-v5.raw', saving at offset 9437184 in '/dev/loop0'.
[   35.959575] TEST-72-SYSUPDATE.sh[1089]: Failed to decode and write: Input/output error
[   35.959575] TEST-72-SYSUPDATE.sh[1089]: Exiting.
```

Fixes #38524.
2025-08-13 23:54:18 +09:00
Yu Watanabe
5e4115e59e TEST-17-UDEV: rotate journal before checking
Otherwise, journal files may be rotated during checking journal entries
and the main system journal file may not be loaded:
```
[  350.372652] TEST-17-UDEV.sh[5841]: + test b253:2 = b253:2
[  350.373288] TEST-17-UDEV.sh[5841]: + [[ 1 == \1 ]]
[  350.373722] TEST-17-UDEV.sh[5841]: + journalctl -n 1 -q -u systemd-udevd.service --invocation=0 --grep 'Found inotify watch .*457'
[  350.374534] TEST-17-UDEV.sh[5970]: Journal file /run/log/journal/edc1fb58daff00ad89d6c8d9689bf172/system.journal is truncated, ignoring file.
[  350.375415] TEST-17-UDEV.sh[415]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/TEST-17-UDEV.watch.sh failed'
```

Fixes #38559.
2025-08-13 09:36:35 +01:00
Yu Watanabe
ee76ac1411 TEST-38-FREEZER: use 'systemctl show' to get freezer state
Also, use timeout command for waiting freezer state applied.
2025-08-13 12:30:31 +09:00
Yu Watanabe
0e25939a9d TEST-38-FREEZER: check if watchdog is not restarted by systemctl daemon-reload or daemon-reexec 2025-08-13 10:45:36 +09:00
Luca Boccassi
208ba34a43 test: add coverage for kernel keyring in TEST-50-DISSECT
Use the kernel keyring to verify images in the dissect test.
The userspace keyring is still covered by the DDI and mountfsd tests.
2025-08-11 10:59:51 +01:00
Luca Boccassi
25178aadb2 service: stop/reset watchdog on freeze/thaw
Otherwise the unit will be killed by the watchdog given it's frozen
but the clock keeps ticking

Fixes https://github.com/systemd/systemd/issues/38517
2025-08-11 10:26:32 +09:00
Yu Watanabe
df75dd34f6 test-network: also save the current state of socket units for resolved and stop them
Silence the following waring:
```
Stopping 'systemd-resolved.service', but its triggering units are still active:
systemd-resolved-varlink.socket, systemd-resolved-monitor.socket
```

Follow-up for 0fa188307b.
2025-08-08 19:38:27 +09:00
Luca Boccassi
c892e33979 nspawn: fix recursive bind mounts
Follow-up for 90fa161b5b

Fixes https://github.com/systemd/systemd/issues/38505
2025-08-08 10:53:02 +09:00
Luca Boccassi
2af77abb1c test: ensure printf builtin buffers and does a single write when piping into socat
Should hopefully solve this:

[  111.084463] systemd[1]: testservice-50k.service: Got notification message from PID 2651: RELOADING=1
[  111.085980] systemd[1]: testservice-50k.service: Got notification message from PID 2651: MONOTONIC_USEC=111072508

ie, pid1 receives RELOADING=1 and MONOTONIC_USEC= in different messages instead
of a single one, and reload-notify breaks

Follow-up for 3998b30a04

Fixes https://github.com/systemd/systemd/issues/37626
2025-08-06 00:21:22 +01:00
Yu Watanabe
3d4977a12b TEST-64-UDEV-STORAGE: mdadm --zero-superblock seems to not support symlink
On CentOS 9:
```
TEST-64-UDEV-STORAGE.sh[522]: + mdadm -v --zero-superblock --force /dev/disk/by-id/scsi-0systemd_foobar_deadbeefmdadmlvm0 ...
TEST-64-UDEV-STORAGE.sh[1014]: mdadm: Unrecognised md component device - /dev/disk/by-id/scsi-0systemd_foobar_deadbeefmdadmlvm4
```

This also adds `udevadm settle` before clearing superblocks for safety.

Follow-up for 5ad6fe9850.
2025-08-05 12:19:54 +01:00
Yu Watanabe
7b20a5cbf3 TEST-13-NSPAWN: wait for a few seconds after markers found
Otherwise, the scope that the nspawn container belonging to may be
removed before the grandchild process of the machined exits and it may
be SIGKILLed.
```
[  100.829613] systemd-machined[678]: Successfully forked off '(sd-bindmnt)' as PID 2962.
[  100.833366] systemd-nspawn[2953]: Inner child finished, invoking payload.
[  100.836111] (sd-bindmnt)[2962]: Skipping PR_SET_MM, as we don't have privileges.
[  100.836401] (sd-bindmnt)[2962]: Successfully forked off '(sd-bindmnt-inner)' as PID 2964.
[  100.846498] (sd-bindmnt)[2962]: (sd-bindmnt-inner) terminated by signal KILL.
[  100.848846] systemd[1]: machine-TEST\x2d13\x2dNSPAWN.machinectl\x2dbind.7ye.scope: cgroup is empty
[  100.849303] systemd[1]: machine-TEST\x2d13\x2dNSPAWN.machinectl\x2dbind.7ye.scope: Deactivated successfully.
[  100.849317] systemd[1]: machine-TEST\x2d13\x2dNSPAWN.machinectl\x2dbind.7ye.scope: Changed running -> dead
[  100.849752] systemd[1]: machine-TEST\x2d13\x2dNSPAWN.machinectl\x2dbind.7ye.scope: Consumed 91ms CPU time, 1.3M memory peak.
[  100.850399] systemd-machined[678]: (sd-bindmnt) failed with exit status 1.
[  100.850414] systemd-machined[678]: Child failed.
[  100.854574] systemd-machined[678]: Failed to mount /tmp/marker-varlink on /tmp/marker-varlink in the namespace of machine 'TEST-13-NSPAWN.machinectl-bind.7ye': Protocol error
```

Hopefully fixes #38434.
2025-08-01 09:49:57 +01:00
Luca Boccassi
cb88cf9760 udev/node: fix issue in removing device node symlink (#38419)
Fixes #37823.
2025-07-31 23:20:05 +01:00
Luca Boccassi
090b23e051 test: run test-journal-append binary with info level logging
It is ran thousands of times so the logs are overwhelming otherwise
2025-08-01 05:42:51 +09:00