1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-06 17:18:12 +03:00
Commit Graph

3927 Commits

Author SHA1 Message Date
Dmitry V. Levin
9e36da1541 udevadm-verify: introduce --no-summary option
When udevadm verify is invoked by an analyzer tool like rpminspect
to verify individual udev rules files, the summary just clutters the
output, so provide an option to turn the summary off.
2023-05-21 23:20:30 +09:00
Mike Yuan
a3d975b240
test: add tests for networkctl edit/cat 2023-05-21 15:55:42 +08:00
Yu Watanabe
b3bd6ccd1e
Merge pull request #27707 from mrc0mmand/tests
test: provide coverage for a couple of recent-ish issues
2023-05-20 08:40:01 +09:00
Yu Watanabe
294c20198b test: replace Makefile for several tests with symlink to the one for TEST-01-BASIC 2023-05-20 05:42:24 +09:00
Yu Watanabe
396f6900ae
Merge pull request #27676 from ldv-alt/udevadm-verify
udevadm-verify: add support for directory arguments
2023-05-20 05:41:05 +09:00
Frantisek Sumsal
a9ec30ab7e test: check if we correctly handle locales with leading spaces
Provides coverage for #27179.
2023-05-19 21:35:47 +02:00
Frantisek Sumsal
305aa43815 tests: run all functions with testcase_ prefix automagically 2023-05-19 20:03:34 +02:00
Frantisek Sumsal
b74df879fc test: check if we correctly handle invalid UTF-8 in mount stuff
Provides coverage for #27611.
2023-05-19 20:03:34 +02:00
Frantisek Sumsal
928733cd86 test: assorted TEST-13-NSPAWN tweaks 2023-05-19 20:03:34 +02:00
Frantisek Sumsal
c11c50a53f test: check if we can use --merge with --follow
Provides coverage for #24565.
2023-05-19 20:03:34 +02:00
Luca Boccassi
d936595672 manager: restrict Dump*() to privileged callers or ratelimit
Dump*() methods can take quite some time due to the amount of data to
serialize, so they can potentially stall the manager. Make them
privileged, as they are debugging tools anyway. Use a new 'dump'
capability for polkit, and the 'reload' capability for SELinux, as
that's also non-destructive but slow.

If the caller is not privileged, allow it but rate limited to 10 calls
every 10 minutes.
2023-05-19 15:18:23 +01:00
Frantisek Sumsal
038efe6df1 test: build the SELinux test module on the host
Let's save some time and build the SELinux test module on the host
instead of a possibly unaccelerated VM. This brings the runtime of
TEST-06-SELINUX from ~12 minutes down to a ~1 minute.
2023-05-19 11:45:11 +02:00
Frantisek Sumsal
daeb95a1d8 test: drop generated stuff from the final coverage report
Let's drop stuff from the current $BUILD_DIR from the final coverage
report, as it's all generated files (mostly gperf) which we don't
really care about and it makes the Coveralls report confusing, since it
reports "source not available" for all such files.
2023-05-19 11:07:07 +02:00
Frantisek Sumsal
ff40235b9b test: make the stress test slightly less stressful on slower machines
Without acceleration this part of the test takes over 10 minutes (!),
which feels quite unnecessary. Let's cut down the number of stuff we
dump to the journal in such case, but keep the original value if we run
with acceleration (since in that case it takes less than 10 seconds).
2023-05-19 10:48:15 +02:00
Yu Watanabe
65f2ff7998
Merge pull request #27685 from keszybz/the-semiannual-excercise-in-output-narrowing
The semiannual excercise in output narrowing
2023-05-19 03:04:47 +09:00
Yu Watanabe
ec0bd9611a
Merge pull request #27684 from mrc0mmand/more-nspawn-tests
test: further extend systemd-nspawn coverage
2023-05-19 03:00:54 +09:00
Dmitry V. Levin
a9802abaee udevadm-verify: add support for directory arguments
When an argument specified to udevadm verify is a directory,
verify all *.rules files in that directory.

Suggested-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2023-05-18 17:00:00 +00:00
Luca Boccassi
8fb26ccd36 integration test: pass 'noresume' to qemu
When running on Debian/Ubuntu, I get a minute delay or so on every boot
because the local initramfs tries to resume from hibernation. This is
not really useful here, so always skip it
2023-05-18 16:45:55 +01:00
Dmitry V. Levin
75390455cb testsuite-17.11.sh: fix assert_1()
Fix assert_1() to exit with an error status in case of a failed assertion.
2023-05-18 15:45:55 +00:00
Frantisek Sumsal
2de77dbfc7 test: wrap setfacl when running with ASan 2023-05-18 17:30:36 +02:00
Zbigniew Jędrzejewski-Szmek
02e0f430a0 meson: rename "dist-check" suite to "dist"
*Now* one of those tests is the longest, let's make them a bit shorter.
2023-05-18 17:18:11 +02:00
Frantisek Sumsal
0d4519dd84 test: don't mount /sys & /proc if already mounted 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
cbd20ab41b test: add a couple of tests for nspawn config files 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
28ed232639 test: create nspawn config files when collecting coverage
Which bind-mounts the $BUILD_DIR into the container. This whole coverage
thing is getting slightly ridiculous.

Follow-up to 3b2823a749, but for non-machinectl containers.
2023-05-18 16:50:24 +02:00
Frantisek Sumsal
d5a6ff8c18 test: cover --bind-user= 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
74696ba5ef test: add a couple of sanity tests for --port= 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
cf260f799f test: drop "check" from test case names 2023-05-18 16:50:24 +02:00
Frantisek Sumsal
f0193b4b63 test: exercise a couple of error paths in nspawn's OCI code as well 2023-05-18 16:50:24 +02:00
Zbigniew Jędrzejewski-Szmek
e2e736cbbd fuzz: rename long samples
With those long filenames, output doesn't fit on the terminal.
2023-05-18 15:23:27 +02:00
Yu Watanabe
f0485be000
Merge pull request #27677 from mrc0mmand/test-followups
test: get rid of the busybox stuff
2023-05-18 17:47:02 +09:00
Frantisek Sumsal
a6dac790c8 test: explicitly use bash
To avoid unexpected surprised in CIs with different default shell.
2023-05-17 23:22:54 +02:00
Frantisek Sumsal
5656759d06 test: get rid of the busybox stuff
It already required a lot of workarounds, since the busybox utilities
often work differently than their "full" counterparts, and putting
the container together using our "tools" is quite simple anyway.
2023-05-17 23:22:54 +02:00
Frantisek Sumsal
c01f0184b9 test: mangle the machine ID only for the QEMU test part
systemd-nspawn doesn't like invalid machine IDs and refuses to boot with one:

TEST-74-AUX-UTILS RUN: Tests for auxiliary utilities
...
Spawning container TEST-74-AUX-UTILS--3 on /var/tmp/systemd-test-TEST-74-AUX-UTILS_3/root.
Press Ctrl-] three times within 1s to kill container.
Failed to read machine ID from container image: Structure needs cleaning
E: nspawn failed with exit code 1

