summaryrefslogtreecommitdiff
path: root/src/test
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #27659 from yuwata/memfd-sealMike Yuan2023-05-162-0/+31
|\ | | | | memfd-util: handle F_SEAL_EXEC flag
| * test: add basic test for memfd_set_sealed() and memfd_get_sealed()Yu Watanabe2023-05-162-0/+31
| |
* | test: add tests for UpheldBy= in [Install] sectionMike Yuan2023-05-151-2/+10
|/
* Merge pull request #27565 from yuwata/static-destructDaan De Meyer2023-05-121-4/+37
|\ | | | | static-destruct: support clearing array on exit
| * static-destruct: introduce STATIC_ARRAY_DESTRUCTOR_REGISTER()Yu Watanabe2023-05-091-4/+37
| |
* | mkfs-util: Add quiet argument to make_filesystem()Daan De Meyer2023-05-121-4/+4
| | | | | | | | | | | | | | | | We default to quiet operation everywhere except for repart, where we disable quiet and have the mkfs tools write to stdout. We also make sure --quiet or equivalent is implemented for all mkfs tools.
* | Merge pull request #27534 from keszybz/deperlifyYu Watanabe2023-05-092-10/+19
|\ \ | |/ |/| Rewrite udev-test.pl in Python
| * test: rework how udev-test is invokedZbigniew Jędrzejewski-Szmek2023-05-092-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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'.
| * test-udev: add an optional timeout argumentZbigniew Jędrzejewski-Szmek2023-05-091-4/+13
| | | | | | | | | | | | | | | | 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.
* | test-specifier: Ignore -ENOPKG from specifier_printf()Daan De Meyer2023-05-081-1/+1
|/ | | | | If /etc/machine-id contains "uninitialized", specifier_printf() with %m will fail with ENOPKG, so ignore that error as well.
* parse-util: make parse_fd() return -EBADFYu Watanabe2023-05-081-2/+2
| | | | | | | | The previous error code -ERANGE is slightly ambiguous, and use more specific one. This also drops unnecessary error handlings. Follow-up for 754d8b9c330150fdb3767491e24975f7dfe2a203 and e652663a043cb80936bb12ad5c87766fc5150c24.
* Merge pull request #27536 from dtardon/checked-fd-parsingLuca Boccassi2023-05-051-0/+13
|\ | | | | Always check parsed fds for validity
| * test: add a test for parse_fd()David Tardon2023-05-051-0/+13
| |
* | tpm2 PCRs: fix unchecked attempt to set PCR[24]OMOJOLA2023-05-051-1/+2
|/
* mount-util: simplify mount_switch_root() a bitLennart Poettering2023-05-031-0/+43
| | | | | | | | | | | | | There's no need to fchdir() out of the rootfs and back into it around the umount2(), hence don't. This brings the logic closer to what the pivot_root() man page suggests. While we are at it, always operate based on fds, once we opened the original dir, and pass the path string along only for generating messages (i.e. as "decoration"). Add tests for both code paths: the pivot_root() one and the MS_MOUNT.
* generate-sym-test: only look in .c and .h filesLennart Poettering2023-05-021-0/+2
| | | | | Otherwise it might find backup files and such, which triggered all kinds of false positives (at least on my devel machine).
* generate-sym-test: search for missing symbolsLennart Poettering2023-05-021-2/+25
| | | | | | | | | | This slightly extends the symbol file test and checks which symbols are listed in one list but missing in the other. This is tremendously useful to quickly determine which symbols wheren't exposed properly but should have been. (This is is implemented in pure C, no systemd helpers, to ensure we see libsystemd.so API as any other tool would.)
* test: also test all _public_ functions are listed in .sym filesYu Watanabe2023-05-012-28/+81
| | | | Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
* cgroup: rework how we validate/escape cgroupsLennart Poettering2023-04-271-5/+10
| | | | | | Let's clean up validation/escaping of cgroup names. i.e. split out code that tests if name needs escaping. Return proper error codes, and extend test a bit.
* image-policy: split out code that "extends" underspecified partition policy ↵Lennart Poettering2023-04-271-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | flags When encoding partition policy flags we allow parts of the flags to be "unspecified" (i.e. entirely zeros), which when actually checking the policy we'll automatically consider equivalent to "any" (i.e. entirely ones). This "extension" of the flags was so far done as part of partition_policy_normalized_flags(). Let's split this logic out into a new function partition_policy_flags_extend() that simply sets all bits in a specific part of the flags field if they were entirely zeroes so far. When comparing policy objects for equivalence we so far used partition_policy_normalized_flags() to compare the per-designator flags, which thus meant that "underspecified" flags, and fully specified ones that are set to "any" were considered equivalent. Which is great. However, we forgot to do that for the fallback policy flags, the flags that apply to all partitions for which no explicit policy flags are specified. Let's use the new partition_policy_flags_extend() call to compare them in extended form, so that there two we can hide the difference between "underspecified" and "any" flags.
* coredump filter: add mask for 'all' using UINT32_MAX, not UINT64_MAXLuca Boccassi2023-04-261-0/+2
| | | | | | The kernel returns ERANGE when UINT64_MAX is passed. Create a mask and use UINT32_max, which is accepted, so that future bits will also be set.
* Merge pull request #27408 from keszybz/creds-missing-messageZbigniew Jędrzejewski-Szmek2023-04-261-4/+4
|\ | | | | Adjust messages when credentials are missing
| * shared/creds-util: return 0 for missing creds in read_credential_strings_manyZbigniew Jędrzejewski-Szmek2023-04-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | Realistically, the only thing that the caller can do is ignore failures related to missing credentials. If the caller requires some credentials to be present, they should just check which output variables are not NULL. One of the callers was already doing that, and the other wanted to, but missed -ENOENT. By suppressing -ENOENT and -ENXIO, both callers are simplified. Fixes a warning at boot: systemd-vconsole-setup[221]: Failed to import credentials, ignoring: No such file or directory
* | test: cover missed stuff from securebits-util.hFrantisek Sumsal2023-04-251-0/+13
|/
* mountpoint-util: make path_get_mnt_id_at() work with a NULL pathLennart Poettering2023-04-251-0/+47
|
* fs-util: make sure open_mkdir_at() does something roughly sensible when ↵Lennart Poettering2023-04-251-0/+17
| | | | invoked with '/'
* Merge pull request #27386 from dtardon/test-cleanupLuca Boccassi2023-04-2511-155/+65
|\ | | | | More automatic cleanup in tests
| * test-hashmap-plain: use _cleanup_David Tardon2023-04-241-57/+22
| |
| * test-set: use _cleanup_David Tardon2023-04-241-4/+2
| |
| * test-calendarspec: use _cleanup_David Tardon2023-04-241-11/+5
| |
| * test: use _cleanup_ for temp. filesDavid Tardon2023-04-217-72/+31
| |
| * test-fdset: use _cleanup_David Tardon2023-04-211-5/+2
| |
| * test: shorten a bitDavid Tardon2023-04-211-6/+3
| |
* | Merge pull request #27113 from keszybz/variable-expansion-reworkZbigniew Jędrzejewski-Szmek2023-04-243-122/+266
|\ \ | |/ |/| Rework serialization of command lines in pid1 and make run not expand variables
| * core/unit: add UNIT_ESCAPE_EXEC_SYNTAXZbigniew Jędrzejewski-Szmek2023-04-241-18/+38
| | | | | | | | | | | | | | | | | | | | Unfortunately we can't escape $ when ':' is used to prohibit variable expansion: ExecStart=:echo $$ is not the same as ExecStart=:echo $ This just adds the functionality and the unittests, without using it anywhere for real yet.
| * core/unit: rename UNIT_ESCAPE_EXEC_SYNTAX → *_ENVZbigniew Jędrzejewski-Szmek2023-04-241-2/+2
| | | | | | | | In preparation for future changes.
| * core/unit: fix shell-escaping of stringsZbigniew Jędrzejewski-Szmek2023-04-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our escaping of '$' is '$$', not '\$'. We would write unit files that were not valid: $ systemd-run --user bash -c 'echo $$; sleep 1000' Running as unit: run-r1c7c45b5b69f487c86ae205e12100808.service $ systemctl cat --user run-r1c7c45b5b69f487c86ae205e12100808 # /run/user/1000/systemd/transient/run-r1c7c45b5b69f487c86ae205e12100808.service ... ExecStart="/usr/bin/bash" "-c" "echo \$\$\; sleep 1000" $ systemd-analyze verify /run/user/1000/systemd/transient/run-r1c7c45b5b69f487c86ae205e12100808.service /run/user/1000/systemd/transient/run-r1c7c45b5b69f487c86ae205e12100808.service:7: Ignoring unknown escape sequences: "echo \$\$\; sleep 1000" Similarly, ';' cannot be escaped as '\;'. Only a handful of characters listed in "Supported escapes" is allowed. Escaping of "'" can be done, but it's not useful because we use double quotes around the string anyway whenever we do escaping. unit_write_setting() is called all over the place. In a great majority of places we write either fixed strings or something that we generate ourselves, so no escaping or quoting is needed. (And it's not allowed, e.g. 'Type="oneshot"' would not work.) But if we forgot to add escaping or quoting for a free-style string, it would probably allow writing a unit file that would be read completely wrong. I looked over various places where unit_write_setting() is called, and I couldn't find any place where quoting/escaping was forgotten. But trying to figure out the full ramifications of this change is not easy.
| * basic/logarithm: add popcount() wrapperZbigniew Jędrzejewski-Szmek2023-04-241-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | __builtin_popcount() is a bit of a mouthful, so let's provide a helper. Using _Generic has the advantage that if a type other then the ones on the list is given, compilation will fail. This is nice, because if by any change we pass a wider type, it is rejected immediately instead of being truncated. log.h is also needed. It is included transitively, but let's include it directly. macro.h is *not* needed.
| * test-core-unit: add new test file for unit_escape_setting() and friendsZbigniew Jędrzejewski-Szmek2023-04-042-0/+105
| | | | | | | | | | | | | | | | None of the existing test files fit very well. test-unit-serialize is pretty close, but it does special cgroup setup, which we don't need in this case. I hope we can add more tests in the future for this basic functionality, so I'm adding a brand new file names after the source file it's testing.
| * meson: redo grouping of tests under src/test/Zbigniew Jędrzejewski-Szmek2023-04-041-122/+120
| | | | | | | | | | | | | | | | Move the tests that link to libcore into a separate subgroup. They are special and it makes sense to keep them together. While at it, make the list alphabetical. Also, merge the list additions into one. No idea why it was like that.
* | chase: replace path_prefix_root_cwd() with chaseat_prefix_root()Yu Watanabe2023-04-192-39/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The function path_prefix_root_cwd() was introduced for prefixing the result from chaseat() with root, but - it is named slightly generic, - the logic is different from what chase() does. This makes the name more explanative and specific for the result of the chaseat(), and make the logic consistent with chase(). Fixes https://github.com/systemd/systemd/pull/27199#issuecomment-1511387731. Follow-up for #27199.
* | chase: make the result absolute when a symlink is absoluteYu Watanabe2023-04-191-1/+10
| | | | | | | | As the path may be outside of the specified dir_fd.
* | chase: make chaseat() provides absolute path also when dir_fd points to the ↵Yu Watanabe2023-04-191-0/+28
| | | | | | | | | | | | | | | | | | | | root directory Usually, we pass the file descriptor of the root directory to chaseat() when `--root=` is not specified. Previously, even in such case, the result was relative, and we need to prefix the path with "/" when we want to pass the path to other functions that do not support dir_fd, or log or show the path. That's inconvenient.
* | test: modernize test-async a bitFrantisek Sumsal2023-04-161-8/+7
| | | | | | | | | | Mainly to give it some debug output to, hopefully, see why it sometimes gets stuck in CI when run with sanitizers.
* | Merge pull request #27283 from mrc0mmand/assorted-test-tweaksYu Watanabe2023-04-166-1/+209
|\ \ | | | | | | test: a bunch of assorted tweaks, Saturday edition
| * | test: add a couple of tests with invalid UTF-8 charactersFrantisek Sumsal2023-04-161-1/+19
| | |
| * | test: add a simple test for getenv_path_list()Frantisek Sumsal2023-04-161-0/+35
| | |
| * | test: add a simple test for secure-bits stuffFrantisek Sumsal2023-04-162-0/+85
| | |
| * | test: add tests for uuid/uint64 specifiersFrantisek Sumsal2023-04-161-0/+27
| | | | | | | | | | | | | | | They're used in repart, but are not part of the "common" specifier lists, so cover them explicitly.
| * | test: add a test case for table_dup_cell()Frantisek Sumsal2023-04-151-0/+43
| | | | | | | | | | | | Also, sneak in coverage for "less popular" cell types.