Commit graph

865 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 348dc14569 Merge pull request #3183 from crawford/preset-array
install: cache the presets before evaluating
2016-05-03 16:24:09 -04:00
Alex Crawford 622d370584 test: ensure presets are evaluated in order
This tests to make sure that preset patterns are checked in the order
they were declared. Both "prefix-1.service" and "prefix-2.service" match
against two rules: their exact name (which enables the service) and
"prefix-*.service" (which disables the service). Because of the
ordering, only "prefix-1.service" should be enabled.
2016-05-01 09:40:39 -07:00
Zbigniew Jędrzejewski-Szmek 26ccc1d087 Merge pull request #3151 from keszybz/pr3149-2
Assorted fixes #3149 + one commit tacked on top
2016-04-29 14:27:23 -04:00
Lennart Poettering 2985700185 core: make parsing of RLIMIT_NICE aware of actual nice levels 2016-04-29 16:27:49 +02:00
kayrus 313fe66fbd core: Filter by unit name behind the D-Bus, instead on the client side (#3142)
This commit improves systemd performance on the systems which have
thousands of units.
2016-04-29 15:59:51 +02:00
Lennart Poettering 2397bc4312 test-copy: never call alloca() in a loop
That's a total no-no, hence rework this to use malloc()-based memory instead of
alloca()-based memory.

Also see CODING_STYLE about this.
2016-04-29 14:28:04 +02:00
Lennart Poettering 0e2b2caccd copy: also copy AF_UNIX sockets
We previously would fail with EOPNOTSUPP when encountering an AF_UNIX socket in
the directory tree to copy. Fix that, and copy them too (even if they are dead
in the result).

Fixes: #2914
2016-04-29 14:28:03 +02:00
Zbigniew Jędrzejewski-Szmek b05b9cde12 test-path-util: add a trivial test for hidden_or_backup_file 2016-04-28 08:25:17 -04:00
Thomas H. P. Andersen 0f5e13822d tree-wide: remove unused variables (#3098) 2016-04-22 20:49:07 -04:00
Lennart Poettering 03532f0ae0 coredump,basic: generalize O_TMPFILE handling a bit
This moves the O_TMPFILE handling from the coredumping code into common library
code, and generalizes it as open_tmpfile_linkable() + link_tmpfile(). The
existing open_tmpfile() function (which creates an unlinked temporary file that
cannot be linked into the fs) is renamed to open_tmpfile_unlinkable(), to make
the distinction clear. Thus, code may now choose between:

 a) open_tmpfile_linkable() + link_tmpfile()
 b) open_tmpfile_unlinkable()

Depending on whether they want a file that may be linked back into the fs later
on or not.

In a later commit we should probably convert fopen_temporary() to make use of
open_tmpfile_linkable().

Followup for: #3065
2016-04-22 16:16:53 +02:00
Martin Pitt 48062f072c build: fix test-nss.c build failure with --disable-{resolved,myhostname} (#3081)
When building without resolved and/or myhostname, test-nss.c failed to build
with

  src/test/test-nss.c: In function 'main':
  src/test/test-nss.c:417:32: error: 'MODULE1' undeclared (first use in this function)
           NULSTR_FOREACH(module, MODULE1 MODULE2 MODULE3 MODULE4) {
                                ^

Ensure that all MODULEx are always defined, and empty if the module is not
available (so that it will be a no-op in the string concatenation).
2016-04-21 12:13:08 +02:00
Zbigniew Jędrzejewski-Szmek fe4aede922 systemctl: warning about missing install info for template units
The advice string didn't talk about template units at all. Extend
it and print when trying to enable a template unit without install info.

Fixes #2345.
2016-04-19 09:03:47 -04:00
Zbigniew Jędrzejewski-Szmek 596fc2636a Various formatting and style fixes 2016-04-18 23:35:51 -04:00
Zbigniew Jędrzejewski-Szmek 24737c2917 install: allow paths like LookupPath.generator to be NULL
Fixes #3047.
2016-04-16 23:08:23 -04:00
Zbigniew Jędrzejewski-Szmek 3ae5990c6e tree-wide: introduce PATH_IN_SET macro 2016-04-16 22:57:05 -04:00
Zbigniew Jędrzejewski-Szmek 76ec966f0e tree-wide: use ERFKILL instead of ESHUTDOWN for "unit masked"
If the error code ever leaks (we print the strerror error instead of providing
our own), the message for ESHUTDOWN is "Cannot send after transport endpoint
shutdown", which can be misleading. In particular it suggest that some
mishandling of the dbus connection occured. Let's change that to ERFKILL which
has the advantage that a) it sounds implausible as actual error, b) has the
connotation of disabling something manually.
2016-04-16 18:41:34 -04:00
Zbigniew Jędrzejewski-Szmek ea9b54f827 test-strv: add a test that extending empty strv works as expected
Just making sure :)
2016-04-13 21:09:32 -04:00
Lennart Poettering d2120590ff tests: override XDG_RUNTIME_DIR where we use the user runtime dir
We don#t really support systems where XDG_RUNTIME_DIR is not supported for
systemd --user. Hence, let's always set our own XDG_RUNTIME_DIR for tests that
involve systemd --user, so that we know it is set, and that it doesn't polute
the user's actual runtime dir.
2016-04-12 13:43:33 +02:00
Lennart Poettering 344ca7556b core,systemctl: add new "systemctl revert" command
This allows dropping all user configuration and reverting back to the vendor
default of a unit file. It basically undoes what "systemctl edit", "systemctl
set-property" and "systemctl mask" do.
2016-04-12 13:43:32 +02:00
Lennart Poettering 4c310c073a basic: remove rbtree code, it's unused
it's unused, and should we need it one day we can always resurrect it from git
history.
2016-04-12 13:43:32 +02:00
Lennart Poettering 4943d14306 systemctl: don't confuse sysv code with generated units
The SysV compat code checks whether there's a native unit file before looking
for a SysV init script. Since the newest rework generated units will show up in
the unit path, and hence the checks ended up assuming that there always was a
native unit file for each init script: the generated one.

