summaryrefslogtreecommitdiffstats
path: root/test (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #22649 from ↵Zbigniew Jędrzejewski-Szmek2022-03-293-4/+698
|\ | | | | | | | | keszybz/symlink-enablement-yet-again-punish-me-harder Fixups to the unit enablement logic
| * test-systemctl-enable: disable the test for %a for nowZbigniew Jędrzejewski-Szmek2022-03-291-1/+3
| |
| * test-systemctl-enable: also use freshly-built systemd-id128Zbigniew Jędrzejewski-Szmek2022-03-291-2/+3
| | | | | | | | Tests were failing on centos7 because systemd-id128 is not in path.
| * test-systemctl-enable: use magic syntax to allow inverted testsZbigniew Jędrzejewski-Szmek2022-03-291-37/+39
| | | | | | | | | | | | | | | | | | | | Inspired by 7910ec3bcde2ee0086b3e49f8aaa2a9f13f58d97. '! true' passes, because it's a conditional expression. But '( ! true )' fails, because '( … )' creates a subshell, i.e. a separate program, and '! true' becomes the return value of that program, and the whole thing apparently is not a conditional expression for the outer shell. This is shorter, so let's just do this.
| * shared/install: when creating symlinks, accept different but equivalent symlinksZbigniew Jędrzejewski-Szmek2022-03-291-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We would only accept "identical" links, but having e.g. a symlink /usr/lib/systemd/system/foo-alias.service → /usr/lib/systemd/system/foo.service when we're trying to create /usr/lib/systemd/system/foo-alias.service → ./foo.service is OK. This fixes an issue found in ubuntuautopkg package installation, where we'd fail when enabling systemd-resolved.service, because the existing alias was absolute, and (with the recent patches) we were trying to create a relative one. A test is added. (For .wants/.requires symlinks we were already doing OK. A test is also added, to verify.)
| * test-systemctl-enable: make shellcheck happyZbigniew Jędrzejewski-Szmek2022-03-291-38/+38
| | | | | | | | | | Quoting is not necessary in many places, but I think it's nicer to use it consistently.
| * shared/install: fix handling of a linked unit fileZbigniew Jędrzejewski-Szmek2022-03-291-4/+8
| | | | | | | | | | | | When we have a symlink that goes outside of our search path, we should just ignore the target file name. But we were verifying it, and rejecting in the case where a symlink was created manually.
| * shared/install: create relative symlinks for enablement and aliasingZbigniew Jędrzejewski-Szmek2022-03-291-66/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fairly noticable change, but I think it needs to be done. So far we'd create an absolute symlink to the target unit file: .wants/foo.service → /usr/lib/systemd/system/foo.service or alias.service → /etc/systemd/system/aliased.service. This works reasonably well, except in one case: where the unit file is linked. When we look at a file link, the name of the physical file isn't used, and we only take the account the symlink source name. (In fact, the destination filename may not even be a well-formed unit name, so we couldn't use it, even if we wanted to.) But this means that if a file is linked, and specifies aliases, we'd create absolute links for those aliases, and systemd would consider each "alias" to be a separate unit. This isn't checked by the tests here, because we don't have a running systemd instance, but it is easy enough to check manually. The most reasonable way to fix this is to create relative links to the unit file: .wants/foo.service → ../foo.service alias.service → aliased.service. I opted to use no prefix for aliases, both normal and 'default.target', and to add "../" for .wants/ and .requires/. Note that the link that is created doesn't necessarily point to the file. E.g. if we're enabling a file under /usr/lib/systemd/system, and create a symlink in /etc/systemd/system, it'll still be "../foo.service", not "../../usr/lib/systemd/system/foo.service". For our unit loading logic this doesn't matter, and figuring out a path that actually leads somewhere would be more work. Since the user is allowed to move the unit file, or add a new unit file in a different location, and we don't actually follow the symlink, I think it's OK to create a dangling symlink. The prefix of "../" is useful to give a hint that the link points to files that are conceptually "one level up" in the directory hierarchy. With the relative symlinks, systemd knows that those are aliases. The tests are adjusted to use the new forms. There were a few tests that weren't really testing something useful: 'test -e x' fails if 'x' is a a dangling symlink. Absolute links in the chroot would be dangling, even though the target existed in the expected path, but become non-dangling when made relative and the test fails. This should be described in NEWS, but I'm not adding that here, because it'd likely result in conflicts.
| * shared/install: also remove symlinks like .wants/foo@one.service → ↵Zbigniew Jędrzejewski-Szmek2022-03-291-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ../foo@one.service So far 'systemctl enable' would create absolute links to the target template name. And we would remove such symlinks just fine. But the user may create symlinks manually in a different form. In particular, symlinks for instanced units *must* have the instance in the source name, and then it is natural to also include it in the target name (.wants/foo@one.service → ../foo@one.service rather than .wants/foo@one.service → ../foo@.service). We would choke on such links, or not remove them at all. A test is added: before: + build-rawhide/systemctl --root=/tmp/systemctl-test.001xda disable templ1@.service Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@seven.service". Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@six.service". Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@five.service". Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@four.service". Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@three.service". Failed to disable unit, refusing to operate on linked unit file /tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@two.service. Failed to disable unit, refusing to operate on linked unit file /tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@two.service. after: + build-rawhide/systemctl --root=/tmp/systemctl-test.QVP0ev disable templ1@.service Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@seven.service". Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@six.service". Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@five.service". Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@four.service". Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@three.service". Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@two.service". Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@one.service". + test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@one.service + test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@two.service + test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@three.service + test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@four.service + test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@five.service + test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@six.service + test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@seven.service
| * test-systemctl-enable: enhance the test for unit file linkingZbigniew Jędrzejewski-Szmek2022-03-291-3/+36
| | | | | | | | | | Current behaviour is wrong, but it cannot be shown in this test, because we don't have a running systemd instance here.
| * test-systemctl-enable: extend the test for repeated WantedBy/RequiredByZbigniew Jędrzejewski-Szmek2022-03-291-4/+18
| | | | | | | | | | | | | | | | | | | | | | I was considering deduplicating the list of target units in WantedBy/RequiredBy. But to do this meaningfully, we'd need to do alias expansion first, i.e. after the initial parsing is done. This seems to be more trouble than it would be worth. Instead, I added tests that we're doing the right thing and creating symlinks as expected. For duplicate links, we create the link, and on the second time we see that the link is already there, so the output is correct.
| * shared/install: fix reenable on linked unit filesZbigniew Jędrzejewski-Szmek2022-03-291-5/+3
| |
| * install: when linking a file, create the link first or abortZbigniew Jędrzejewski-Szmek2022-03-291-6/+3
| | | | | | | | | | | | We'd create aliases and other symlinks first, and only then try to create the main link. Since that can fail, let's do things in opposite order, and abort immediately if we can't link the file itself.
| * man: fix invalid description of template handling in WantedBy=Zbigniew Jędrzejewski-Szmek2022-03-291-0/+49
| | | | | | | | | | | | | | | | | | We don't need to talk about Alias=. The approach of using Alias= to enable units is still supported, but hasn't been advertised as the way to do thing for many years. Using it as an explanation is just confusing. Also, the description of templated units did not take DefaultInstance= into account. It is updated and extended.
| * shared/install: also check for self-aliases during installation and ignore themZbigniew Jędrzejewski-Szmek2022-03-291-4/+2
| | | | | | | | | | | | | | | | | | We had a check that was done in unit_file_resolve_symlink(). Let's move the check to unit_validate_alias_symlink_or_warn(), which makes it available to the code in install.c. With this, unit_file_resolve_symlink() behaves almost the same. The warning about "suspicious symlink" is done a bit later. I think this should be OK.
| * shared/install: return failure when enablement fails, but process as much as ↵Zbigniew Jędrzejewski-Szmek2022-03-291-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | possible So far we'd issue a warning (before this series, just in the logs on the server side, and before this commit, on stderr on the caller's side), but return success. It seems that successfull return was introduced by mistake in aa0f357fd833feecbea6c3e9be80b643e433bced (my fault :( ), which was supposed to be a refactoring without a functional change. I think it's better to fail, because if enablement fails, the user will most likely want to diagnose the issue. Note that we still do partial enablement, as far as that is possible. So if e.g. we have [Install] Alias=foo.service foobar, we'll create the symlink 'foo.service', but not 'foobar', since that's not a valid unit name. We'll print info about the action taken, and about 'foobar' being invalid, and return failure.
| * shared/specifier: fix %u/%U/%g/%G when called as unprivileged userZbigniew Jędrzejewski-Szmek2022-03-292-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would resolve those specifiers to the calling user/group. This is mostly OK when done in the manager, because the manager generally operates as root in system mode, and a non-root in user mode. It would still be wrong if called with --test though. But in systemctl, this would be generally wrong, since we can call 'systemctl --system' as a normal user, either for testing or even for actual operation with '--root=…'. When operating in --global mode, %u/%U/%g/%G should return an error. The information whether we're operating in system mode, user mode, or global mode is passed as the data pointer to specifier_group_name(), specifier_user_name(), specifier_group_id(), specifier_user_id(). We can't use userdata, because it's already used for other things.
| * shared/install: provide proper error messages when invalid specifiers are usedZbigniew Jędrzejewski-Szmek2022-03-291-26/+14
| | | | | | | | | | $ build/systemctl --root=/tmp/systemctl-test.KXY8fu enable some-some-link6@.socket Failed to enable unit, invalid specifier in "target@C:%C.socket".
| * shared/specifier: provide proper error messages when specifiers fail to read ↵Zbigniew Jędrzejewski-Szmek2022-03-291-14/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | files ENOENT is easily confused with the file that we're working on not being present, e.g. when the file contains %o or something else that requires os-release to be present. Let's use -EUNATCH instead to reduce that chances of confusion if the context of the error is lost. And once we have pinpointed the reason, let's provide a proper error message: + build/systemctl --root=/tmp/systemctl-test.TO7Mcb enable some-some-link6@.socket /tmp/systemctl-test.TO7Mcb/etc/systemd/system/some-some-link6@.socket: Failed to resolve alias "target@A:%A.socket": Protocol driver not attached Failed to enable unit, cannot resolve specifiers in "target@A:%A.socket".
| * basic: add new variable $SYSTEMD_OS_RELEASE to override location of os-releaseZbigniew Jędrzejewski-Szmek2022-03-291-2/+10
| | | | | | | | | | | | The test for the variable is added in test-systemctl-enable because there we can do it almost for free, and the variable is most likely to be used with 'systemctl enable --root' anyway.
| * test: add test for systemctl link & enableZbigniew Jędrzejewski-Szmek2022-03-292-0/+524
| | | | | | | | | | | | This test has overlap with test-install-root, but it tests things at a different level, so I think it's useful to add. It immediately shows various bugs which will be fixed in later patches.
* | test: add tests for worker error codeYu Watanabe2022-03-291-2/+22
| |
* | portable: allow reattaching when one image has a version and the other does notLuca Boccassi2022-03-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A reattach might go from img.raw to img_0.1.raw or viceversa, but this is not allowed right now as we try to match the full name. Also take into account that running strcspn(a, '/') on an image name, without leading path, will return the length of the full string, but the versions might be different so they won't match, eg: img_0.1.raw -> 12 img_0.1.1.raw -> 14 So adjust the check to take that into account, and skip it if we are not dealing with directories
* | network: rename netdev kind virtual-wlan -> wlanYu Watanabe2022-03-281-1/+1
| | | | | | | | | | | | The Kind= setting in [Match] section of .network files takes "wlan". This makes the same setting in .netdev files matches the one in .network files.
* | test: use flock when calling mkfs.btrfsFrantisek Sumsal2022-03-252-4/+47
| | | | | | | | | | | | | | | | | | As stated in https://github.com/systemd/systemd/issues/21819#issuecomment-1064377645 `mkfs.btrfs` doesn't hold the lock for the whole duration of `mkfs.btrfs`, thus causing unexpected races & test fails. Let's wrap the `mkfs.btrfs` calls in an flock wrapper to mitigate this. Hopefully fixes: #21819
* | Revert "test: temporary workaround for #21819"Frantisek Sumsal2022-03-251-8/+3
| | | | | | | | This reverts commit 95e35511bbdb7810c00c2e4a6cbda5b187192f74.
* | TEST-68: instead of calling daemon-reload, just use different cleanup unitsZbigniew Jędrzejewski-Szmek2022-03-241-10/+12
| | | | | | | | | | | | | | | | On a very slow machine, things are executed out-of-order, and something pins the previously-exited unit. Instead of fighting with this with daemon-reload, let's just use a different cleanup unit. Hopefully fixes #22755.
* | TEST-68: get rid of unnecessary descriptionsZbigniew Jędrzejewski-Szmek2022-03-241-20/+0
|/ | | | | The name of the unit already says all, no need to duplicate this. And the comments can easily get out of date, as they did.
* test: use a dropin to override the end.service unitFrantisek Sumsal2022-03-211-1/+6
| | | | instead of removing it.
* test: run test-shutdown.py in verbose modeFrantisek Sumsal2022-03-211-5/+5
| | | | To make the debugging of spurious fails a bit easier.
* test: don't try to execute a non-existing scriptFrantisek Sumsal2022-03-211-1/+1
|
* Merge pull request #22798 from keszybz/test-output-narrow-and-timeoutsLuca Boccassi2022-03-216-0/+0
|\ | | | | Increase timeout for a flaky test and make test names shorter to avoid line wrapping in output
| * fuzz: rename fuzz-dhcp-server-relay-message to fuzz-dhcp-server-relayZbigniew Jędrzejewski-Szmek2022-03-213-0/+0
| | | | | | | | | | We can only relay messages, so we can make the name shorter without losing informational value. This makes meson test output look better.
| * fuzz: rename the longest test samplesZbigniew Jędrzejewski-Szmek2022-03-214-0/+0
| | | | | | | | | | | | | | "meson test" uses a test name generated from the file name and those long names cause the test log output to exceed terminal width which looks bad. Let's replace some long names with more-meaningful names that actually say something about the tests.
* | test: add integration test for sysupdateLennart Poettering2022-03-194-0/+195
|/
* Add tests and documentation for all remaining sandboxing in user managerLuca Boccassi2022-03-181-3/+49
|
* Merge pull request #22754 from mrc0mmand/creds_dir_specifierLennart Poettering2022-03-182-0/+13
|\ | | | | core: add %d specifier for the $CREDENTIALS_DIRECTORY
| * core: add %d specifier for the $CREDENTIALS_DIRECTORYFrantisek Sumsal2022-03-172-0/+13
| | | | | | | | Resolves: #22549
* | tree-wide: fix duplicated wordsMichael Biebl2022-03-181-1/+1
|/ | | | | | | the the in in not not we we
* cryptenroll: add tests for TPM2 unlockingGrigori Goronzy2022-03-155-1/+102
| | | | | | | | | | | Add tests for enrolling and unlocking. Various cases are tested: - Default PCR 7 policy w/o PIN, good and bad cases (wrong PCR) - PCR 7 + PIN policy, good and bad cases (wrong PCR, wrong PIN) - Non-default PCR 0+7 policy w/o PIN, good and bad cases (wrong PCR 0) v2: rename test, fix tss2 library installation, fix CI failures v3: fix ppc64, load module
* test: wait for loopback device being actually createdYu Watanabe2022-03-151-0/+8
| | | | | | | | | | | | | | It seems there exists a short time period that we cannot see the loopback device after `losetup` is finished: ``` testsuite-58.sh[367]: ++ losetup -b 1024 -P --show -f /tmp/testsuite-58-sector-1024.img kernel: loop1: detected capacity change from 0 to 204800 testsuite-58.sh[285]: + LOOP=/dev/loop1 testsuite-58.sh[285]: + systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no /dev/loop1 testsuite-58.sh[368]: Device '/dev/loop1' has no dm-crypt/dm-verity device, no need to look for underlying block device. testsuite-58.sh[368]: Failed to determine canonical path for '/dev/loop1': No such file or directory testsuite-58.sh[368]: Failed to open file or determine backing device of /dev/loop1: No such file or directory ```
* test: format disk image through loopback deviceYu Watanabe2022-03-151-1/+1
| | | | | It seems that the change on the image file sometimes not propagated on the loopback device immediately.
* test: use /var/tmp for storing disk imagesYu Watanabe2022-03-151-4/+4
| | | | | | The Ubuntu CI on ppc64el seems to have a issue on tmpfs, and files may not be fsynced. See c10caebb98803b812ebc4dd6cdeaab2ca17826d7. For safety, let's use /var/tmp to store disk images.
* Merge pull request #22714 from mrc0mmand/codeql-docsLuca Boccassi2022-03-111-0/+54
|\ | | | | A couple of doc updates
| * test: document how to run CodeQL/LGTM stuff manuallyFrantisek Sumsal2022-03-111-0/+54
| | | | | | | | | | Let's have this documented somewhere so I don't have to relearn all this stuff every time I need it.
* | Merge pull request #22618 from yuwata/network-safe-stringLennart Poettering2022-03-111-2/+3
|\ \ | |/ |/| network: dhcp-server: refuse unsafe filename
| * network: dhcp: rename NextServer= and Filename= settingsYu Watanabe2022-03-111-2/+3
| | | | | | | | | | | | | | And make the settings configures DHCP option 66 and 67. Follow-ups for #22615. Fixes #22661.
* | core: support ExtensionDirectories in user managerLuca Boccassi2022-03-102-0/+14
| | | | | | | | | | | | | | Unprivileged overlayfs is supported since Linux 5.11. The only change needed to get ExtensionDirectories to work is to avoid hard-coding the staging directory to the system manager runtime directory, everything else just works (TM).
* | manager: pass monitor metadata in more casesZbigniew Jędrzejewski-Szmek2022-03-101-0/+9
| | | | | | | | | | | | The first ExecStartPre or the first ExecStart commands would get the metadata, but not the subsequent ones. Also check that we do not pass it in ExecStartPost.
* | TEST-68: enhance testing of chained commandsZbigniew Jędrzejewski-Szmek2022-03-101-5/+21
| | | | | | | | | | | | | | | | | | The test would fail when the the same handler was used for multiple *failing* units. We need to call 'reset-failed' to let the manager forget about the earlier ones. systemd-analyze log-target console is removed, because it's easier to follow the logs if logging it to the journal.