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

64627 Commits

Author SHA1 Message Date
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
Daan De Meyer
97211510b0 units: Add CAP_NET_ADMIN condition to systemd-networkd-wait-online@.service as well
It was added to CAP_NET_ADMIN but we forgot to add it to the template
service as well.
2023-05-09 17:59:55 +02:00
Yu Watanabe
251ca88230 sd-dhcp-client: client ID always has non-zero data
Follow-up for f04c991a2f.
Fixes CID#1510978.
2023-05-09 14:41:55 +01:00
Yu Watanabe
c093bfe0ad
Merge pull request #27534 from keszybz/deperlify
Rewrite udev-test.pl in Python
2023-05-09 18:06:51 +09:00
Yu Watanabe
9695b0c01b static-destruct: introduce STATIC_ARRAY_DESTRUCTOR_REGISTER() 2023-05-09 17:53:42 +09:00
Yu Watanabe
555ead8985 static-destruct: several cleanups
No functional changes, preparation for later commits.
2023-05-09 17:53:42 +09:00
Yu Watanabe
3facdc7da8 memory-util: make ArrayCleanup passed to array_cleanup() const
Should not change any behavior, preparation for later commits.
2023-05-09 17:53:42 +09:00
Zbigniew Jędrzejewski-Szmek
98e2089f1b mkosi,ci: do not install perl 2023-05-09 08:11:10 +02: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
e11c9ba7bf tools/oss-fuzz: s/perl/awk/
The pattern is not exactly the same, but I don't think we need to
be super-precise here.
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
7c0d79131b README: require python >= 3.7, clean up module descriptions
libpython was added in 2cc86f094a, it seems
because of python-systemd module that we built. But libpython by itself
is not enough for actual python programs, and now we also list python itself,
so let's drop libpython from the list.

meson requires >= 3.7. We have CI that runs on CentOS8 with Python 3.6, but
let's not provide official support for an EOL Python version. Individual
distributions can provide backports, but we don't need to mention that in
the user-facing docs. According to [1], 3.7 is on life support and 3.6 is EOL.

[1] https://devguide.python.org/versions/
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
e76ff43236 tools/check-includes: compat with Python 3.7
I thought that 3.8 is enough. But Centos8 CI chokes on the walrus.
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
Zbigniew Jędrzejewski-Szmek
495658d43c check-includes: print path relative to project root
Instead of /home/zbyszek/src/systemd-work/build/../src/xdg-autostart-generator/xdg-autostart-service.h:11,
print just src/xdg-autostart-generator/xdg-autostart-service.h:11.

This is a bit annoying that this requires so much verbosity, but the output
with the full names was too annoying.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
b0bd2ae8b3 meson: fix indentation 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
6089235829 meson: add check-includes test to the test suite
Let's just call it always. It is quite fast (meson says 0.12 s).
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
ba9ca60a88 meson: include .cc files in tags too
We only have one, but it seems reasonable to not exclude it.
Result tested with emacs.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
c4a090d60e Rewrite check-includes.pl in python 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
083e2ba445 pid1: drop duplicate include 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
7d3d147c4a test_ukify: print message when skipping whole test file 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek
fb5578b3c3 test-udev: add an optional timeout argument
The tests wants to call some workers with a delay. This implements the delay
directly in test-udev so that the caller can be simplified.

Note that the argument is to be used by the other test file, so this is
purposefully implemented in a simple way.
2023-05-09 08:10:20 +02:00
Yu Watanabe
d94027ad16 bus-util: drop unnecessary continue 2023-05-09 08:08:53 +09:00
Yu Watanabe
d421db6e8b units: add/fix Documentation= about bus interface 2023-05-09 06:10:23 +09:00
Daan De Meyer
d0287dc1d7 test-journal-verify: Use a more thorough machine ID check
Let's not only check if the file exists but also check if it contains
a valid machine ID.
2023-05-09 06:09:43 +09:00
Yu Watanabe
8d3beb00c0
Merge pull request #27579 from YHNdnzj/refuse-dbus-activation
core: refuse dbus activation if dbus is not running
2023-05-09 06:09:25 +09:00
Yu Watanabe
aa7b8755b6
Merge pull request #27578 from yuwata/sd-dhcp-client-client-id-len
sd-dhcp-client: several cleanups for client_id_len
2023-05-09 06:08:32 +09:00
Yu Watanabe
f86a388de3 core/service: fix error cause in the log
Fixes a bug caused by a5648b8094.
Fixes #27575.
2023-05-09 06:08:14 +09:00
Daan De Meyer
cdccdea2ad
Merge pull request #27553 from yuwata/sd-journal-generic-array-bisect
sd-journal: several fixes for generic_array_bisect()
2023-05-08 20:29:24 +02:00
Mike Yuan
53964fd26b
core: refuse dbus activation if dbus is not running
dbus-broker issues StartUnit directly for activation requests,
so let's add a check on bus state in bus_unit_queue_job to refuse
that if dbus is not running.