Follow-up to b4d42a82eb.
2023-05-17 15:10:22 +01:00
Frantisek Sumsal
7c6fa5bf16 test: move runas() to the shared utility library 2023-05-16 23:07:45 +02:00
Frantisek Sumsal
e71bac7222 test: make shellcheck happy again
No functional changes.
2023-05-16 23:07:45 +02:00
Frantisek Sumsal
16eb568766 test: merge TEST-48-START-STOP-NO-RELOAD into TEST-23-UNIT-FILE 2023-05-16 23:07:45 +02:00
Frantisek Sumsal
518c3e2722 test: merge TEST-49-RUNTIME-BIND-PATHS into TEST-23-UNIT-FILE 2023-05-16 23:07:45 +02:00
Frantisek Sumsal
ab1b2f22fd test: clean up test artifacts
So we don't run into unexpected fails when two tests use the same paths.
2023-05-16 23:07:45 +02:00
Frantisek Sumsal
23cb7362f1 test: merge TEST-28-PERCENTJ-WANTEDBY into TEST-23-UNIT-FILE 2023-05-16 22:43:52 +02:00
Frantisek Sumsal
fb03fea2a2 test: merge TEST-56-EXIT-TYPE into TEST-19-CGROUP
And clean it up a bit.
2023-05-16 22:43:52 +02:00
Frantisek Sumsal
3999ea001a test: rename TEST-19-DELEGATE to TEST-19-CGROUP
And clean it up a bit.
2023-05-16 22:43:52 +02:00
Frantisek Sumsal
5ff1c6fcde test: introduce get_cgroup_hierarchy() 2023-05-16 22:43:52 +02:00
Frantisek Sumsal
cb153b4fe9 test: rename assert.sh to util.sh
So we can extend it with additional utility functions without making it
confusing.

No functional change.
2023-05-16 22:43:52 +02:00
Frantisek Sumsal
1fd24da616 test: merge TEST-33-CLEAN-UNIT into TEST-23-UNIT-FILE 2023-05-16 22:43:52 +02:00
Frantisek Sumsal
9245eb3cbd test: merge TEST-27-STDOUTFILE into TEST-23-UNIT-FILE 2023-05-16 21:49:09 +02:00
Frantisek Sumsal
b4d42a82eb test: merge TEST-14-MACHINE-ID into TEST-74-AUX-UTILS 2023-05-16 21:49:09 +02:00
Yu Watanabe
871a41f0ef
Merge pull request #27606 from YHNdnzj/loginctl-list-show-state
loginctl: list-{users,sessions}: add a column for showing state
2023-05-17 01:41:13 +09:00
Yu Watanabe
8c7dd49ad1
Merge pull request #27655 from yuwata/udev-net-assign-alternative-names-only-on-add-event
udev/net: assign alternative names only on add event
2023-05-17 01:39:40 +09:00
Frantisek Sumsal
a5a4d5a18e
Merge pull request #27651 from mrc0mmand/more-nspawn-tests
nspawn: OCI related fixes & tests
2023-05-16 17:26:25 +02:00
Mike Yuan
0313c41068
Merge pull request #27638 from YHNdnzj/upheldby-unit-file
unit-file: support UpheldBy= in [Install] settings (adding Upholds= deps from .upholds/)
2023-05-16 21:53:24 +08:00
Mike Yuan
306ff2e297
test: add test for state in loginctl list-{users,sessions} 2023-05-16 18:09:15 +08:00
Yu Watanabe
40b6b448bd test: add tests for renaming network interface 2023-05-16 18:28:18 +09:00
Frantisek Sumsal
f00519b5b3 fuzz: update the base JSON for fuzz-nspawn-oci 2023-05-16 11:27:10 +02:00
Frantisek Sumsal
0d5896a949 test: add a couple of tests for nspawn's OCI stuff 2023-05-16 11:27:10 +02:00
Frantisek Sumsal
806b18240a test: make $BUILD_DIR writable when rootfs is mounted read-only
Adjust two systemd-nspawn invocations where rootfs is mounted read-only,
to avoid gcov complaining.
2023-05-15 10:15:24 +02:00
Frantisek Sumsal
786f6d81f7 test: pass $BUILD_DIR as $COVERAGE_BUILD_DIR to the system manager
To make additional coverage-related tweaks slightly easier.
2023-05-15 10:06:54 +02:00
Mike Yuan
b5b1351317
test: add tests for UpheldBy= in [Install] section 2023-05-15 15:04:38 +08:00
Frantisek Sumsal
1c8bf49b67 test: update nspawn's basic config file used for fuzzing 2023-05-15 09:00:17 +02:00
Frantisek Sumsal
08d547a481 test: rename TEST-13-NSPAWN-SMOKE to TEST-13-NSPAWN
To make it consistent with the rest of the tests.
2023-05-14 19:32:07 +02:00
Frantisek Sumsal
703766408f test: slightly extend the systemd-nspawn tests 2023-05-14 19:32:07 +02:00
Frantisek Sumsal
8416a15e5c test: wait after sending a signal if necessary
On overloaded systems it might take a bit until the signal is sent,
processed, and the respective file is created.
2023-05-14 19:32:07 +02:00
Frantisek Sumsal
807626d1ce test: install the overlayfs/loop modules unconditionally 2023-05-14 19:32:07 +02:00
Frantisek Sumsal
9f596939e4 test: create merged-usr containers 2023-05-14 19:32:07 +02:00
Frantisek Sumsal
3b2823a749 test: bind mount the $BUILD_DIR into nspawn containers
when collecting coverage. This applies only to containers started
via machinectl (or directly via the systemd-nspawn@.service unit).
2023-05-14 19:32:07 +02:00
Frantisek Sumsal
ceea144ed8 test: use dropins to override system configuration
Instead of touching the configuration files directly.
2023-05-14 19:32:07 +02:00
Luca Boccassi
942afbad2a
Merge pull request #27634 from mrc0mmand/TEST-13-shenanigans
test: clean up & extend the nspawn/machinectl test suite
2023-05-13 10:23:14 +01:00
Frantisek Sumsal
a1ff1ac273 test: merge machinectl edit/cat tests into TEST-13 2023-05-13 00:26:38 +02:00
Frantisek Sumsal
990b629e12 test: always install the script utility 2023-05-13 00:26:38 +02:00
Frantisek Sumsal
378db9e2b9 test: add a couple of tests for machinectl 2023-05-13 00:26:38 +02:00
Frantisek Sumsal
c2df08b5b8 test: clean up the nspawn tests a bit 2023-05-12 18:05:29 +02:00
Frantisek Sumsal
e8dba80626 core: fix memory leak during deserialization
when activation-details-unit-name is encountered multiple times.

