Commit graph

1583 commits

Author SHA1 Message Date
Daan De Meyer c709499a4e TEST-50-DISSECT: Use --apparent-size when calling du
Otherwise if the file is full of holes we get the wrong size and
we'll fail later on.
2024-04-24 15:51:37 +02:00
Daan De Meyer 2a9184b902 TEST-50-DISSECT: Skip mountfsd test if the user namespace interface is not supported 2024-04-24 15:51:35 +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 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
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
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
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
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
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
Lennart Poettering 36769db1b0 ci: update tests to showcase new option a bit 2024-04-18 18:12:24 +02: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 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
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
Mike Yuan 48c21790ba
test: merge TEST-77-OPENFILE into TEST-23-UNIT-FILE
And add coverage for #32179
2024-04-10 21:49:28 +08:00
Frantisek Sumsal 721e78ff73 test: give sd-resolved enough time to timeout
The timeout on sd-resolved's side is 5-10s (UDP or TCP), but dig's
default timeout is 5s. Let's give sd-resolved enough time to timeout
before either giving up or checking if it served stale data on dig's
side.

Resolves: #31639
2024-04-09 21:39:46 +02:00
Frantisek Sumsal bfd30e8af6 test: let curl show a potential error in silent mode
I collected a couple of fails in this particular test, but without any
output they're impossible to debug. Let's make this slightly less
annoying and let curl show an error (if any) even in silent mode.

This patch uncovers that curl has been (silently) complaining about not
being able to write to the output destination, because `grep -q`
short-circuits on the first match and doesn't bother reading the rest,
so replace `grep -q` with `grep ... >/dev/null` to force grep to always
read the whole thing from curl.
2024-04-09 21:39:46 +02:00
Lennart Poettering 625646815b test: add integration test for unpriv mountfsd/nsresourced 2024-04-06 16:09:10 +02:00
Zbigniew Jędrzejewski-Szmek c1e7f938ca
Merge pull request #31435 from bluca/portable_fix_versioned
portable: assorted bug fixes
2024-04-05 17:04:17 +02:00
Zbigniew Jędrzejewski-Szmek cdba129b71 TEST-50: add tests for riscv{32,64}
Requested for the testing of F40 riscv bringup. Numbers copied from
https://uapi-group.org/specifications/specs/discoverable_partitions_specification/.

It'd be nice to do the same in TEST-58, but the code there is rather involved
and I don't have a system to test on. We can probably try that later on when F40
is available.
2024-04-04 20:07:57 +02:00
Daan De Meyer 7b62a246a6
Merge pull request #32033 from DaanDeMeyer/unit-creds
debug-generator: Add unit and drop-in credentials
2024-04-04 18:27:20 +02:00
Daan De Meyer 8595f578fe debug-generator: Add unit and drop-in credentials
These allow adding extra units and drop-ins via credentials.
2024-04-04 16:17:38 +02:00
Daan De Meyer c89b3e1dfd test: Always exit with 77 if we skip a test
Prep work for running the integration tests with meson, which requires
tests to exit with 77 to indicate they are skipped.

Note this only deals with the easy cases where there's only tests. The
hard ones where there's subtests of which only some are skipped are left
for another PR.
2024-04-03 09:14:15 +09:00
Frantisek Sumsal 5d7b7bf1d4 test: don't hide exit code of the systemd-run process 2024-04-02 19:00:42 +02:00
Frantisek Sumsal c956bf31f8 test: check if sd-executor doesn't complain during (de)serializing
This was usually caught by "accident" by other tests that parse output
of commands executed by sd-executor, so let's have an explicit check for
this.
2024-04-02 19:00:42 +02:00
Frantisek Sumsal 38d072a175 test: bump the container boot timeout when running w/o acceleration
With plain QEMU on a saturated AWS region we might just barely miss the
timeout window, causing unexpected test fails:

