Commit graph

145 commits

Author SHA1 Message Date
Anita Zhang 31cd5f63ce core: ExecCondition= for services
Closes #10596
2019-07-17 11:35:02 +02:00
Yu Watanabe 8cec0a5c32 tree-wide: drop duplicated blank lines
```
$ for i in */*.[ch] */*/*.[ch]; do sed -e '/^$/ {N; s/\n$//g}' -i $i; done
$ git checkout HEAD -- basic/linux shared/linux
```
2019-07-15 18:41:27 +02:00
Michal Sekletar 3f09629c22
Merge pull request #12628 from keszybz/dbus-execute
Rework cpu affinity parsing
2019-05-30 12:32:53 +02:00
Zbigniew Jędrzejewski-Szmek 167a776dbe test-execute: use CPUSet too
cpu_set_malloc() was the last user. It doesn't seem useful to keep
it just to save the allocation of a few hundred bytes in a test, so
it is dropped and a fixed maximum is allocated (1024 bytes).
2019-05-29 10:29:28 +02:00
Lennart Poettering c3ab2c389e test-execute: let's ignore the difference between CLD_KILLED and CLD_DUMPED
Depending on system configuration and whether SCMP_ACT_KILL_PROCESS or
SCMP_ACT_KILL_THREAD is available/used processes might coredump on
specific coredumps or are just plain killed. For our test case the
difference doesn't really matter, hence let's hide it away.
2019-05-24 10:48:28 +02:00
Lennart Poettering 18f8c5d466 test-execute: check exit code before exit status
The meaning of the status changes depending on the code, hence let's
always compare the code first, status second.
2019-05-24 10:48:28 +02:00
Zbigniew Jędrzejewski-Szmek 9ca5828475 test-execute: skip flaky test when we can't unshare namespaces
When running in Fedora "mock", / is a tmpfs and /home is not mounted. The test
assumes that /home will be a tmpfs only and only if we can unshare. Obviously,
this does not hold in this case, because unsharing is not possible, but /home
is still a tmpfs. Let's just skip the test, since it's fully legitimate to
mount either or both of / and /home as tmpfs.
2019-03-26 18:53:53 +01:00
Zbigniew Jędrzejewski-Szmek 6aed6a1157 test-execute: provide custom failure message
test_exec_ambientcapabilities: exec-ambientcapabilities-nobody.service: exit status 0, expected 1

Sometimes we get just the last line, for example from the failure summary,
so make it as useful as possible.
2019-03-26 18:53:53 +01:00
Zbigniew Jędrzejewski-Szmek 054d871d41 test-execute: block /sys not /proc
As explained in the previous commit, blocking /proc can cause us
to go into a long loop or fail the test.
2019-03-15 15:46:41 +01:00
Zbigniew Jędrzejewski-Szmek 9efb96315a test-execute: allow filtering test cases by pattern
When debugging failure in one of the cases, it's annoying to have to wade
through the output from all the other cases. Let's allow picking select
cases.
2019-03-15 15:46:41 +01:00
Yu Watanabe 7e46b29bd3 test: add a testcase for ProtectHome=tmpfs vs ProtectSystem=strict 2019-03-13 11:53:59 +09:00
Zbigniew Jędrzejewski-Szmek 2bd061a48b test-execute: avoid undefined variable warning when compiled w/o seccomp 2019-03-07 10:59:06 +01:00
Anita Zhang 7ca69792e5 core: add ':' prefix to ExecXYZ= skip env var substitution 2019-02-20 17:58:14 +01:00
Yu Watanabe 3285320786 test-execute: unset $HOME before testing
Otherwise, test for %h specifier may fail.

