Commit graph

4783 commits

Author SHA1 Message Date
Richard Maw 2fd849016b test: Shut down tests on crash
If an assert in systemd fails it can't shut down normally.

By default it freezes. For interactive runs we want the crash shell
to enable further debugging, but during test runs we want it to exit
without having to wait for the test timeout.

By deactivating the crash shell, enabling reboot, and configuring qemu
so that it shuts down instead of rebooting we can shut down instead.

Because by default UEFI will enroll keys and then reboot
we also have to set --qemu-firmware-variables=custom
so it doesn't need to auto-enroll.

Because mkosi has to handle not receiving an EXIT_STATUS notification
it falls back to the exit code of qemu, which in the case of reboot
would be 0, we also override the success exit status to 123
and check that we got that as an exit code from mkosi.
2024-04-24 11:01:45 +02:00
Richard Maw 796cf1b483 test: document when writable /usr overlays may be needed 2024-04-24 11:01:45 +02:00
Daan De Meyer b85e54961c test: Various mkosi integration test improvements
- Stop using logging module since the default output formatting is
  pretty bad. Prefer print() for now.
- Log less, logging the full mkosi command line is rather verbose,
  especially when it contains multi-line dropins.
- Streamline the journalctl command we output for debugging failed
  tests.
- Don't force usage of the disk image format.
- Don't force running without unit tests.
- Don't force disabling RuntimeBuildSources.
- Update documentation to streamline the command for running a single
  test and remove sudo as it's not required anymore.
- Improve the console output by having the test unit's output logged
  to both the journal and the console.
- Disable journal console log forwarding as we have journal forwarding
  as a better alternative.
- Delete existing journal file before running test.
- Delete journal files of succeeded tests to reduce disk usage.
- Rename system_mkosi target to just mkosi
- Pass in mkosi source directory explicitly to accomodate arbitrary
  build directory locations.
- Add test interactive debugging if stdout is connected to a tty
- Stop explicitly using the 'system' image since it'll likely be
  dropped soon.
- Only forward journal if we're not running in debugging mode.
- Stop using testsuite.target and instead just add the necessary
  extras to the main testsuite unit via the credential dropin.
- Override type to idle so test output is not interleaved with
  status output.
- Don't build mkosi target by default
- Always add the mkosi target if mkosi is found
- Remove dependency of the integration tests on the mkosi target
  as otherwise the image is always built, even though we configure
  it to not be built by default.
- Move mkosi output, cache and build directory into build/ so that
  invocations from meson and regular invocations share the same
  directories.
- Various aesthetic cleanups.
2024-04-23 10:32:42 +02:00
Daan De Meyer 741d59b326 test: Rework TEST-02-UNITTESTS
Currently, A large amount of unit test output is logged directly
to the console instead of to the per test log file as any subprocesses
executed by a test manager will detect that stderr is not connected
to the journal and log directly to /dev/console instead.

To solve this issue, let's make sure all tests are connected directly
to the journal by running them with systemd-run. We also simplify the
entire test script by getting rid of the custom queue and replicating
it with xargs instead. By using bash's function export feature, we can
make our run_test() function available to the bash subprocess spawned
by xargs.

Once a test is finished, we read its logs from the journal and put them
in the appropriate file if needed.
2024-04-22 19:37:13 +02:00
Lennart Poettering f92868db4e
Merge pull request #32369 from DaanDeMeyer/serial
terminal-util: Enable line wrapping in reset_terminal_fd()
2024-04-22 17:48:14 +02:00
Luca Boccassi edd3d4d7c2 nspawn: ensure single-process container running as --user can access credentials
When starting a container with --user, the new uid will be resolved and switched to
only in the inner child, at the end of the setup, by spawning getent. But the
credentials are set up in the outer child, long before the user is resolvable,
and the directories/files are made only readable by root and read-only, which
means they cannot be changed later and made visible to the user.

When this particular combination is specified, it is obvious the caller wants
the single-process container to be able to use credentials, so make them world
readable only in that specific case.

Fixes https://github.com/systemd/systemd/issues/31794
2024-04-22 15:47:44 +02:00
Daan De Meyer f57705d67d terminal-util: Enable line wrapping in reset_terminal_fd()
The qemu seabios firmware disables serial console line wrapping. Let's
make sure we re-enable it again when we reset a terminal to some sane
defaults.