With this change the generated unit file directory is suppressed from the
search path when this check is done, to avoid the confusion.
2016-04-12 13:43:32 +02:00
Lennart Poettering 9183df707b install: rename generator_paths() → generator_binary_paths()
This is too confusing, as this funciton returns the paths to the generator
binaries, while usually when we refer to the just the "generator path" we mean
the generated unit files. Let's clean this up.
2016-04-12 13:43:31 +02:00
Lennart Poettering e46e442243 tests: make sure test-path-lookup can run even when no units are installed on test system 2016-04-12 13:43:31 +02:00
Lennart Poettering 198402d3c9 test: bump up log level for install root test 2016-04-12 13:43:31 +02:00
Lennart Poettering a145334304 core: rework logic to drop duplicate and non-existing items from search path
Move this into a function of its own, so that we can run it after we ran the
generators, so that it takes into account removed generator dirs.
2016-04-12 13:43:30 +02:00
Lennart Poettering 463d0d1569 core: remove ManagerRunningAs enum
Previously, we had two enums ManagerRunningAs and UnitFileScope, that were
mostly identical and converted from one to the other all the time. The latter
had one more value UNIT_FILE_GLOBAL however.

Let's simplify things, and remove ManagerRunningAs and replace it by
UnitFileScope everywhere, thus making the translation unnecessary. Introduce
two new macros MANAGER_IS_SYSTEM() and MANAGER_IS_USER() to simplify checking
if we are running in one or the user context.
2016-04-12 13:43:30 +02:00
Lennart Poettering a3c4eb0710 core: rework generator dir logic, move the dirs into LookupPaths structure
A long time ago – when generators where first introduced – the directories for
them were randomly created via mkdtemp(). This was changed later so that they
use fixed name directories now. Let's make use of this, and add the genrator
dirs to the LookupPaths structure and into the unit file search path maintained
in it. This has the benefit that the generator dirs are now normal part of the
search path for all tools, and thus are shown in "systemctl list-unit-files"
too.
2016-04-12 13:43:29 +02:00
Evgeny Vereshchagin dbab702a2a tests: port udev-test to log_*_errno (#3015)
SYSTEMD_LOG_LEVEL=debug test/udev-test.pl is working now
Also, fixes CID 1354602
2016-04-11 21:31:57 +02:00
Evgeny Vereshchagin d2528deb44 tests: don't silently skip test-namespace 2016-04-10 23:41:04 +00:00
Evgeny Vereshchagin ad43ccb096 tests: ignore some mount errors in test-udev
Fixes:
$ sudo make distcheck
...
FAIL: test/udev-test.pl
...

$ vi systemd-229/_build/sub/test/udev-test.pl.log
...
failed to mount empty
/home/ubuntu/systemd/systemd-229/_inst/lib/udev/rules.d No such file or directory
...
failed to mount empty
/home/ubuntu/systemd/systemd-229/_inst/lib/udev/rules.d No such file or directory
...
414 errors occurred
2016-04-10 20:01:27 +00:00
Martin Pitt 600101ca28 Merge pull request #2969 from evverx/udev-test-dont-rely-on-underlying-fs-2
tests: don't rely on the underlying fs in test-udev (v2)
2016-04-06 11:51:38 +02:00
Lennart Poettering 056f0498fe Merge pull request #2947 from keszybz/test-nss
Add a test for nss modules and some related fixes
2016-04-06 10:48:55 +02:00
Evgeny Vereshchagin 21d9e3f339 tests: don't rely on the underlying fs in test-udev (v2)
* This reverts commit 646048b40a.
Let's test really big numbers again

* Don't be so brutal: use rmdir instead of rm -rf
As suggested https://github.com/systemd/systemd/pull/2966#issuecomment-205751680
2016-04-06 04:08:39 +00:00
Zbigniew Jędrzejewski-Szmek 2abb5b3b10 test-nss: test the resolution of various names
nss-dns is also "tested". It should be almost always available,
and provides a reference for comparison.
2016-04-05 23:19:56 -04:00
Evgeny Vereshchagin 2ce8d27b1f tests: don't rely on underlying fs in udev-test, use tmpfs instead
Fixes: #457
2016-04-05 10:38:09 +00:00
Daniel Mack 99d91109a6 Merge pull request #2880 from keszybz/more-tests
Add some simple tests for env_value_is_valid and env_assignment_is_valid
2016-03-22 10:23:12 +01:00
Zbigniew Jędrzejewski-Szmek b8c83cfc1a test-env-util: test env_{value,assignment}_is_valid
Just to make sure everything works as expected in relation
to https://bugzilla.redhat.com/show_bug.cgi?id=1312384.
2016-03-21 16:49:42 -04:00
Zbigniew Jędrzejewski-Szmek 93515caebf tests: rename test-env-replace to test-env-util 2016-03-21 16:17:18 -04:00
Ronny Chevalier 34f5ff465f test-execute: fix execution of AmbientCapabilities tests
Wrong tests were executed
2016-03-21 18:48:12 +01:00
Martin Pitt fa13cf9e21 test-copy: use correct data type for max_bytes
copy_bytes() and the comparisons in test_copy_bytes_regular_file() expect an
uint64_t, not a size_t. On 32 bit architectures the latter is 32 bit, leading
to truncation errors.

Fixes regression from commit 7a827fcb.
2016-03-21 14:58:30 +01:00
Daniel Mack 68de79d6a4 Merge pull request #2760 from ronnychevalier/rc/core_no_new_privileges_seccompv3
core: set NoNewPrivileges for seccomp if we don't have CAP_SYS_ADMIN
2016-03-21 12:57:43 +01:00
Zbigniew Jędrzejewski-Szmek 7a827fcb11 test-copy: test with different max_bytes values 2016-03-15 19:26:28 -04:00
Zbigniew Jędrzejewski-Szmek ce33fddad0 test-copy: add a test shuffling bytes between normal files
I started looking into adding copy_file_range support, and discovered
that we can improve the way we call sendfile:
- sendfile(2) man page is missing an important bit: the number of bytes to
  copy cannot be too big (SSIZE_MAX actually), and the description of EINVAL
  return code does not mention this either,
- our implementation works but calls sendfile over and over with a small
  size, which seems suboptimal.

First add a test which (under strace) can be used to see current behaviour.
2016-03-15 14:53:31 -04:00
Lukas Nykryn 7322824832 test-ipcrm: fix log message 2016-03-10 12:57:23 +01:00
Zbigniew Jędrzejewski-Szmek c41d3b3a0c Merge pull request #2792 from ronnychevalier/rc/tests_movev2
tests: move out unrelated tests from test-util to their own file
2016-03-09 23:53:54 -05:00
Zbigniew Jędrzejewski-Szmek b5ec6ada9c test-selinux: use yes_no() and strnull() 2016-03-04 21:45:58 -05:00
Zbigniew Jędrzejewski-Szmek 301a9c67aa test-libudev: disable monitor mode by default and add to automatic tests 2016-03-04 21:45:45 -05:00
Zbigniew Jędrzejewski-Szmek cc4c1d2290 test-libudev: modernization 2016-03-04 21:45:45 -05:00
Zbigniew Jędrzejewski-Szmek c1ab819162 Enable test-ipcrm, test-hostname in unsafe tests 2016-03-04 21:45:45 -05:00
Zbigniew Jędrzejewski-Szmek 134953c99c Enable test-daemon, test-log, test-watchdog by default
Those should be safe to run, resulting in some messages in logs.
2016-03-04 21:45:45 -05:00