Fixes #11609.
2019-02-01 18:43:14 +01:00
Lennart Poettering b2238e380e test,systemctl,nspawn: use "const char*" instead of "char*" as iterator for FOREACH_STRING()
The macro iterates through literal strings (i.e. constant strings),
hence it's more correct to have the iterator const too.
2019-01-16 12:29:30 +01:00
Fabrice Fontaine a22692d718 capability: fix build without PR_CAP_AMBIENT
systemd fails to build on kernel without PR_CAP_AMBIENT (< 4.3) since
2a03bb3e65

To fix this error, include missing_prctl.h in all files using
PR_CAP_AMBIENT

Fixes:
 - http://autobuild.buildroot.org/results/699c078aa078240c6741da4dbd0871450ceeca92

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-01-11 17:37:20 +01:00
Lennart Poettering 0df54921bc tree-wide: use new macro HAS_FEATURE_ADDRESS_SANITIZER everywhere 2018-12-03 17:38:50 +01:00
Zbigniew Jędrzejewski-Szmek 62a85ee0a9 tree-wide: rename path_join_many() to path_join()
$ git grep -e path_join_many -l|xargs sed -r -i 's/path_join_many/path_join/g'

The two test functions are merged into one.
2018-11-30 10:59:47 +01:00
Zbigniew Jędrzejewski-Szmek 30016f21b3 tree-wide: replace path_join with path_join_many 2018-11-30 10:40:38 +01:00
Evgeny Vereshchagin 176ceb2c47 tests: skip test-execute on TravisCI under ASan
Unfortunately, f5f9a580dd didn't help much and now
the next subtest gets stuck from time to time. Let's skip
test-execute altogether so as not to bother anybody with
spurious failures.

https://github.com/systemd/systemd/issues/10696 is still open.
Everybody is welcome to share ideas :-)
2018-11-24 06:05:23 +03:00
Evgeny Vereshchagin f5f9a580dd tests: skip test_exec_ambientcapabilities on Travis CI under ASan
Let's not bother contributors with spurious failures nobody can't
seem to reproduce. There is an issue about that where we're trying
to figure out what's going on: https://github.com/systemd/systemd/issues/10696.
2018-11-20 20:23:19 +01:00
Lennart Poettering bd7989a3d9 tests: always use the right vtable wrapper calls
Prompted by https://github.com/systemd/systemd/pull/10836#discussion_r234598868
2018-11-20 05:34:29 +03:00
Lennart Poettering 1acacd737b test-execute: fix killing of unit processes
Let's use the correct wrapper for calling unit vtable functions. Let's
make sure we always use the right wrappers, and never bypass them
needlessly.

Moreover use SIGKILL rather than "9" as signal name. Let's not be
needlessly cryptic.

Follow-up for: f7f8e8cbb9
2018-11-19 21:53:23 +01:00
Evgeny Vereshchagin f7f8e8cbb9 test: kill all processes launched by test-execute before exiting
As was shown in https://github.com/systemd/systemd/issues/10696#issuecomment-439613204,
currently `meson` waits for 1080 seconds (which is three times the global timeout) for the
test to fail completely even though it takes just two minutes for it to really fail. This
happens because the test itself leaves the services it has launched behind, which, in turn, makes
meson think that the test is still in progress. KILL_ALL with SIGKILL should make the issue
go away.
2018-11-19 09:24:22 +01:00
Lennart Poettering 5f00dc4df6 test: skip various tests if namespacing is not available
Apparently on Debian LXC/AppArmor doesn't allow namespacing to container
payloads. Deal with it.