Replaces #27570
Closes #26799
2023-05-09 01:42:25 +08:00
Mike Yuan
e886315065
core/manager: export manager_dbus_is_running 2023-05-09 01:42:25 +08:00
Daan De Meyer
7429c8fe57 test-specifier: Ignore -ENOPKG from specifier_printf()
If /etc/machine-id contains "uninitialized", specifier_printf() with
%m will fail with ENOPKG, so ignore that error as well.
2023-05-08 18:53:27 +02:00
Marko Korhonen
2ad681f53c
shell completion: add timesync-status and show-timesync to zsh completion file (#27574)
Fixes #27560
2023-05-09 01:01:16 +09:00
Yu Watanabe
e69c281ad2 sd-dhcp-client: do not use implicit cast to boolean 2023-05-09 00:37:29 +09:00
Yu Watanabe
f04c991a2f sd-dhcp-client: make return arguments for sd_dhcp_client_get_client_id() optional 2023-05-09 00:34:06 +09:00
Yu Watanabe
22e299fc5e sd-dhcp-client: drop redundant condition
Closes #27561.
2023-05-09 00:27:24 +09:00
Yu Watanabe
16cda99c73 nulstr-util: make ret_size in strv_make_nulstr() optional 2023-05-08 21:40:56 +08:00
Daan De Meyer
6840e89a57
Merge pull request #27569 from keszybz/mkosi-nicer-output
Prettification for mkosi build output
2023-05-08 15:37:22 +02:00
Miao Wang
4fad639a13 doc: remove legacy DefaultControlGroup from dbus properties
DefaultControlGroup does not exist any more.
2023-05-08 22:23:00 +09:00
Zbigniew Jędrzejewski-Szmek
1bcad2de7c mkosi.build: print important build commands
This undoes the effect of 1394a3ec35 partially.
We print the fairly verbose output of the build commands, so let's also
print the commands themselves. This makes it much easier to understand what
is going on.

(The style was copied from other scripts where we do 'set -x' for one command.)
2023-05-08 15:04:02 +02:00
Zbigniew Jędrzejewski-Szmek
385fb4e323 mkosi/fedora: silence warning about sysusers config mismatch 2023-05-08 15:04:02 +02:00
Zbigniew Jędrzejewski-Szmek
dede53943f mkosi.build: use bash, use array for configuration options, shellcheckify
With bash, we can use an array for options. This is nice because we can
construct the commandline more easily. The file is now shellcheck-clean.
2023-05-08 15:04:02 +02:00
Yu Watanabe
210cb8d690 core/unit: check the validity of unit type with activation_details_vtable
Follow-up for 24e91e08f8.
2023-05-08 09:49:55 +02:00
Yu Watanabe
d2132d3d8d parse-util: make parse_fd() return -EBADF
The previous error code -ERANGE is slightly ambiguous, and use more
specific one. This also drops unnecessary error handlings.

Follow-up for 754d8b9c33 and
e652663a04.
2023-05-08 09:49:55 +02:00
Ronan Pigott
b3d12ac0da zsh: add service-log-{level,target} completions for systemctl 2023-05-08 01:08:36 +01:00
Janne Sirén
78e0dd2244
hwdb: add landscape IdeaPad Miix 310 sensor orientation (#27555)
Enables support for landscape orientated display variants of the IdeaPad Miix 310 2-in-1 laptop.
2023-05-07 09:18:55 +09:00