To avoid potentially blocking on writing to the terminal, we put it
in nonblocking mode and add a timeout of 50ms.
2024-04-22 15:28:26 +02:00
Luca Boccassi 93cb78aee2 core: add ExecMainHandoverTimestamp property recording time-of-execve
Enable the exec_fd logic for Type=notify* services too, and change it
to send a timestamp instead of a '1' byte. Record the timestamp in a
new ExecMainHandoverTimestamp property so that users can track accurately
when control is handed over from systemd to the service payload, so
that latency and startup performance can be trivially and accurately
tracked and attributed.
2024-04-22 15:16:05 +02:00
Yu Watanabe 0fe4a1c870 test-network: add test for [IPv6SendRA] ReachableTimeSec= and RetransmitSec= 2024-04-22 18:42:56 +09:00
Lennart Poettering b7866fa6aa
Merge pull request #31987 from flatcar-hub/krnowak/usr-perm-check
sysext: Fix issues with merged hierarchy mode
2024-04-22 11:14:35 +02:00
Yu Watanabe d51377ac42 test-network: add test for global UseDomains= setting 2024-04-20 12:01:53 +09:00
Luca Boccassi 565f6130b2
Merge pull request #32142 from bluca/portable_vpick
portable: support vpick
2024-04-19 20:34:16 +02:00
Luca Boccassi 8257508c58 portable: support vpick
Resolve at attach/detach/inspect time, so that the image is pinned and requires
re-attaching on update, given files are extracted from it so just passing
img.v/ to RootImage= is not enough to get a portable image updated
2024-04-19 13:25:32 +01:00
Krzesimir Nowak d74d69ae53 test: Make the sysext test to run with --root and without
I was bitten several times by testing things only with --root flag, so this
commit prepares the existing test cases to run on / too. This required the test
cases to clean up after themselves, thus I have put each test case in a
separate subshell and used traps to do the cleanups.

I needed to change the hierarchy used by the test extension to /opt, because
unmounting /usr often failed with EBUSY.
2024-04-19 10:24:17 +02:00
Krzesimir Nowak 60c335a4bc test: Do not limit hierarchies 2024-04-19 07:20:52 +02:00
Krzesimir Nowak 140f834333 test: Add sysext test case for checking valid mutable directory mode 2024-04-19 07:18:38 +02:00
Krzesimir Nowak 6aab53b175 test: Add sysext test-cases for checking mode preservation 2024-04-19 07:15:01 +02:00
Luca Boccassi e54bf3fe0b
Merge pull request #32299 from yuwata/network-radv-ignore-rs-from-the-same-interface
network/radv: ignore RS message from the same interface
2024-04-18 23:45:06 +02:00
Lennart Poettering dd37963aff
Merge pull request #31790 from poettering/pcrlock-policy-fix
Replace PolicyAuthValue by PolicySigned as access policy for pcrlock policy nvindex
2024-04-18 21:11:27 +02:00
Luca Boccassi 0c8bda7dc3
Merge pull request #32121 from CodethinkLabs/basic-mkosi-integration-tests
Basic mkosi integration tests
2024-04-18 21:02:41 +02:00
Lennart Poettering 36769db1b0 ci: update tests to showcase new option a bit 2024-04-18 18:12:24 +02:00
Richard Maw 945b722f13 test: Add mkosi-based integration test runner
The first two tests are included to ensure parallel test execution is
demonstrable.
2024-04-18 16:26:38 +01:00
Luca Boccassi 966d7977c7 portablectl: add --clean parameter for detaching
Calls CleanUnit on each portable service being removed, after it has
stopped
2024-04-18 10:47:29 +01:00
Yu Watanabe 3b4eeccd27 test-network: add test case of RS sent by the same interface 2024-04-18 09:40:23 +09:00
Yu Watanabe 45c2bbbaea test-network: introduce check_networkd_log() helper function 2024-04-18 09:40:23 +09:00
Yu Watanabe 864c7980c0 test-network: drop trailing spaces
Follow-up for fb57300743.
2024-04-18 09:40:23 +09:00
Yu Watanabe 88382e8dab test: fix typo
Follow-up for 236634c82c.
2024-04-17 13:29:39 +09:00
Yu Watanabe e27f2ad6be
Merge pull request #32300 from mrc0mmand/assorted-tweaks
test: split TEST-50-DISSECT into smaller parts
2024-04-17 11:52:30 +09:00
Sam Leonard b6183109cb
test-64-udev-storage: partition disk inside testcase - testcase_multipath_basic_failover 2024-04-16 17:02:31 +01:00
Sam Leonard 211062e3b5
test-64-udev-storage: partition disk inside testcase - testcase_virtio_scsi_identically_named_partitions 2024-04-16 16:18:55 +01:00
Sam Leonard 8d82e39046
test-64-udev-storage: partition disk inside testcase - testcase_long_sysfs_path 2024-04-16 16:18:36 +01:00
Frantisek Sumsal 236634c82c test: rework systemd-sysext test
Let's rework the test a bit, namely:
  - condense the code a bit
  - drop unnecessary braces around variables
  - drop unnecessary explanations around `touch` calls
  - drop/rename functions to make the code more self-explanatory
  - simplify cleanup a bit
  - create R/O bind mounts directly (supported since util-linux 2.27)
