summaryrefslogtreecommitdiff
path: root/test/units
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #16968 from yuwata/remove-old-device-on-move-eventLennart Poettering2020-10-141-0/+16
|\ | | | | core, udev: remove old device on move event
| * test: add test for device renaming issue #16967Yu Watanabe2020-09-151-0/+16
| |
* | Merge pull request #17152 from keszybz/make-mountapivfs-defaultLennart Poettering2020-10-011-26/+28
|\ \ | | | | | | Make MountAPIVFS=yes default
| * | TEST-50-DISSECT: drop now-unneeded MountAPIVFS=yes and full paths to executablesZbigniew Jędrzejewski-Szmek2020-09-241-26/+28
| |/ | | | | | | With the previous changes we can simplify the invocations in the test a bit.
* | test: switch TEST-02-CRYPTSETUP and TEST-24-UNITTESTSZbigniew Jędrzejewski-Szmek2020-09-243-5/+5
|/ | | | | | | When tests are executed serially (the default), it seems better to launch the fairly generic test that runs the unittests early in the sequence. Right now the tests are ordered based on when they were written, but this doesn't make much sense.
* test: add test for new "sticky" tags logicLennart Poettering2020-09-012-0/+73
|
* tests/TEST-50: support the case when /etc/os-release is presentZbigniew Jędrzejewski-Szmek2020-08-271-7/+9
| | | | | | | | | | | | | | | | We have four legal cases: 1. /usr/lib/os-release exists and /etc/os-release is a symlink to it 2. both exist but /etc/os-release is not a symlink to /usr/lib/os-release 3. only /usr/lib/os-release exists 4. only /etc/os-release exists The generic setup code in test-functions and create-busybox-image didn't handle case 3. The test-specific code in TEST-50 didn't handle 2 (because the general setup code would only install /etc/os-release in the image and grep -f /usr/lib/os-release would not work) and 4 (same reason) and would fail in case 3 in generic setup.
* test: add test suite for new credentials logicLennart Poettering2020-08-252-0/+38
|
* Merge pull request #16686 from bluca/mount_images_optsZbigniew Jędrzejewski-Szmek2020-08-211-18/+31
|\ | | | | core: add mount options support for MountImages
| * core: add mount options support for MountImagesLuca Boccassi2020-08-201-8/+16
| | | | | | | | | | | | Follow the same model established for RootImage and RootImageOptions, and allow to either append a single list of options or tuples of partition_number:options.
| * core: change RootImageOptions to use names instead of partition numbersLuca Boccassi2020-08-201-10/+15
| | | | | | | | Follow the designations from the Discoverable Partitions Specification
* | nspawn: move $NOTIFY_SOCKET into /run/host/ tooLennart Poettering2020-08-201-1/+1
|/ | | | | | | | | | | | | | | The sd_notify() socket that nspawn binds that the payload can use to talk to it was previously stored in /run/systemd/nspawn/notify, which is weird (as in the previous commit) since this makes /run/systemd something that is cooperatively maintained by systemd inside the container and nspawn outside of it. We now have a better place where container managers can put the stuff they want to pass to the payload: /run/host/, hence let's make use of that. This is not a compat breakage, since the sd_notify() protocol is based on the $NOTIFY_SOCKET env var, where we place the new socket path.
* test: update tests to use new JSON output instead of human readable outputLennart Poettering2020-08-121-13/+17
|
* core: new feature MountImagesLuca Boccassi2020-08-051-0/+20
| | | | | | | | | | | | | Follows the same pattern and features as RootImage, but allows an arbitrary mount point under / to be specified by the user, and multiple values - like BindPaths. Original implementation by @topimiettinen at: https://github.com/systemd/systemd/pull/14451 Reworked to use dissect's logic instead of bare libmount() calls and other review comments. Thanks Topi for the initial work to come up with and implement this useful feature.
* test: adapt TEST-13-NSPAWN-SMOKE for SUSEElisei Roca2020-08-031-18/+24
|
* service: add new RootImageOptions featureLuca Boccassi2020-07-291-0/+31
| | | | | | | | | | Allows to specify mount options for RootImage. In case of multi-partition images, the partition number can be prefixed followed by colon. Eg: RootImageOptions=1:ro,dev 2:nosuid nodev In absence of a partition number, 0 is assumed.
* nspawn: rework how /run/host/ is set upLennart Poettering2020-07-231-4/+17
| | | | | | | | | | | Let's find the right os-release file on the host side, and only mount the one that matters, i.e. /etc/os-release if it exists and /usr/lib/os-release otherwise. Use the fixed path /run/host/os-release for that. Let's also mount /run/host as a bind mount on itself before we set up /run/host, and let's mount it MS_RDONLY after we are done, so that it remains immutable as a whole.
* verity: re-use already open devices if the hashes matchLuca Boccassi2020-07-211-1/+12
| | | | | | | | | | | | | | | | | | | | | | | Opening a verity device is an expensive operation. The kernelspace operations are mostly sequential with a global lock held regardless of which device is being opened. In userspace jumps in and out of multiple libraries are required. When signatures are used, there's the additional cryptographic checks. We know when two devices are identical: they have the same root hash. If libcrypsetup returns EEXIST, double check that the hashes are really the same, and that either both or none have a signature, and if everything matches simply remount the already open device. The kernel will do reference counting for us. In order to quickly and reliably discover if a device is already open, change the node naming scheme from '/dev/mapper/major:minor-verity' to '/dev/mapper/$roothash-verity'. Unfortunately libdevmapper is not 100% reliable, so in some case it will say that the device already exists and it is active, but in reality it is not usable. Fallback to an individually-activated unique device name in those cases for robustness.
* test: run systemd-dissect and systemd-run with log level debug in ↵Luca Boccassi2020-07-211-0/+5
| | | | TEST-50-DISSECT
* Merge pull request #16478 from bluca/dissect_testsZbigniew Jędrzejewski-Szmek2020-07-201-11/+93
|\ | | | | Expand TEST-50-DISSECT to cover dm-verity features
| * test: exercise RootImage, RootHash and RootVerity in TEST-50-DISSECTLuca Boccassi2020-07-151-0/+10
| | | | | | | | Run with both the single-filesystem image and the GPT image
| * test: pre-assemble minimal image for TEST-50-DISSECT at build timeLuca Boccassi2020-07-151-16/+11
| | | | | | | | Easier than in the limited VM environment
| * test: exercise systemd-dissect with GPT and verity in TEST-50-DISSECTLuca Boccassi2020-07-151-0/+54
| |
| * test: exercise systemd-dissect --mount in TEST-50-DISSECTLuca Boccassi2020-07-151-6/+29
| |
* | nspawn: mount os-release in two steps to make it read-onlyLuca Boccassi2020-07-161-0/+2
|/ | | | | | | | The kernel interface requires setting up read-only bind-mounts in two steps, the bind first and then a read-only remount. Fix nspawn-mount, and cover this case in the integration test. Fixes #16484
* timer: Adjust calendar timers based on monotonic timer instead of realtimeFilipe Brandenburger2020-07-152-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the RTC time at boot is off in the future by a few days, OnCalendar= timers will be scheduled based on the time at boot. But if the time has been adjusted since boot, the timers will end up scheduled way in the future, which may cause them not to fire as shortly or often as expected. Update the logic so that the time will be adjusted based on monotonic time. We do that by calculating the adjusted manager startup realtime from the monotonic time stored at that time, by comparing that time with the realtime and monotonic time of the current time. Added a test case to validate this works as expected. The test case creates a QEMU virtual machine with the clock 3 days in the future. Then we adjust the clock back 3 days, and test creating a timer with an OnCalendar= for every 15 minutes. We also check the manager startup timestamp from both `systemd-analyze dump` and from D-Bus. Test output without the corresponding code changes that fix the issue: Timer elapse outside of the expected 20 minute window. next_elapsed=1594686119 now=1594426921 time_delta=259198 With the code changes in, the test passes as expected.
* Merge pull request #15891 from bluca/host_os_releaseZbigniew Jędrzejewski-Szmek2020-07-081-0/+14
|\ | | | | Container Interface: expose the host's os-release metadata to nspawn and portable guests
| * nspawn: implement container host os-release interfaceLuca Boccassi2020-06-231-0/+14
| |
* | test: bump the TEST-47 sleeps once againFrantisek Sumsal2020-07-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several recent failed runs show that the test is still racy in two ways: 1) Sometimes it takes a while before the PID file is created, leading to: ``` [ 10.950540] testsuite-47.sh[308]: ++ cat /leakedtestpid [ 10.959712] testsuite-47.sh[308]: cat: /leakedtestpid: No such file or directory [ 10.959824] testsuite-47.sh[298]: + leaked_pid= ``` 2) Again, sometimes we check the leaked PID before the unit is actually stopped, leading to a false negative: ``` [ 18.099599] testsuite-47.sh[346]: ++ cat /leakedtestpid [ 18.116462] testsuite-47.sh[333]: + leaked_pid=342 [ 18.117101] testsuite-47.sh[333]: + systemctl stop testsuite-47-repro ... [ 20.033907] testsuite-47.sh[333]: + ps -p 342 [ 20.080050] testsuite-47.sh[351]: PID TTY TIME CMD [ 20.080050] testsuite-47.sh[351]: 342 ? 00:00:00 sleep [ 20.082040] testsuite-47.sh[333]: + exit 42 ```
* | core: refresh unit cache when building a transaction if UNIT_NOT_FOUNDLuca Boccassi2020-07-071-0/+27
| | | | | | | | | | | | | | | | | | When a command asks to load a unit directly and it is in state UNIT_NOT_FOUND, and the cache is outdated, we refresh it and attempto to load again. Use the same logic when building up a transaction and a dependency in UNIT_NOT_FOUND state is encountered. Update the unit test to exercise this code path.
* | test: use KILL instead of SIGKILL in TEST-52-HONORFIRSTSHUTDOWNFrantisek Sumsal2020-07-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SIG-prefixed signals for `kill` are not POSIX compliant, so on Ubuntu CI (which defaults to dash instead of bash) the TEST-52 contains following error: [ 9693.549638] sh[51]: + systemctl poweroff --no-block [ 9693.553130] systemd-logind[26]: System is powering down. [ 9693.608911] sh[54]: /bin/sh: 1: kill: Illegal option -S This can be reproduced manually as well, either by running dash, or bash in POSIX mode: $ dash -c 'kill -SIGKILL 123' dash: 1: kill: Illegal option -S $ bash --posix -c 'kill -SIGKILL 123' bash: line 0: kill: SIGKILL: invalid signal specification
* | core: store timestamps of unit load attemptsLuca Boccassi2020-06-301-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the system is under heavy load, it can happen that the unit cache is refreshed for an unrelated reason (in the test I simulate this by attempting to start a non-existing unit). The new unit is found and accounted for in the cache, but it's ignored since we are loading something else. When we actually look for it, by attempting to start it, the cache is up to date so no refresh happens, and starting fails although we have it loaded in the cache. When the unit state is set to UNIT_NOT_FOUND, mark the timestamp in u->fragment_loadtime. Then when attempting to load again we can check both if the cache itself needs a refresh, OR if it was refreshed AFTER the last failed attempt that resulted in the state being UNIT_NOT_FOUND. Update the test so that this issue reproduces more often.
* | Add quotes for -nGaoyi2020-06-261-1/+1
| | | | | | | | | | | | | | According to SC2070, -n doesn't work with unquoted arguments https://github.com/koalaman/shellcheck/wiki/SC2070 Signed-off-by: Gaoyi <ymuemc@163.com>
* | feature to honor first shutdown request to completionJay Burger2020-06-242-0/+14
|/ | | | | | Create unit tests per established norm at position 52 check in_set first before getting unit
* test: make TEST-02-CRYPTSETUP a bit more robustFrantisek Sumsal2020-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Prompted by systemd/systemd#16111. * check if /var is a mountpoint - if not, something went wrong. In case of systemd/systemd#16111 the /failed file was created, because systemd-cryptsetup failed, but it ended up being empty, making the result check incorrectly pass * forward journal messages to console - if we fail to mount /var, journald won't flush logs to the persistent storage and we end up empty handed and with no clue what went wrong For example, without systemd/systemd#16111 and with this patch: ... [FAILED] Failed to start systemd-cryptsetup@varcrypt.service. See 'systemctl status systemd-cryptsetup@varcrypt.service' for details. [DEPEND] Dependency failed for cryptsetup.target. ... [ 3.882451] systemd-cryptsetup[581]: Key file /etc/varkey is world-readable. This is not a good idea! [ 3.883946] systemd-cryptsetup[581]: WARNING: Locking directory /run/cryptsetup is missing! [ 3.884846] systemd-cryptsetup[581]: Failed to load Bitlocker superblock on device /dev/disk/by-uuid/180ba5ef-873b-4018-9968-47c23431f71a: Invalid argument ... [ 4.099451] sh[606]: + mountpoint /var [ 4.100025] sh[603]: + systemctl poweroff --no-block [ 4.101636] systemd[1]: Finished systemd-user-sessions.service. [ 4.102598] sh[608]: /var is not a mountpoint [FAILED] Failed to start testsuite-02.service.
* core: don't consider SERVICE_SKIP_CONDITION for abnormal or failure restartsAnita Zhang2020-06-104-0/+37
| | | | Fixes: #16115
* Merge pull request #16046 from bluca/dissect_squashfs_verityLennart Poettering2020-06-092-0/+38
|\ | | | | dissect: single-filesystem verity images with external hashdevice
| * dissect: support single-filesystem verity images with external verity hashLuca Boccassi2020-06-092-0/+38
| | | | | | | | | | | | | | | | dm-verity support in dissect-image at the moment is restricted to GPT volumes. If the image a single-filesystem type without a partition table (eg: squashfs) and a roothash/verity file are passed, set the verity flag and mark as read-only.
* | Merge pull request #16074 from msekletar/freezer-test-flakesLennart Poettering2020-06-091-0/+4
|\ \ | |/ |/| Freezer test flakes
| * tests: sleep a bit and give kernel time to perform the action after manual ↵Michal Sekletár2020-06-051-0/+4
| | | | | | | | | | | | freeze/thaw Fixes: #16050
* | test: add integration test for udev event timeoutMichal Sekletár2020-06-052-0/+53
|/ | | | | | Note that run_test() calls coredumpctl in a loop because in certain environments (1 vCPU unaccelerated QEMU VM) it might take quite a while to process the coredump.
* core: reload cache if it's dirty when starting a UNIT_NOT_FOUND unitLuca Boccassi2020-05-302-0/+45
| | | | | | | | The time-based cache allows starting a new unit without an expensive daemon-reload, unless there was already a reference to it because of a dependency or ordering from another unit. If the cache is out of date, check again if we can load the fragment.
* test: make the systemd-run calls synchronousFrantisek Sumsal2020-05-271-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | Otherwise we might be checking results of such calls before they even finish, causing nasty races like: ``` [ 15.656530] testsuite-43.sh[303]: + su testuser -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh systemd-run --user --unit=test-unprotected-home -P touch /home/testuser/works.txt ... [ 15.757744] testsuite-43.sh[324]: Running as unit: test-unprotected-home.service [ 15.775611] systemd[296]: Started /usr/bin/touch /home/testuser/works.txt. [ 15.783597] testsuite-43.sh[303]: + test -e /home/testuser/works.txt [ 15.787542] systemd[296]: test-unprotected-home.service: Succeeded. ... [ 15.787684] systemd[1]: Received SIGCHLD from PID 303 (bash). [ 15.787790] systemd[1]: Child 303 (bash) died (code=exited, status=1/FAILURE) [ 15.787881] systemd[1]: testsuite-43.service: Child 303 belongs to testsuite-43.service. [ 15.788040] systemd[1]: testsuite-43.service: Main process exited, code=exited, status=1/FAILURE [ 15.788224] systemd[1]: testsuite-43.service: Failed with result 'exit-code'. [ 15.788333] systemd[1]: testsuite-43.service: Service will not restart (restart setting) [ 15.788421] systemd[1]: testsuite-43.service: Changed start -> failed [ 15.788790] systemd[1]: testsuite-43.service: Job 160 testsuite-43.service/start finished, result=failed [ 15.788995] systemd[1]: Failed to start testsuite-43.service. ```
* test: Stricter test case for #15654 (Add more checks)Benjamin Robin2020-05-131-0/+4
| | | | | | | | Check: - There is only 3 messages logged with type stdout - Check all messages logged does not have new line: LINE_BREAK=eof - Check that the 3 messages are logged from a different PID - Check the 3 MESSAGE= content
* test: Add a test case for #15654Benjamin Robin2020-05-131-0/+8
|
* test: add test for cgroup v2 freezer supportMichal Sekletár2020-04-303-0/+301
|
* test: add a test case for #15528Kumar Kartikeya Dwivedi2020-04-231-0/+3
|
* Merge pull request #15520 from mrc0mmand/various-codebase-improvementsZbigniew Jędrzejewski-Szmek2020-04-221-2/+2
|\ | | | | tree-wide: various codebase improvements
| * tree-wide: fix spelling errorsFrantisek Sumsal2020-04-211-2/+2
| | | | | | | | | | | | Based on a report from Fossies.org using Codespell. Followup to #15436
* | test: drop Disk (Size|Free|Floor|Ceiling) fields prior comparingFrantisek Sumsal2020-04-211-1/+8
|/ | | | | | | | | | | The disk attributes can take some time to update on certain filesystems, so let's strip them from inputs of both `homectl` and `userdbctl` before comparing them to avoid unexpected fails. Also, switch from `cmp` to `diff` to make a potential test fail a bit more debuggable. Fixes: #14755