Fixes: #9700
2018-10-24 19:40:24 +02:00
Yu Watanabe e913b7988f
test-execute: add a test for systemcall filter (#10273)
This adds a test for issue #9939 which is fixed by
a5404992cc (#9942).
2018-10-05 14:46:30 +09:00
Yu Watanabe b7172f3471 test-execute: also tests under the condition that unshare() is filtered
This is mainly for testing 1beab8b0d0.
2018-10-03 08:33:23 +02:00
Yu Watanabe 642d1a6d6e test-execute: skip several tests when running in container 2018-09-21 00:45:00 +09:00
Yu Watanabe 738c74d7b1 test-execute: also check python3 is installed or not 2018-09-21 00:45:00 +09:00
Zbigniew Jędrzejewski-Szmek 730d989acc tests: add a helper function to skip with errno 2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 6d7c403324 tests: use a helper function to parse environment and open logging
The advantages are that we save a few lines, and that we can override
logging using environment variables in more test executables.
2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 317bb217d3 tests: add helper to unify skipping a test and exiting 2018-09-14 09:29:57 +02:00
Filipe Brandenburger 55890a40c3 test: remove support for suffix in get_testdata_dir()
Instead, use path_join() in callers wherever needed.
2018-09-12 09:49:03 -07:00
Yu Watanabe 9f82d685f3 test: add tests for DynamicUser= with static User= whose UID and GID are different 2018-07-26 16:32:10 +09:00
Zsolt Dollenstein 566b7d23eb Add support for opening files for appending
Addresses part of #8983
2018-07-20 03:54:22 -07:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
Fixes #9320.

for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do
  git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms'
done
2018-06-20 11:58:53 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Yu Watanabe 2b633119a0 test: add test for trailing dot in WorkingDirectory= and RuntimeDirectory= 2018-06-03 23:59:51 +09:00
Lennart Poettering cdc0f9be92
Merge pull request #8817 from yuwata/cleanup-nsflags
core: allow to specify RestrictNamespaces= multiple times
2018-05-24 16:49:13 +02:00
Felipe Sateler 57b7a260c2 core: undo the dependency inversion between unit.h and all unit types 2018-05-15 14:24:34 -04:00
Yu Watanabe 1c5873096e test-execute: remove state directories before running tests
Fixes #8679.
2018-05-10 22:50:51 -07:00
Joost Heitbrink b6887d7ae4 test: add testcase for environment file variables with backslashes
systemd silently strips out backslashes in variables from environment
files. Add a testcase that explicitly tests for this behaviour.
2018-05-11 13:15:16 +09:00
Yu Watanabe 1dcf96c29f test: add tests for merging RestrictNamespaces= 2018-05-05 11:07:37 +09:00
Yu Watanabe cfa24ca0e6 test: add tests for PrivateDevices= with '+' prefix 2018-05-01 13:44:24 +09:00
Lennart Poettering 63d6135fea tests: compare with correct shell
We synthesize the passwd record for UID 0, hence we need to compare with
our synthesized data and not with the data stored in /etc/passwd
2018-04-19 11:41:28 +02:00
Lennart Poettering 2cb36f7c1e
Merge pull request #8575 from keszybz/non-absolute-paths
Do not require absolute paths in ExecStart and friends
2018-04-17 15:54:10 +02:00
Zbigniew Jędrzejewski-Szmek 5008da1ec1 systemd: do not require absolute paths in ExecStart
Absolute paths make everything simple and quick, but sometimes this requirement
can be annoying. A good example is calling 'test', which will be located in
/usr/bin/ or /bin depending on the distro. The need the provide the full path
makes it harder a portable unit file in such cases.

This patch uses a fixed search path (DEFAULT_PATH which was already used as the
default value of $PATH), and if a non-absolute file name is found, it is
immediately resolved to a full path using this search path when the unit is
loaded. After that, everything behaves as if an absolute path was specified. In
particular, the executable must exist when the unit is loaded.
2018-04-16 16:09:46 +02:00
Zbigniew Jędrzejewski-Szmek ba412430a9 tests: use manager_load_startable_unit_or_warn() to load units
Doing manager_load_unit() followed by UNIT_VTABLE(unit)->start(unit) would
result in an assertion failure in ->start() if the unit failed to load
properly. Something like this is okey-ish is tests, since the test units are
not expected to fail to load, but the reason for failure is clearer if we
fail immediately.
2018-04-16 16:08:52 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00