2024-04-16 14:25:57 +02:00
Frantisek Sumsal 5f42fae2f1 test: simplify unit check 2024-04-16 14:25:57 +02:00
Frantisek Sumsal 5d259f1236 test: split some overly long lines
Let's get the line count back up again by splitting some overly long
lines in hopes to make the code slightly more readable.
2024-04-16 14:25:57 +02:00
Frantisek Sumsal ccb2671539 test: split TEST-50-DISSECT into smaller parts
As the current version has almost 2k lines.
2024-04-16 14:25:57 +02:00
Yu Watanabe 78d5bad2f5
Merge pull request #32294 from yuwata/network-generator-creds
network-generator: also load drop-ins for networkd.conf from credentials
2024-04-16 16:42:59 +09:00
Yu Watanabe 9c202ba2e2 test: add test case for 'networkctl cat' without arguments 2024-04-16 13:31:14 +09:00
Yu Watanabe 9a4a8fbe48 test: add test case for network.conf.* credential 2024-04-16 12:45:08 +09:00
Yu Watanabe a3e4edd1af test: add test for systemd-udev-load-credentials.service 2024-04-16 10:35:13 +09:00
Yu Watanabe b2800ec597 udevadm-control: check if control command really specified
Previously, 'udevadm control' only checked the number of the arguments.
So, if only `--timeout` is specified, it spuriously did nothing and succeeded.
This makes the command request at least one control command.
2024-04-16 09:42:20 +09:00
Luca Boccassi a4328b284e
Merge pull request #32258 from yuwata/network-tc-fix-stack-overflow
network/tc: fix stack overflow
2024-04-15 22:34:39 +02:00
Yu Watanabe ae9fd433d6
Merge pull request #32194 from henryli001/lihl/add-defaultUseDomains-config
network: add mechanism to configure default UseDomains= setting
2024-04-14 13:40:06 +09:00
Henry Li fb57300743 network: add mechanism to configure default UseDomains= setting, update man page and add test 2024-04-13 16:54:31 -07:00
Yu Watanabe e6fa91195b test-network: add test for stack overflow in qdisc_drop() and tclass_drop() 2024-04-13 09:39:55 +09:00
Frantisek Sumsal 844af666ed test: add instructions on how to run Coverity locally
This requires a Coverity license, so the usefulness of the instructions
is somewhat limited, but at least I won't have to re-discover everything
from scratch when I need to debug something Coverity-related again in the
future.
2024-04-12 14:42:00 +02:00
Yu Watanabe 9944629eee network/ndisc: fix verification of sender of Redirect message
The sender must be the first-hop router of the destination. Previously,
we only accepted Redirect messages whose sender is the current default
router with the highest priority.

See RFC 4861 section 8.1 for more details.

Fixes #31981.
2024-04-12 04:59:42 +09:00
Yu Watanabe 2e73aa507b network/ndisc: do not set per-route MTU and hop limit
Setting MTU announced in RA message to routes is problematic, as the
value may be larger than the device MTU (IFLA_MTU), and in such case the
route cannot be used.

These two properties are now set per-interface, and gracefully handled
such invalid cases. Hence not necessary to set them to each route.

Follow-up for #32195.
2024-04-12 04:59:38 +09:00
Frantisek Sumsal 6d13aacaac test: make sd-journal-gatewayd tests even more debug-able
Unfortunately bfd30e8af6 is not enough and the test fails, that still
occasionally occur, don't provide enough information to see what's
wrong. Let's rework the test a little to improve this, namely:

  - redirect curl's output into a temporary file instead of piping it
    directly into the "check" expression; that way we can simply dump
    the temporary file when the test fails, providing potentially
    crucial information. We don't want to always dump everything to
    stdout, as some of the tests request an entire system journal (note
    that shell redirection instead of `curl -o file` is used
    intentionally, so the output file is always nuked first)
  - by dropping the pipes in curl commands we can re-enable pipefail
  - also, split some very long commands to multiple lines to (slightly)
    improve readability

Follow-up for bfd30e8af6.
2024-04-11 14:42:45 +02:00
Frantisek Sumsal 8d9cdb31f7 test: make the output of TEST-69 less painful to read
The logs from TEST-69 still contain a lot of unnecessary shell
metacharacters, so to make the output more readable let's just set
TERM=dumb, instead of having to strip everything semi-manually. Also,
move the related --background= tweak to TEST-69, since it's relevant
only for that particular test.

Follow-up for 8d4bfd38ed.
2024-04-11 11:35:17 +02:00
Luca Boccassi 798ea5c05a
Merge pull request #32181 from YHNdnzj/open-file
Some fixes/improvements for OpenFile=
2024-04-10 23:15:56 +01:00