[  688.681324] systemd-nspawn[1332]: [  OK  ] Finished systemd-user-sessions.service.
[  689.451267] systemd-nspawn[1332]: [  OK  ] Started console-getty.service.
[  689.572874] systemd-nspawn[1332]: [  OK  ] Reached target getty.target.
[  693.634609] testsuite-74.sh[1223]: + at_exit
[  693.634609] testsuite-74.sh[1223]: + rm -fv -- /tmp/test-dump /tmp/test-usr-dump /tmp/make-dump
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/test-dump'
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/test-usr-dump'
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/make-dump'
[  693.951114] testsuite-74.sh[670]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-74.coredump.sh failed'
[  693.951114] testsuite-74.sh[670]: Subtest /usr/lib/systemd/tests/testdata/units/testsuite-74.coredump.sh failed
[  693.951114] testsuite-74.sh[670]: + return 1
[  694.659094] systemd[1]: testsuite-74.service: Main process exited, code=exited, status=1/FAILURE
[  694.719563] systemd[1]: testsuite-74.service: Failed with result 'exit-code'.
[  694.882069] systemd[1]: Failed to start testsuite-74.service.
[  695.574445] systemd[1]: Reached target testsuite.target.
[  696.174844] systemd[1]: Starting end.service...
[  699.509408] systemd-nspawn[1332]:
[  699.509408] systemd-nspawn[1332]: CentOS Stream 9
[  699.509408] systemd-nspawn[1332]: Kernel 5.14.0-432.el9.x86_64 on an x86_64 (pts/0)
[  699.509408] systemd-nspawn[1332]:

Also, move the rest of container the setup for the user xattrs test into
the condition, since doing it without the actual test is pretty
pointless.
2024-04-02 19:00:24 +02:00
Luca Boccassi a7f2019055
Merge pull request #32010 from bluca/reexec_rate_limit
core: serialize reload rate limit and apply ReloadLimit to reexec too
2024-03-29 17:16:36 +00:00
Luca Boccassi 8312b17a29 core: apply ReloadLimit to reexec too
Same reason as the reload, reexec is disruptive and it requires the
same privileges, so if somebody wants to limit reloads, they'll also
want to limit reexecs, so use the same setting.
2024-03-29 12:03:32 +00:00
Yu Watanabe fee6510667
Merge pull request #31998 from yuwata/udev-event-mode
udev: make udevadm test and test-builtin not destructive
2024-03-29 11:31:58 +09:00
Yu Watanabe 089bef6631 udev: make udevadm test and test-builtin not destructive
Previously, 'udevadm test' performs not only processing udev rules,
but made several destructive change on the system; updating udev
database, device node permission, devlinks, network interface
properties, and so on.

Similary, 'udevadm test-builtin' may perform something destructive,
especially by 'keyboard', 'kmod', and 'net_setup_link' builtins.

Let's make these commands and test executables not change device
configurations.
2024-03-29 09:33:07 +09:00
Luca Boccassi 373a1e47b2 portable: fix 'portablectl list' to show the actual state for extensions
When listing images they are inspected one by one, so in case of a
portable with extensions they always resulted as not found.
Allow a partial match when listing, so that we can find the appropriate
unit that an image belongs to, and list the correct state as attached.
2024-03-28 14:20:20 +00:00
Luca Boccassi 1cbb792763 Ensure that a portable is not detached when another portable that shares the same base is detached
The matches line includes all images, but the logic returned
immediately with a successful match if the first element matches.
2024-03-28 14:20:20 +00:00
Luca Boccassi 37543971af os-util: allow matching versioned image with extension-release file
Currently app_1.0.raw is refused if it contains extension-release.d/extension-release.app,
which stops one from using versioned images without using the force flag to disable
the check. Relax it so that only the actual name, and not the version, is compared, like
it already happens in other places.
2024-03-28 14:20:20 +00:00
Yu Watanabe e4c7dc9418 test: disable IPv6AcceptRA= for test network interfaces with static address
This hopefully improves test performance.
2024-03-28 12:37:45 +00:00