summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2015-07-06treewide: fix typos of let'sZbigniew Jędrzejewski-Szmek
2015-06-23test: fix test-copy without /etc/os-release.Dimitri John Ledkov
2015-06-18Merge pull request #289 from michich/hashmap-small-cleanupLennart Poettering
a tiny hashmap cleanup
2015-06-18test: disable test-barrier by defaultDavid Herrmann
The test-barrier binary uses real-time alarms and timeouts to test for races in the thread-barrier implementation. Hence, if your system is under high load and your scheduler decides to not run test-barrier for >BASE_TIME, then the tests are likely to fail. Two options: 1) Increase BASE_TIME. This will make the test take significantly longer for no real good. Furthermore, it is still not guaranteed that the task is scheduled. 2) Don't rely on real-time timers, but use explicit synchronization. This would basically test one barrier implementation with another.. kinda ironic.. but maybe something worth looking into. 3) Disable test-barrier by default. This patch chooses option 3) and makes sure test-barrier only runs if you pass any argument. Side note: test-barrier is written in a way that if it fails under load, but does not on idle systems, then it is very _unlikely_ that the barrier implementation is the culprit. Hence, it makes little sense to run it under load, anyway. It will not improve the test coverage of barrier.c, but rather the coverage of the test itself.
2015-06-17load-fragment: reset the list on an ExecStart= containing only whitespaceFilipe Brandenburger
This is consistent with how an empty string works in an ExecStart= statement. We should not differentiate between an empty string and whitespace only (since they look the same.) Update the test case with whitespace only to reflect that the list is reset. Tested that `test-unit-file` passes and other test cases are not affected. Installed the patched systemd binaries on a machine, booted it, looked for out of the usual behavior but did not find any.
2015-06-17load-fragment: use unquote_first_word in config_parse_execFilipe Brandenburger
Convert config_parse_exec() from using FOREACH_WORD_QUOTED into a loop of unquote_first_word. Loop through the arguments only once (the FOREACH_WORD_QUOTED implementation did it twice, once to count them and another time to process and store them.) Use newly introduced flag UNQUOTE_UNESCAPE_RELAX to preserve unrecognized escape sequences such as regexps matches such as "\w", "\d", etc. (Valid escape sequences such as "\s" or "\b" still need an extra backslash if literals are desired for regexps.) Differences in behavior: - Handle ; (command separator) in special, so that only ; on its own is valid for that purpose, an quoted semicolon ";" or ';' will now behave as a literal semicolon. This is probably what was initially intended. - Handle \; (to introduce a literal semicolon) in special, so that only \; is turned into a semicolon but not \\; or "\\;" or "\;" which are kept as a literal \; in the output. This is probably what was initially intended. Known issues: - Using an empty string (for example, ExecStartPre=<empty>) will empty the list and remove the existing commands, but using whitespace only (for example, ExecStartPre=<spaces>) will not. This is a pre-existing issue and will be dealt with in a follow up commit. Tested: - Unit tests passing. Also `make distcheck` still works as expected. - Installed it on a local machine and booted with it, checked console output, systemctl and journalctl output, did not notice any issues running the patched systemd binaries. Relevant bug: https://bugs.freedesktop.org/show_bug.cgi?id=90794
2015-06-17tests: additional cases in test-unit-fileFilipe Brandenburger
These tests will be useful to check the cases regarding quoted and escaped semicolon when we switch to using unquote_first_word. Additionally, convert some of the tests that have semicolons so that the argument after the semicolon looks like a path (starts with /) so that we can see the change of behavior when making config_parse_exec more strict about what it accepts as a command separator.
2015-06-17util: Introduce unquote_first_word_and_warnFilipe Brandenburger
It will try to unquot_first_word, but if it runs into escaping problems it will retry it adding UNQUOTE_CUNESCAPE_RELAX to the flags. If it succeeds on the second try, it will log a warning about it. If it fails both times, it will log an error. Add test cases to confirm it behaves as expected.
2015-06-17util: New flag UNQUOTE_UNESCAPE_RELAX for unquote_first_wordFilipe Brandenburger
The new flag UNQUOTE_UNESCAPE_RELAX preserves unrecognized escape sequences verbatim in unquote_first_word, either when it's a trailing backslash (similar to UNQUOTE_RELAX, but in this case keep the extra backslash in the output) or in the middle of a sequence string. Add unit test cases to ensure the new flag works as expected and to prevent regressions from being introduced. Tested with a follow up commit converting config_parse_exec() to start using unquote_first_word, in which case this flags makes it possible to preserve unrecognized escape sequences. Relevant bug: https://bugs.freedesktop.org/show_bug.cgi?id=90794
2015-06-17hashmap: allow NULL key in ordered_hashmap_next()Michal Schmidt
There is no reason to require key to be non-NULL. Change test_ordered_hashmap_next() to use trivial_hash_ops in order to test NULL key too.
2015-06-17Merge pull request #176 from filbranden/test_cgroup_mask1Lennart Poettering
test-cgroup-mask: unit_get_sibling_mask ignores cgroup_supported
2015-06-16Merge pull request #197 from dvdhrm/hashmapMichal Schmidt
hashmap: fix iterators to not skip entries
2015-06-15Merge pull request #214 from poettering/signal-rework-2Lennart Poettering
everywhere: port everything to sigprocmask_many() and friends
2015-06-15everywhere: port everything to sigprocmask_many() and friendsLennart Poettering
This ports a lot of manual code over to sigprocmask_many() and friends. Also, we now consistly check for sigprocmask() failures with assert_se(), since the call cannot realistically fail unless there's a programming error. Also encloses a few sd_event_add_signal() calls with (void) when we ignore the return values for it knowingly.
2015-06-15util: when creating temporary file names, allow including extra id string in itLennart Poettering
This adds a "char *extra" parameter to tempfn_xxxxxx(), tempfn_random(), tempfn_ranomd_child(). If non-NULL this string is included in the middle of the newly created file name. This is useful for being able to distuingish the kind of temporary file when we see one. This also adds tests for the three call. For now, we don't make use of this at all, but port all users over.
2015-06-15firewall: rename fw-util.[ch] → firewall-util.[ch]Daniel Mack
The names fw-util.[ch] are too ambiguous, better rename the files to firewall-util.[ch]. Also rename the test accordingly.
2015-06-14hashmap: fix iterators to not skip entriesDavid Herrmann
Currently, the HASHMAP iterators stop at the first NULL entry in a hashmap. This is non-obvious and breaks users like sd-device, which legitimately store NULL values in a hashmap. Fix all the iterators by taking a pointer to the value storage, instead of returning it. The iterators now return a boolean that tells whether the end of the list was reached. Current users of HASHMAP_FOREACH() are *NOT* changed to explicitly check for NULL. If it turns out, there were users that inserted NULL into hashmaps, but didn't properly check for it during iteration, then we really want to find those and fix them.
2015-06-14test-netlink-manual: typo fixThomas Hindoe Paaboel Andersen
No functional change, but looked weird.
2015-06-13sd-netlink: rename from sd-rtnlTom Gundersen
2015-06-11test-cgroup-mask: unit_get_sibling_mask ignores cgroup_supportedFilipe Brandenburger
The result of unit_get_sibling_mask returns bits for the sibling cgroups even if they are not supported in the local system. I caught this on a machine where my kernel was misconfigured with CONFIG_MEMCG unset, but the rest of the cgroup infrastructure enabled. Tested with `make check` on a host running a kernel where CONFIG_MEMCG is not set.
2015-06-11sd-rtnl: make joining broadcast groups implicitTom Gundersen
2015-06-11Merge pull request #6 from xnox/drop-nameLennart Poettering
shared: Drop 'name=' prefix from SYSTEMD_CGROUP_CONTROLLER define.
2015-06-10resolve: move dns routines into sharedNick Owens
2015-06-10test-copy: test copy_bytes()Zbigniew Jędrzejewski-Szmek
2015-06-09path-util: Fix path_is_mount_point for parent mount points in symlink modeMartin Pitt
When we have a structure like this: /bin -> /usr/bin /usr is a mount point Then path_is_mount_point("/bin", AT_SYMLINK_FOLLOW) needs to look at the pair /usr/bin and /usr, not at the pair / and /usr/bin, as the latter have different mount IDs. But we only want to consider the base name, not any parent. Thus we have to resolve the given path first to get the real parent when allowing symlinks. Bug: https://github.com/systemd/systemd/issues/61
2015-06-03test-util: fix a memleakThomas Hindoe Paaboel Andersen
2015-06-03test-unit-file.c: fixup the test for commit 3b51f8ddd5Harald Hoyer
2015-06-03util: fix another cunescape() regressionDaniel Mack
Fix a regression caused by 4034a06d ("util: rework word parsing and c unescaping code") which broke octal escape sequences. The reason for this breakage is that cunescape_one() expects 4 characters in an octal encoding, which is a stray left-over from the old code which operated on different variables to make the length check. While at it, add a test case to prevent the same thing from happening again.
2015-06-03udevd: simplify signal mask handlingTom Gundersen
We used to block all signals, and restore the original signal mask before exec'ing external processes. Now we just block the signals we care about and unconditionally unblock all signals before exec'ing.
2015-06-02shared: Drop 'name=' prefix from SYSTEMD_CGROUP_CONTROLLER define.Dimitri John Ledkov
In cgtop,mount-setup,nspawn the name= prefix is hard-coded in the mount options, and the define is not used. Everywhere else, we explicitly white-list allow 'name=' prefix to be used with all controllers, and strip it out to 'normalise' the controller name. That work is mostly inflicted on us due to 'name=' prefix in the define. Dropping this prefix makes everything more sane overall.
2015-06-01test-unit-file: add test for improperly escaped exec stringDaniel Mack
Add a regression test for the recent breakage of handling improperly escaped exec strings in unit files. Code contributed by Martin Pitt: https://bugs.freedesktop.org/show_bug.cgi?id=90794
2015-05-30test-fdset: add more testsRonny Chevalier
add tests for the following functions: - fdset_new_array - fdset_steal_first - fdset_isempty
2015-05-30tests: add test-conf-parserRonny Chevalier
2015-05-29util: split out signal-util.[ch] from util.[ch]Lennart Poettering
No functional changes.
2015-05-29udevd: event - port spawn_wait() to sd-eventTom Gundersen
This allows us to drop the special sigterm handling in spawn_wait() as this will now be passed directly to the worker event loop. We now log failing spawend processes at 'warning' level, and timeouts are in terms of CLOCK_BOOTTIME when available, otherwise the behavior is unchanged.
2015-05-29path-util: Change path_is_mount_point() symlink arg from bool to flagsMartin Pitt
This makes path_is_mount_point() consistent with fd_is_mount_point() wrt. flags.
2015-05-29path-util: Fix path_is_mount_point for filesMartin Pitt
Commits 27cc6f166 and f25afeb broke path_is_mount_point() for files (such as /etc/machine-id → /run/machine-id bind mounts) as with the factorization of fd_is_mount_point() we lost the parent directory. We cannot determine that from an fd only as openat(fd, "..") only works for directory fds. Change fd_is_mount_point() to behave like openat(): It now takes a file descriptor of the containing directory, a file name in it, and flags (which can be 0 or AT_SYMLINK_FOLLOW). Unlike name_to_handle_at() or openat(), fstatat() only accepts the inverse flag AT_SYMLINK_NOFOLLOW and complains with EINVAL about AT_SYMLINK_FOLLOW; so we need to transform the flags for that fallback. Adjust rm_rf_children() accordingly (only other caller of fd_is_mount_point() aside from path_is_mount_point()). Add test cases for files, links, and file bind mounts (the latter will only work when running as root). Split out a new test_path_is_mount_point() test case function as it got significantly larger now.
2015-05-25test: hostname - test that hostname is truly initializedTom Gundersen
Fixes CID CID 1299638 (use after free).
2015-05-21json: minor style fixessystemd/v220Lennart Poettering
2015-05-21test.json: fix build on x86-32 where int and intmax_t differLennart Poettering
2015-05-19json: fix a mem leakThomas Hindoe Paaboel Andersen
2015-05-19test/test-json: Tests for the tokenizer bugfix and the DOM parserPavel Odvody
The DOM parser tests are accompanied with structure and element analysis
2015-05-19hostname: Allow comments in /etc/hostnameMartin Pitt
The hostname(1) tool allows comments in /etc/hostname. Introduce a new read_hostname_config() in hostname-util which reads a hostname configuration file like /etc/hostname, strips out comments, whitespace, and cleans the hostname. Use it in hostname-setup.c and hostnamed and remove duplicated code. Update hostname manpage. Add tests. https://launchpad.net/bugs/1053048
2015-05-19test-hashmap: fix an assertThomas Hindoe Paaboel Andersen
CID#1299016
2015-05-18core: Private*/Protect* options with RootDirectoryAlban Crequy
When a service is chrooted with the option RootDirectory=/opt/..., then the options PrivateDevices, PrivateTmp, ProtectHome, ProtectSystem must mount the directories under $RootDirectory/{dev,tmp,home,usr,boot}. The test-ns tool can test setup_namespace() with and without chroot: $ sudo TEST_NS_PROJECTS=/home/lennart/projects ./test-ns $ sudo TEST_NS_CHROOT=/home/alban/debian-tree TEST_NS_PROJECTS=/home/alban/debian-tree/home/alban/Documents ./test-ns
2015-05-18util: split all hostname related calls into hostname-util.cLennart Poettering
2015-05-15core: Fix assertion with empty Exec*= pathsMartin Pitt
An Exec*= line with whitespace after modifiers, like ExecStart=- /bin/true is considered to have an empty command path. This is as specified, but causes systemd to crash with Assertion 'skip < l' failed at ../src/core/load-fragment.c:607, function config_parse_exec(). Aborting. Aborted (core dumped) Fix this by logging an error instead and ignoring the invalid line. Add corresponding test cases. Also add a test case for a completely empty value which resets the command list. https://launchpad.net/bugs/1454173
2015-05-13util: add generic calls for prefixing a root directory to a pathLennart Poettering
So far a number of utilities implemented their own calls for this, unify them in prefix_root() and prefix_roota(). The former uses heap memory, the latter allocates from the stack via alloca(). Port over most users of a --root= logic.
2015-05-11install: when exporting prefix InstallInfo to become UnitFileInstallInfoLennart Poettering
All other types exported from install.h should be namespaces like this, hence namespace InstallInfo the same way. Also, remove external forward definition of UnitFileScope type.
2015-05-11core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering
It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.