Resolves: #27623
2023-05-13 00:42:25 +09:00
Yu Watanabe
82c60c939c test-network: add tests for static lease matching with chaddr
Follow-up for 4646cdaa37 (#27313).
2023-05-12 03:07:10 +09:00
Frantisek Sumsal
b0582f6b63 cryptenroll: actually allow using multiple "special" strings when wiping
The systemd-cryptenroll man page states:

    Takes a comma separated list of numeric slot indexes, or the special
    strings ..., or any combination of these strings or numeric
    indexes, in which case all slots matching either are wiped.

but we'd allow only one special string at any given time as the value
was not ORed when assigning. So, for example, --wipe=recovery,password
would actually become --wipe=password, etc.
2023-05-11 13:12:08 +01:00
Yu Watanabe
531a6233d1
Merge pull request #27603 from mrc0mmand/more-test-shenanigans
test: merge PID1-related tests into TEST-07-PID1
2023-05-11 16:48:13 +09:00
Frantisek Sumsal
15bbc0c107 test: abstract the common test parts into a utility script
Also, instead of bailing out on the first failed subtest, always run all
subtests and print a summary at the end (with an appropriate exit code).
2023-05-10 21:26:26 +02:00
Frantisek Sumsal
3a4b86264e test: merge TEST-20-MAINPIDGAMES into TEST-07-PID1 2023-05-10 21:26:26 +02:00
Frantisek Sumsal
d8d8380a35 test: merge TEST-51-ISSUE-16115 into TEST-07-PID1 2023-05-10 21:26:26 +02:00
Frantisek Sumsal
11562ee585 test: merge TEST-47-ISSUE-14566 into TEST-07-PID1 2023-05-10 21:26:26 +02:00
Frantisek Sumsal
8412cdf4fd test: move TEST-23's units into a dedicated subfolder
To remain consistent with other tests.
2023-05-10 21:26:26 +02:00
Frantisek Sumsal
51b6dbf75a test: merge TEST-12-ISSUE-3171 into TEST-07-PID1 2023-05-10 21:26:26 +02:00
Daan De Meyer
1fd5ec5697 tmpfiles: Add merge support for copy files action
If '+' is specified with 'C', let's merge the tree with any existing
tree.
2023-05-10 18:08:07 +02:00
Daan De Meyer
e57b7020d2 repart: Fix deny list logic
Until now, we always excluded the top level directories that were
covered by child partition mount points, regardless of the source
directory and the target directory of the copy files operation.
This means that even if we were populating a XBOOTLDR partition, if
there was an EFI partition in the image, we'd exclude /boot
unconditionally, leading to the XBOOTLDR partition to be empty.

Also, because of the same cause, if we were copying a nested source
directory (e.g. /abc/def) to the root directory in the root
partition, if /abc/def/usr existed and was populated with files and
directories, the root partition would have those files under /usr,
even if a /usr partition was defined.

To fix these issues, instead of unconditionally excluding the top
level partition mount points under <source>, let's make sure that
when we're copying files from any source directory to the root
directory of a root partition, that we exclude the partition mount
point directories under the source directory instead of the top
level ones.
2023-05-10 18:07:47 +02:00
Frantisek Sumsal
33dff897b9 test: merge TEST-11-ISSUE-3166 into TEST-07-PID1 2023-05-10 14:29:38 +02:00
Frantisek Sumsal
a8faac7dae test: merge TEST-10-ISSUE-2467 with TEST-07-PID1 2023-05-10 14:29:38 +02:00
Frantisek Sumsal
4966a31ba3 test: merge TEST-09-ISSUE-2691 into TEST-07-PID1 2023-05-10 14:29:38 +02:00
Frantisek Sumsal
cd62ba42a4 test: merge TEST-08-ISSUE-2730 into TEST-07-PID1 2023-05-10 14:29:38 +02:00
Frantisek Sumsal
09c033a276 test: rename TEST-07-ISSUE-1981 to TEST-07-PID1 2023-05-10 12:38:57 +02:00
Frantisek Sumsal
a9fe7f66e8 test: slightly extend systemd-cryptenroll coverage 2023-05-09 22:47:42 +02:00
Frantisek Sumsal
920eb35db9 test: TEST-70-TPM2 cleanup
No functional changes.
2023-05-09 21:18:36 +02:00
Frantisek Sumsal
b6869359e6 test: add coverage for #27533
Issue: https://github.com/systemd/systemd/issues/27533
Fix: https://github.com/systemd/systemd/pull/27553
2023-05-09 19:59:13 +02:00
Frantisek Sumsal
5e8656e101 test: discard kill's output 2023-05-09 19:55:04 +02:00
Frantisek Sumsal
539af5c441 test: merge unit file related tests into TEST-23-UNIT-FILE
Rename TEST-23-TYPE-EXEC to TEST-23-UNIT-FILE and merge it with
following tests:
  - TEST-37-RUNTIMEDIRECTORYPRESERV
  - TEST-40-EXEC-COMMAND-EX
  - TEST-41-ONESHOT-RESTART
  - TEST-42-EXECSTOPPOST
  - TEST-57-ONSUCCESS-UPHOLD
2023-05-10 02:39:12 +09:00
Zbigniew Jędrzejewski-Szmek
711169905e test: use sed and grep instead of perl
This gets rid of the all-but-one remaining uses of perl. I tested the new code
on my machine, so I'm fairly confident that it works as expected.

install_iscsi() has one majestic perl invocation, but we can't get rid of it
easily: it extends the code of tgt-admin to print some list of files. Obviously
this only works because tgt-admin is written in perl, and perl will be installed
if tgt-admin is installed. install_iscsi() is used in TEST-64-UDEV-STORAGE
conditionally if tgtadm is installed, so this can stay as is.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
b370f050f8 test-execute: use bash instead of perl
I think this is easier to grok too.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
21ec66420a test-udev: skip test on python3.6 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
dcbbc7cef5 test/run-unit-tests, TEST-02: skip tests where the interpeter is not installed
When the interpeter is missing, we get an exit code of 127. Let's treat those
tests as skipped too. If we could run the test far enough so that it could do
the check itself, it would return 77 anyway.

$ test/asdf; echo $?
exec: Failed to execute process 'test/asdf': The file specified the interpreter '/bin/asdf', which is not an executable command.
127
$ test/asdf; echo $?
/usr/bin/env: ‘/bin/asdf’: No such file or directory
127

This should resolve the problem that TEST-02 fails or Debian's 'unit-tests' fail
when python3 is not installed. Installing python3 via the mechanism that is
used to construct TEST images, i.e. the dracut dependency chasing scheme, would
be a lot of work for python with its modules in multiple locations and hundreds
of little files. So I think it OK to just skip the test there, and also in
other cases where python is not available.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
0454cf05d3 test: rework how udev-test is invoked
As part of the build, we would populate build/test/sys/ using
sys-script.py, and then udev-test.p[ly] would create a tmpfs instance
on build/test/tmpfs and copy the sys tree to build/test/tmpfs/sys.

Also, we had udev-test.p[ly] which called test-udev. test-udev was
marked as a manual test and installed, but neither udev-test.p[ly] or
sys-script.py were.

test-udev is renamed to udev-rule-runner, which reduces confusion and
frees up the test-udev name. udev-test.py is renamed to test-udev.py.
All three files are now installed.

test-udev.py is modified to internally call sys-script.py to set up the
sys tree. Copying and creating it from scratch should take the same
amount of time. We avoid having a magic directory, everything is now
done underneath a temporary directory.

test-udev.py is now a normal installed test, and run-unit-tests.py will
pick it up. When test-udev.py is invoked from meson, the path to
udev-rule-runner is passed via envvar; when it is invoked via
run-unit-tests.py or directly, it looks for udev-rule-runner in a relative
path.

The goal of this whole change is to let Debian drop the 'udev' test.
It called sys-script.py and udev-test.pl from the source directory and
had to recreate a bunch of the logic. Now test-udev.py will now be called
via 'upstream'.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
09ea351b6f test: drop udev-test.pl 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
f2c02d232e test: rewrite udev-test.pl in Python
I tried to keep this a 1:1 rewrite with the same field names.
Nevertheless, some changes were made:
- exp_add_error and exp_rem_error are dropped. Those fields meant that
  "./test-udev add <devpath>" actually succeeded, but symlinks were not
  created, and exp_links was ignored and could contain bogus content.
  Instead, exp_links and not_exp_links are adjusted to not contain
  garbage and the tests check that "./test-udev add" succeeds and that
  the links are as expected from exp_links and not_exp_links.
- cleanup was only used in one rule, and that rule was expected to fail,
  so cleanup wasn't actually necessary. So the cleanup field and the
  logic to call cleanup from individual tests is removed.
- a bunch of fields were set, but didn't seem to be connected to any
  implementation: not_exp_name, not_exp_test.
  e62acc3159 did a rewrite of some of the
  tests and it seems that not_exp_test was added by mistake and
  not_exp_name was left behind by mistake.
  In Python, the field list is declared in the class, so it's harder to
  assign an unused attribute. Those uses were converted to not_exp_links.
- in most rules, r"""…""" is used, so that escaping is not necessary.
- the logic to generate devices was only used in one place, and the
  generator function also had provisions to handle arguments that were
  never given. all_block_devs() is made much simpler.
- Descriptions that started with a capital letter were shortened
  and lowercased.
- no special test case counting is done. pytest just counts the cases
  (Rules objects).
- the output for failures is also removed. If something goes wrong, the
  user can use pytest --pdb or such to debug the issue.
- perl version used a semaphore to manage udev runners, and would fork,
  optionally wait a bit, and then start the runner. In the python
  version, we just spawn them all and wait for them to exit. It's not
  very convenient to call fork() from python, so instead the runner
  was modified (in previous commit) to wait.

The test can be called as:
  (cd build && sudo pytest -v ../test/udev-test.py)
  sudo meson test -C build udev-test.py -v

I think this generally provides functionality that is close to the perl
version. It seems some of the checks are now more fully implemented.
Support for strace/gdb/valgrind is missing.

Runtime goes down: 8.36 s → 5.78 s.
2023-05-09 08:11:10 +02:00
Frantisek Sumsal
380a36582d test: add a test case for #27521
Which got resolved by e652663a04.
2023-05-05 22:15:23 +02:00
Frantisek Sumsal
24e91e08f8 core: check the unit type more thoroughly when deserializing
Resolves: #27523
2023-05-05 22:15:23 +02:00
Frantisek Sumsal
cc938f1ce0 shared: refuse fd == INT_MAX
Since we do `FD_TO_PTR(fd)` that expands to `INT_TO_PTR(fd) + 1` which
triggers an integer overflow.

Resolves: #27522
2023-05-05 22:15:23 +02:00
Frantisek Sumsal
b003e2c7a6 test: clean up the test script even further
Most notably:
  - use `systemd-id128 new` instead of `journalctl --new-id128`
  - move all temporary files to /tmp
  - wrap repetitive checks in a function
2023-05-03 18:32:00 +02:00
Frantisek Sumsal
8077d99fd2 test: vacuum the journal after the "stress test"
To make the rest of the test significantly faster.
2023-05-03 17:37:09 +02:00
Frantisek Sumsal
23f83ba768 test: slightly extend checks on corrupted journals 2023-05-03 17:32:36 +02:00
Frantisek Sumsal
c4039ceb9e test: further extend our collection of corrupted journals
And make adding them slightly easier.

Provides coverage for b5335da7a5.
2023-05-03 17:22:37 +02:00
Yu Watanabe
a76dc1f3a0
Merge pull request #27504 from mrc0mmand/fuzz-manager-serialize
test: add a simple fuzzer for manager serialization
2023-05-03 21:45:26 +09:00
Frantisek Sumsal
740831076c shared: reject empty attachment path 2023-05-03 10:09:53 +02:00
Frantisek Sumsal
1febf60f9d shared: ignore invalid valink socket fd when deserializing 2023-05-03 10:09:53 +02:00
Frantisek Sumsal
45b1017488 core: fix NULL pointer dereference during deserialization 2023-05-03 10:09:53 +02:00
Frantisek Sumsal
24e6759cbc test: add a simple fuzzer for manager serialization 2023-05-03 10:09:53 +02:00
Yu Watanabe
e94756c566 test: replace sleep with timeout
If the test environment is too slow, then sleeping 2 seconds may not be
sufficient.
2023-05-02 11:09:18 +02:00
Yu Watanabe
8e2449a5c9 test-network: add workaround for bug in iproute2 v6.2.0
Closes #27473.
2023-05-01 20:02:15 +02:00
Frantisek Sumsal
0f69a4e9ae test: test journalctl with corrupted journals
Last month I monkey-patched journald to produce a small (64K) but valid
journal and used that as an input to four AFL fuzzers. After a month it
generated quite a nice corpora (4738 test cases) and after filtering
and minimizing it I was left with 619 unique journals with various
levels of corruption that probe the journal code.

It seems to detect past issues like systemd#26567, etc.
2023-05-01 10:14:12 +02:00
Frantisek Sumsal
de965f4893 test: clean up the test script a bit 2023-05-01 15:47:04 +09:00
Frantisek Sumsal
992e06df08 test: make sure the test units have a test- prefix
So when collecting coverage the test-.service dropin works as
expected.

Follow-up to 969f5f3cea.
2023-04-29 16:59:08 +02:00
Frantisek Sumsal
edea0d6ac5 test: match all messages with the FILE field
As the systemd-pstore process is quite short lived, it might sometimes
lack the necessary metadata to make matching against a unit or a syslog
tag work. Since we already use a cursor file to make the matching window
small as possible, let's just drop the unit match completely and hope
for the best.

Resolves: #27453
2023-04-29 16:58:40 +02:00
Yu Watanabe
843cb225ad test: add tests for "systemctl stop" vs triggering by path unit 2023-04-29 09:10:28 +09:00
Yu Watanabe
2e701a7946 test: create temporary units under /run 2023-04-29 09:10:28 +09:00
Luca Boccassi
398d858d1c
Merge pull request #27437 from mrc0mmand/pstore
test: add a couple of tests for systemd-pstore
2023-04-28 16:14:09 +01:00
Frantisek Sumsal
6858e32d73 test: add a couple of tests for systemd-pstore 2023-04-28 13:16:45 +02:00
Franck Bui
fd34e27fb9 test: dont use anchor char '$' to match a part of a string
When anchoring the pattern using '$' regular expression operator it forces '=~'
operator to match the entire string.
2023-04-27 22:42:51 +08:00
Mike Yuan
82060b62c9
Merge pull request #25622 from YHNdnzj/tmpfiles-X-bit-support
tmpfiles: add conditionalized execute permission (X) support
2023-04-27 22:40:09 +08:00
Lennart Poettering
969f5f3cea test: extend test 19 to also verify DelegateSubgroup= works 2023-04-27 14:15:50 +02:00
Mike Yuan
f582e61bc3
test: tmpfiles: add tests on conditionalized execute bit 2023-04-27 15:18:31 +08:00
Luca Boccassi
66a0ee55d8
Merge pull request #27355 from fbuihuu/kbd-improve-vc2x11-conversion
locale: improve vc -> x11 keyboard conversion
2023-04-26 23:37:53 +01:00
Luca Boccassi
68b12e2d56
Merge pull request #27421 from bluca/coredump_filter
CoredumpFilter: fix stack overflow and invalid assignment with 'all'
2023-04-26 23:22:59 +01:00
Daan De Meyer
fec81dedfd
Merge pull request #27415 from DaanDeMeyer/verity-minimize
repart: Add Minimize= support for verity hash partitions
2023-04-26 18:55:51 +02:00
Luca Boccassi
cf636aa59e test: add coverage for CoredumpFilter=all 2023-04-26 16:12:00 +01:00
Zbigniew Jędrzejewski-Szmek
1db4acbe5d
Merge pull request #27398 from yuwata/udev-rule-negative-match
udev-rule: fix negative match
2023-04-26 16:40:01 +02:00
Frantisek Sumsal
914f280d0c test: tell dfuzzer to skip Reexecute()
As described in systemd/systemd#27204 reexecuting the daemon while
running in a systemd-run "session" causes the session end prematurely.
Let's skip the Reexecute() method in dfuzzer and trigger it manually
until the issue is resolved.
2023-04-26 14:41:05 +02:00
Daan De Meyer
5eef704734 repart: Add Minimize= support for verity hash partitions
Fixes #27414
2023-04-26 14:15:16 +02:00
Franck Bui
b35f71ac1a locale: when no xvariant match select the entry with an empty xvariant
When doing a conversion and the specified 'xc->xvariant' has no match, select
the x11 layout entry with a matching layout and an empty xvariant if such entry
exists. It's still better than no conversion at all.
2023-04-26 08:15:17 +02:00
Yu Watanabe
a101d91988 test: add test case of negative match for SYMLINK and TAG 2023-04-26 09:51:12 +09:00
Frantisek Sumsal
ad2875af9e test: add a couple of sanity tests for systemd-creds 2023-04-25 18:34:49 +02:00
Zbigniew Jędrzejewski-Szmek
4481a30855 test: use idiomatic bash loop iteration
In a few cases, also avoid a sleep in the last (failed) iteration of the loop.
It doesn't matter too much, but it's still ugly.
2023-04-24 21:59:28 +02:00
Zbigniew Jędrzejewski-Szmek
97b35c7cec testsuite-54: drop unnecessary pipe 2023-04-24 21:59:28 +02:00
Zbigniew Jędrzejewski-Szmek
add53f9b93 testsuite-70: drop unnecessary env 2023-04-24 21:59:27 +02:00
Zbigniew Jędrzejewski-Szmek
128db0aa00 test: drop uses of "&& { echo 'unexpected success'; exit 1; }"
Brief is sweet.
2023-04-24 21:58:35 +02:00
Zbigniew Jędrzejewski-Szmek
a1e5bd2066 testsuite-04: remove unnecessary conditional 2023-04-24 10:06:59 +02:00
Zbigniew Jędrzejewski-Szmek
f65c2f5214 testsuite-04: remove redirection, drop whitespace after redirection op 2023-04-24 10:06:59 +02:00
Luca Boccassi
21453b8b4b
Merge pull request #27349 from mrc0mmand/codespell
tree-wide: code spelling fixes
2023-04-20 22:02:17 +01:00
Frantisek Sumsal
94d82b5980 tree-wide: code spelling fixes
As reported by Fossies.
2023-04-20 21:54:59 +02:00
Yu Watanabe
c19f1cc9a5 test: add regression tests for find_esp() and friend 2023-04-19 04:04:57 +09:00
Frantisek Sumsal
574d09bad0 test: prefix the transient unit with test- to make coverage runs happy
See 9fd8226312 for more details.

Follow-up to c9210b7470.
2023-04-18 14:55:08 +01:00
Luca Boccassi
c9210b7470 creds: make available to all ExecStartPre= and ExecStart= processes
Fixes https://github.com/systemd/systemd/issues/27275
2023-04-17 17:47:28 +01:00
Yu Watanabe
f384ce1187
Merge pull request #27283 from mrc0mmand/assorted-test-tweaks
test: a bunch of assorted tweaks, Saturday edition
2023-04-16 19:39:58 +09:00
Frantisek Sumsal
f7f5657ece test: add a couple of basic sanity tests for the security verb 2023-04-16 09:21:13 +02:00
Frantisek Sumsal
a51ba8e31a test: add a couple of basic sanity tests for timedatectl 2023-04-16 09:21:13 +02:00
Luca Boccassi
4d7a06b322
Merge pull request #27273 from mrc0mmand/test-generators
test: add a couple of tests for getty/run/system-update generators
2023-04-14 21:31:55 +01:00
Frantisek Sumsal
3a8b7e8b5f test: stop the test unit when it's not needed anymore
Otherwise it keeps printing stuff to the journal/console, adding
unnecessary noise.
2023-04-14 21:13:14 +02:00
Frantisek Sumsal
e51d13d61d test: check the colored --version output 2023-04-14 21:07:51 +02:00
Frantisek Sumsal
bbbf16b3d7 test: add a couple of tests for run-generator 2023-04-14 17:05:55 +02:00
Frantisek Sumsal
657ea51341 test: add a couple of tests for system-update-generator 2023-04-14 16:09:32 +02:00
Frantisek Sumsal
d72cf09859 test: properly distinguish between generator phases
Let's make sure the units generated by generators are generated at the
right stage.
2023-04-14 15:44:01 +02:00
Frantisek Sumsal
e6c281c1cb test: add a couple of tests for getty-generator 2023-04-14 13:54:27 +02:00
Frantisek Sumsal
7faa4e3782 test: allow overriding PID1's environment for test purposes 2023-04-14 12:58:16 +02:00
Frantisek Sumsal
ff8d435db4 test: add a couple of test for fstab-related kernel cmdline args 2023-04-14 10:45:20 +02:00
Frantisek Sumsal
2d4eb78ce1 test: check if x-systemd.automount is ignored for rootfs 2023-04-14 10:45:20 +02:00
Frantisek Sumsal
53c5dc5446 test: run the generators with debug log level
unless requested otherwise.
2023-04-14 10:45:20 +02:00
Luca Boccassi
2cba2fcd25
Merge pull request #27144 from enr0n/fix-scope-timer-on-coldplug
scope: do not disable timer event source when state is SCOPE_RUNNING
2023-04-14 00:25:06 +01:00
Luca Boccassi
6ef721cbc7 user units: implicitly enable PrivateUsers= when sandboxing options are set
Enabling these options when not running as root requires a user
namespace, so implicitly enable PrivateUsers=.
This has a side effect as it changes which users are visible to the unit.
However until now these options did not work at all for user units, and
in practice just a handful of user units in Fedora, Debian and Ubuntu
mistakenly used them (and they have been all fixed since).

This fixes the long-standing confusing issue that the user and system
units take the same options but the behaviour is wildly (and sometimes
silently) different depending on which is which, with user units
requiring manually specifiying PrivateUsers= in order for sandboxing
options to actually work and not be silently ignored.
2023-04-13 21:33:48 +01:00
Luca Boccassi
ce963a747f
Merge pull request #27244 from bluca/uphold_retry
Uphold/StopWhenUnneeded/BindsTo: add retry timer on rate limit
2023-04-13 21:33:06 +01:00
Nick Rosbrook
af4688398f test: add some tests for RuntimeMaxSec
Make sure the RuntimeMaxSec is applied correctly to service and scope
units when they are started, and also on coldplug.
2023-04-13 15:43:30 -04:00
Luca Boccassi
0607a9f9da systemd-confext: mount confexts as noexec and nosuid
Confexts should not contain code, so mount confexts with noexec.
We cannot mount invidial extensions as noexec, as the overlay ignores
it and bypasses it, we need to use the flag on the whole overlay for
it to be effective.
But given there are legacy scripts still shipped in /etc, allow to
override it with --noexec=false.
2023-04-14 01:21:48 +08:00
Luca Boccassi
4c7a0fc8d0 Uphold/StopWhenUnneeded/BindsTo: requeue when job finishes
When a unit is upheld and fails, and there are no state changes in
the upholder, it will not be retried, which is against what the
documentation suggests.

Requeue when the job finishes. Same for the other two queues.
2023-04-13 13:28:25 +01:00
OMOJOLA JOSHUA DAMILOLA
96ead603b8 systemd-cryptenroll: add string aliases for tpm2 PCRs
Fixes #26697. RFE.
2023-04-13 12:08:32 +01:00
Lennart Poettering
39857544ee
Merge pull request #27027 from dtardon/unit-file-list-cleanup
Use _cleanup_ for UnitFileList hash
2023-04-13 09:10:17 +02:00
Lennart Poettering
3540ce8587 test: validate that fdstore pinning works 2023-04-13 06:44:27 +02:00
David Tardon
e7f5525fb0 test: also test client-side operation if applicable 2023-04-12 17:14:06 +02:00
Lennart Poettering
3af48a86d9
Merge pull request #25608 from poettering/dissect-moar
dissect: add dissection policies
2023-04-12 13:46:08 +02:00
Luca Boccassi
068943453f
Merge pull request #27165 from poettering/fdstore-envvar
service: tell service processes that the fdstore is available via an e…
2023-04-12 12:13:43 +01:00
Daan De Meyer
ea24ed79f6
Merge pull request #27220 from yuwata/sd-device-follow-ups-for-devlink
sd-device: several follow-ups about devlink creation
2023-04-12 11:49:08 +02:00
Lennart Poettering
75b29fda71 service: tell service processes that the fdstore is available via an env var 2023-04-12 10:34:31 +02:00
Yu Watanabe
7e430500d2 udev-test: add more testcases for SYMLINK 2023-04-12 10:52:14 +09:00
Frantisek Sumsal
82929336c7 test: drop binary stripping stuff
Stripping the binaries in the test images makes potential stack straces
quite useless, so let's drop the stripping stuff to make test fails a bit
more developer friendly.

Related: https://github.com/systemd/systemd-centos-ci/pull/616
2023-04-12 10:33:32 +09:00
Daan De Meyer
73c43e96e7
Merge pull request #27186 from yuwata/os-release
os-util: several cleanups and introduce _at() variants of os-release parsers
2023-04-11 14:54:56 +02:00
Zbigniew Jędrzejewski-Szmek
ba5a469648
Merge pull request #27169 from yuwata/udev-rule-refuse-unsafe-path
sd-device,udev: refuse unsafe path in SYMLINK= and TAG=
2023-04-11 14:43:50 +02:00
Yu Watanabe
5cf69e709e os-util: make $SYSTEMD_OS_RELEASE prefixed with the root directory
To make it consistent with other env vars, e.g. $SYSTEMD_ESP_PATH or
$SYSTEMD_XBOOTLDR_PATH.

This is useful when the root is specified by a file descriptor, instead
of a path.
2023-04-11 18:49:23 +09:00
Yu Watanabe
adc5b9823c test: update description 2023-04-11 06:07:15 +09:00
Yu Watanabe
6fdc9fbc0f udev/scsi_id: rename positional arguments 2023-04-11 06:07:03 +09:00
Luca Boccassi
1dec1c6163
Merge pull request #27182 from mrc0mmand/test-tweaks
test: a couple of stability tweaks
2023-04-10 18:42:34 +01:00
Yu Watanabe
32cc2cfac9 test: add another regression test
For #27187, which should be also caused by #26956.
2023-04-10 05:43:09 +09:00
Yu Watanabe
1538136911 test: systemd-analyze blame should succeed now 2023-04-10 05:34:30 +09:00
Frantisek Sumsal
9acb7ee425 test: check if we skip the full setup on daemon-reexec (again)
My original assumption in 61961e693d was wrong, since we do reset
/dev/console during reexec (see make_console_stdio()), so the test was
quite racy. Let's replace it with something, hopefully, more reliable.

Follow-up to 61961e693d.
2023-04-08 13:55:29 +09:00
Yu Watanabe
18a6cd4ba3 test-64: add tests for compat devlinks for NVMe drive 2023-04-08 06:12:29 +09:00
Yu Watanabe
0b4c70b47a sd-device,udev: tag must be a valid filename
All tags are managed under /run/udev/tags, and the directories there are
named with tags. Hence, each tag must be a valid filename.

This also makes all validity check moved to sd-device side, and
makes failure caused by setting invalid tags non-critical.

With this change, an empty string cannot be assigned to TAG=, hence the
test cases are adjusted.
2023-04-08 04:49:46 +09:00
Yu Watanabe
2c5f119c3c sd-device,udev: refuse invalid devlink and store in normalized form
This is especially for the case that the path contains "..".
Prompted by https://github.com/systemd/systemd/pull/27164#issuecomment-1498863858.

This also makes SYMLINK= gracefully handle paths prefixed with "/dev/",
and manage devlink paths with path_hash_ops.
2023-04-08 03:38:19 +09:00
Frantisek Sumsal
cb58571a11 test: bump the timeout for non-qemu runs to 90s
When Ubuntu CI is oversaturated, 60s doesn't seem to be enough.
2023-04-07 17:23:59 +02:00
Frantisek Sumsal
6de6376075 test: enable the systemd-resolved unit in TEST-75
Without enabling itx, there's no symlink to the org.freedesktop.resolve1
dbus service, so there exists a tiny window in which the sequence of
`systemctl start` and `systemctl service-log-level` commands might fail:

[ 1127.615151] H systemd[1]: Started Network Name Resolution.
[ 1127.617768] H testsuite-75.sh[34]: + systemctl service-log-level systemd-resolved.service debug
[ 1127.621251] H dbus-daemon[54]: [system] Activating via systemd: service name='org.freedesktop.resolve1' unit='dbus-org.freedesktop.resolve1.service' requested by ':1.24' (uid=0 pid=119 comm="systemctl service-log-level systemd-resolved>
[ 1127.621336] H systemd[1]: dbus-org.freedesktop.resolve1.service: Failed to load configuration: No such file or directory
[ 1127.621364] H systemd[1]: dbus-org.freedesktop.resolve1.service: Trying to enqueue job dbus-org.freedesktop.resolve1.service/start/replace
[ 1127.621395] H systemd[1]: D-Bus activation failed for dbus-org.freedesktop.resolve1.service: Unit dbus-org.freedesktop.resolve1.service not found.
[ 1127.621965] H dbus-daemon[54]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.resolve1.service': Unit dbus-org.freedesktop.resolve1.service not found.
[ 1127.622046] H systemd[1]: systemd-resolved.service: D-Bus name org.freedesktop.resolve1 now owned by :1.25
[ 1127.622130] H systemctl[119]: Failed to set log level of org.freedesktop.resolve1 to debug: Unit dbus-org.freedesktop.resolve1.service not found.

Spotted in a couple of recent Ubuntu CI runs.
2023-04-07 17:00:10 +02:00
Zbigniew Jędrzejewski-Szmek
1e094cb4ba
Merge pull request #27126 from yuwata/journal-compress
sd-journal: allow to specify compression algorithm through env
2023-04-07 09:28:27 +02:00
Yu Watanabe
0864b5eb6e
Merge pull request #27158 from mrc0mmand/more-tests
test: introduce TEST-81-GENERATORS
2023-04-07 07:53:37 +09:00
Frantisek Sumsal
61961e693d test: check if we skip the full setup on daemon-reexec
A simple test case for issue #27106.

Resolves: #27139
2023-04-07 07:53:14 +09:00
Yu Watanabe
d23a1c52a9 test: add test case that journal file is created with the requested compression algorithm 2023-04-07 02:30:43 +09:00
Frantisek Sumsal
17c9dbc98b test: introduce TEST-81-GENERATORS
Add some explicit tests for various generators we ship, e.g.:
    - systemd-debug-generator
    - systemd-environment-d-generator
    - systemd-fstab-generator
2023-04-06 13:16:40 +02:00
Frantisek Sumsal
9948a169c0 test: add a couple of tests for systemd-modules-load 2023-04-06 10:26:47 +02:00
maanyagoenka
c3c6a4f0a9 confext: add tests for systemd-confext 2023-04-05 21:50:04 +00:00
Franck Bui
f9a23d428a test: use kbd-mode-map we ship in TEST-73-LOCALE
The rational is the same as the one described in commit
be0cc2ce6c.
2023-04-05 19:58:57 +01:00
Lennart Poettering
f1f42aeaf1 test: add integration test for image policy 2023-04-05 20:54:30 +02:00
Lennart Poettering
a62e12dad1 analyze: add 'image-policy' tool for analyzing image dissection policies 2023-04-05 20:51:31 +02:00
Thomas Blume
d6d0661631 test/test-functions: fix typo in install_suse_systemd() 2023-04-04 20:39:11 +01:00
Dmitry V. Levin
56df2f6f9b udev-rules: check tokens order
When invoked by udevadm verify, warn about rules that have PROGRAM
assignments specified after RESULT checks.
2023-04-03 23:44:26 +09:00
Lennart Poettering
6b868766eb
Merge pull request #27044 from bluca/sysext_recursive_dir
Ensure sysexts do not contain an os-release file, do not load sysexts from /usr[/local]/lib/extensions/
2023-04-03 12:38:48 +02:00
Frantisek Sumsal
2e4f69946c
Merge pull request #27087 from mrc0mmand/missing-coverage
test: set ReadWritePaths= for test-.services when built w/ coverage
2023-04-01 18:59:42 +02:00
Frantisek Sumsal
9fd8226312 test: shed some light into the whole coverage situation 2023-04-01 12:15:42 +02:00
Daan De Meyer
05eb2c60bd firstboot: Add --reset option
This can be used to prepare an image for firstboot by removing all
files that systemd knows about that contain machine specific
information.
2023-04-01 10:50:15 +02:00
Dmitry V. Levin
e873a9f18a treewide: fix unnecessary $ on arithmetic variables
This should fix shellcheck warning SC2004.
2023-04-01 01:48:44 +08:00
Frantisek Sumsal
e660c590a5 test: set ReadWritePaths= for test-.services when built w/ coverage
Let's make the dropin, to make the build dir writable for gcov, a bit
more generic, so it can be used by all units starting with prefix test-.
This should help with a bunch of recent reports about missing coverage I
got, as well as with existing test units using DynamicUser=true.

This might feel a bit like a magic trick from behind the curtains, but I
want to touch the actual tests as little as possible, since it makes them
unnecessarily messy (see the various workarounds for sanitizers), and
the coverage reports are generated only in a specific CI job anyway.
2023-03-31 19:23:31 +02:00
OMOJOLA JOSHUA DAMILOLA
27d45db38c test: fixed negative checks in TEST-70-TPM2.
Use in-line error handling rather than redirections. Follow up on #27020
2023-03-31 17:50:59 +01:00
Thomas Blume
c7bf1959d7 test: use setpriv instead of su for user switch from root
systemd-repart needs to find mkfs.ext4 for the test.
This is located in the directory /usr/sbin on openSUSE Tumbleweed.
But since the variable ALWAYS_SET_PATH in /etc/login.defs is set to yes,
su re-initializes the $PATH variable and removes /usr/sbin.
Hence, mkfs.ext4 is not found and the test fails.
Using setpriv instead of su fixes this issue and is more appropriate to
do the switch user task from root.

[zjs: move setpriv to $BASICTOOLS and force-push to retrigger CI]
2023-03-31 22:26:44 +08:00
Luca Boccassi
6afa5d862e sysext: validate that they do not contain os-release
sysexts are not supposed to ship os-release files, enforce this
when loading them
2023-03-30 11:28:12 +01:00
Lennart Poettering
b0717f1b82 test: add test case for fdstore dumping logic, and systemd-notify --fd= 2023-03-29 19:09:10 +02:00
Daan De Meyer
77c3cd2086
Merge pull request #27049 from DaanDeMeyer/update-mkosi
mkosi: Update to latest
2023-03-29 13:48:37 +02:00
Daan De Meyer
94c9855a18 mkosi: Update to latest
- Drop Netdev= as it was removed in mkosi
- Always install python-psutil in the final image (required for networkd tests)
- Always Install python-pytest in the final image (required for ukify tests)
- Use the narrow glob for all centos python packages
- Drop the networkd mkosi config files (the default image can be used instead)
- Use ".conf" as the mkosi config file suffix everywhere
- Copy src/ to /root/src in the final image and set gdb substitute path in
  .gdbinit to make gdb work properly
2023-03-29 13:27:19 +02:00
Luca Boccassi
89c632dfda
Merge pull request #27020 from 1awesomeJ/nit
systemd-cryptenroll: adding integration test cases
2023-03-29 12:24:08 +01:00
Daan De Meyer
3ceb96e018 test: Install systemd-networkd-tests.py when install_tests is enabled 2023-03-29 12:18:42 +02:00
Dmitry V. Levin
139203e1d4 udev_rules_parse_file: do not ignore ENOENT when invoked by udevadm verify
Make sure the ENOENT exception reintroduced by commit
9db7081d83 is not applied when the parser
is invoked by udevadm verify.
2023-03-29 18:50:29 +09:00
Lennart Poettering
09ba6d1a14 TEST-80: synchronize explicitly instead of by time
This removes "sleep" invocations, and makes the notify access testcase a
lot more robust to runtime jitter. We use a pair of fifos in the fs to
sync instead.

Also various other improvoements, including comments.

(Also removes the unnecessary "no-qemu" restriction)
2023-03-29 12:59:53 +09:00
Luca Boccassi
49e8342965 test: do not remove state directory on failure
The test log is in the state directory, and we want to keep it around
when a test fails.

Follow-up for: 256a835f1c
2023-03-29 12:59:02 +09:00
Yu Watanabe
8d9c779cc8
Merge pull request #27046 from bluca/shellcheck
Fix some shellcheck warnings
2023-03-29 12:58:31 +09:00
Luca Boccassi
d79881c530 test: fix shellcheck warnings in test-sysusers.sh 2023-03-29 02:08:18 +01:00
Luca Boccassi
a02c4d469f
Merge pull request #27042 from fbuihuu/fixes-for-testsuite-74-mount
Fixes for testsuite 74 mount
2023-03-29 01:54:30 +01:00
OMOJOLA JOSHUA DAMILOLA
e2a4411a2b added more test cases 2023-03-28 22:28:30 +00:00
Franck Bui
208d9ad168 test: fix regexp in testsuite-74.mount.sh
Several whitespaces can separate "ext4" and "sd-mount-test" strings.
2023-03-28 20:41:40 +02:00
Franck Bui
8607a39e08 test: drop extraneous bracket in testsuite-74.mount.sh 2023-03-28 19:00:44 +02:00
Luca Boccassi
e8114a4f86 portable: add PORTABLE_NAME_AND_VERSION= and other metadata to LogsExtraFields=
This is useful to identify log messages with metadata from the images
they run on. Look for ID/VERSION_ID/IMAGE_ID/IMAGE_VERSION/BUILD_ID,
with a SYSEXT_ prefix if we are looking at an extension, and append via
LogExtraFields= as respectively PORTABLE_NAME_AND_VERSION= in case of a
single image. In case of extensions, append as PORTABLE_ROOT_NAME_AND_VERSION=
for the base and one PORTABLE_EXTENSION_AND_VERSION= for each extension.

Example with a base and two extensions, with the unit coming from the
first extension:

[Service]
RootImage=/home/bluca/git/systemd/base.raw
Environment=PORTABLE=app0.raw
BindReadOnlyPaths=/etc/os-release:/run/host/os-release
LogExtraFields=PORTABLE=app0.raw
Environment=PORTABLE_ROOT=base.raw
LogExtraFields=PORTABLE_ROOT=base.raw
LogExtraFields=PORTABLE_ROOT_NAME_AND_VERSION=debian_10

ExtensionImages=/home/bluca/git/systemd/app0.raw
LogExtraFields=PORTABLE_EXTENSION=app0.raw
LogExtraFields=PORTABLE_EXTENSION_NAME_AND_VERSION=app_0

ExtensionImages=/home/bluca/git/systemd/app1.raw
LogExtraFields=PORTABLE_EXTENSION=app1.raw
LogExtraFields=PORTABLE_EXTENSION_NAME_AND_VERSION=app_1
2023-03-28 12:14:21 +01:00
Yu Watanabe
19279652c0
Merge pull request #27013 from fbuihuu/test-fixlets
Test fixlets
2023-03-28 13:45:24 +09:00
Yu Watanabe
1d4f517bba
Merge pull request #26993 from mrc0mmand/TEST-46-tweaks
test: explicitly pull in systemd-userdbd.service
2023-03-28 13:39:08 +09:00
Franck Bui
04ef5d1bd7 test: don't export $TOOLS_DIR
It's not (and shouldn't be) used by any test scripts.
2023-03-27 17:20:18 +02:00
Franck Bui
256a835f1c test: clean up $STATEDIR too 2023-03-27 17:20:18 +02:00
Franck Bui
0c566150c8 test: $STATEDIR should not point to /usr/lib/systemd/tests when NO_BUILD=1
When testing the binaries from the host, make sure to not store the state data
below /usr but use a dedicated directory in /var/tmp/ instead.

The working directories of the tests, initially located in /var/tmp, are also
moved in a dedicated directory /var/tmp/systemd-tests.
2023-03-27 17:20:15 +02:00
Frantisek Sumsal
98fa6c7210 test: explicitly pull in systemd-userdbd.socket
Since we don't run preset-all on the test image, the
systemd-userdbd.socket remains disabled. Let's pull it in explicitly
to give systemd-userdbd some coverage as well.
2023-03-27 13:29:12 +02:00
Dmitry V. Levin
ebb00082d8 udev-rules: fix grammar in diagnostics about lines that have no effect
Fixes: 25de7aa7b9 ("udev: modernize udev-rules.c")
2023-03-27 10:00:30 +00:00
Dmitry V. Levin
860e2a1115 udev-rules: extend the check for conflicting expressions
Log an error when a rule line contains the following kind of conflicting
match expressions:

  KEY=="foo*", KEY=="bar*"
2023-03-27 10:00:30 +00:00
Dmitry V. Levin
acc1954a03 udev-rules: check token delimiters
When udev_rules_parse_file() is called by udevadm verify, issue warnings
about the following conditions in udev rules:
* the first token in the rule is preceded with a comma
* the last token in the rule is followed by a comma
* there is no comma between tokens
* there is no whitespace between tokens
* there is more than a single comma between tokens
* there is whitespace between a token and a comma
* there is no whitespace after comma
2023-03-27 10:00:30 +00:00
Dmitry V. Levin
d656c49604 testsuite-17.11.sh: add commas between tokens 2023-03-27 10:00:30 +00:00
Luca Boccassi
8e1a129136
Merge pull request #26870 from fbuihuu/move-unit-tests-in-a-dedicated-subdir
Move unit tests in a dedicated subdir
2023-03-27 09:38:15 +01:00
Zbigniew Jędrzejewski-Szmek
957b934f82
Merge pull request #26294 from yuwata/locale-verify-conf
locale: verify loaded keymap or friends
2023-03-27 10:26:24 +02:00
Franck Bui
f8d527aa9a test: install symlinks with valid targets on SUSE and Debian 2023-03-26 10:44:09 +02:00
Yu Watanabe
cccc14c5a8
Merge pull request #26973 from mrc0mmand/userdbctl-tests
test: add a couple of tests for userdbctl
2023-03-26 09:49:27 +09:00
Yu Watanabe
6fc0d6b5ac
Merge pull request #26983 from mrc0mmand/coredump-test-followup
test: don't expand the subshell expression prematurely
2023-03-26 09:47:49 +09:00
Frantisek Sumsal
237d81fdb3 test: filter the merged coverage report instead
So we don't have to do this twice - once for the base report and then
for each "real" one.

Follow-up to 7fdd6e157a.
2023-03-25 17:55:41 +01:00
Frantisek Sumsal
93fe228bb1 test: add a couple of tests for userdbctl 2023-03-25 14:13:00 +01:00
Frantisek Sumsal
7fdd6e157a test: do an initial coverage capture
I noticed that our coverage reports miss some files completely - this
happens when the test doesn't touch the code in them at all, so the
generated coverage data (and resulting reports) have no information
about them. Let's fix this by doing an initial zero coverage capture
that contains a zeroed counter for every instrumented line in every
file, so when we later merge it with a capture from the test, it shows up
with a missing coverage instead of not showing at all.
2023-03-25 12:29:40 +00:00
Frantisek Sumsal
91c031f169 test: drop unnecessary return
Return code of the EXIT trap handler is ignored in bash.
2023-03-25 12:17:11 +01:00
Frantisek Sumsal
370fa624f5 test: don't touch the /failed marker in the subtest scripts
As it is already handled by the "main" script (testsuite-74.sh).
2023-03-25 12:15:33 +01:00
Frantisek Sumsal
0b189ac84c test: don't expand the subshell expression prematurely
We need to expand the subshell expression during the `bash -c`
invocation, not before, to take the desired effect, as now it expands to:

timeout 30 bash -c 'while [[ 0 -eq 0 ]]; do sleep 1; done'

instead of the expected:

timeout 30 bash -c 'while [[ $(coredumpctl list -q --no-legend 770 | wc -l) -eq 0 ]]; do sleep 1; done'

Follow-up to aadbd81f7f.
2023-03-25 12:10:58 +01:00
Yu Watanabe
fcf8b80d1d test: add test for invalid keymap setting 2023-03-25 15:36:53 +09:00
Franck Bui
fa2745a3e1 test: on openSUSE install the collection of unit test binaries in the target only for TEST-02-UNITTESTS 2023-03-24 14:10:04 +01:00
Franck Bui
c18cc7f7fb meson: make sure the unit test scripts find testdata/ even if they are not installed in the same directory
testdata/ is shared by both the unit tests and the integration tests. Hence it
makes sense to place them right under /usr/lib/systemd/tests/ while the tests
themself are located under dedicated sub-directories:

     /usr/lib/systemd/tests/
     ├── integration-tests
     ├── testdata
     └── unit-tests
         ├── testdata -> ../testdata

However the unit tests implemented as shell scripts (such as
test-fstab-generator.sh) expect to find testdata/ where the scripts are
installed, ie they do something like:

  src="$(dirname "$0")/testdata/test-fstab-generator"

This patch installs a symlink in 'unitestsdir' named "testdata" and that points
to whatever value 'testdata_dir' is set.
2023-03-24 14:10:04 +01:00