summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2015-10-06core: add support for naming file descriptors passed using socket activationLennart Poettering
This adds support for naming file descriptors passed using socket activation. The names are passed in a new $LISTEN_FDNAMES= environment variable, that matches the existign $LISTEN_FDS= one and contains a colon-separated list of names. This also adds support for naming fds submitted to the per-service fd store using FDNAME= in the sd_notify() message. This also adds a new FileDescriptorName= setting for socket unit files to set the name for fds created by socket units. This also adds a new call sd_listen_fds_with_names(), that is similar to sd_listen_fds(), but also returns the names of the fds. systemd-activate gained the new --fdname= switch to specify a name for testing socket activation. This is based on #1247 by Maciej Wereski. Fixes #1247.
2015-09-30basic: split out cpu set specific APIs into cpu-set-util.[ch]Lennart Poettering
2015-09-30util: rename parse_cpu_set() to parse_cpu_set_and_warn()Lennart Poettering
It's pretty untypical for our parsing functions to log on their own. Clarify in the name that this one does.
2015-09-30fileio: make get_status_field() more genericAaro Koskinen
All users of get_status_field() expect the field pattern to occur in the beginning of a line, and the delimiter is ':'. Hardcode this into the function, and also skip any whitespace before ':' to support fields in files like /proc/cpuinfo. Add support for returning the full field value (currently stops on first whitespace). Rename the function so it's easier to ensure all callers switch to new semantics.
2015-09-29systemctl: move strv_skip_first() out of systemctl.cLennart Poettering
Make it generic, call it strv_skip() and move it to strv.[ch]
2015-09-24util: Add test for parse_cpu_setFilipe Brandenburger
2015-09-24s390: add personality supportHendrik Brueckner
Introduce personality support for Linux on z Systems to run particular services with a 64-bit or 31-bit personality.
2015-09-22cgtop: underline table headerLennart Poettering
Let's underline the header line of the table shown by cgtop, how it is customary for tables. In order to do this, let's introduce new ANSI underline macros, and clean up the existing ones as side effect.
2015-09-21core: fix group ownership when Group is setRonny Chevalier
When Group is set in the unit, the runtime directories are owned by this group and not the default group of the user (same for cgroup paths and standard outputs) Fix #1231
2015-09-21test-execute: add tests for RuntimeDirectoryRonny Chevalier
2015-09-11util: remove ring.[ch] + pty.[ch] and testsLennart Poettering
This was used by consoled, which was removed, let's remove this too now.
2015-09-10tree-wide: never use the off_t unless glibc makes us use itLennart Poettering
off_t is a really weird type as it is usually 64bit these days (at least in sane programs), but could theoretically be 32bit. We don't support off_t as 32bit builds though, but still constantly deal with safely converting from off_t to other types and back for no point. Hence, never use the type anymore. Always use uint64_t instead. This has various benefits, including that we can expose these values directly as D-Bus properties, and also that the values parse the same in all cases.
2015-09-09tree-wide: update empty-if coccinelle script to cover empty-while and moreLennart Poettering
Let's also clean up single-line while and for blocks.
2015-09-09tree-wide: don't do assignments within if checksLennart Poettering
Turn this: if ((r = foo()) < 0) { ... into this: r = foo(); if (r < 0) { ...
2015-09-07basic: rework virtualization detection APILennart Poettering
Introduce a proper enum, and don't pass around string ids anymore. This simplifies things quite a bit, and makes virtualization detection more similar to architecture detection.
2015-09-07tests: Skip test-cgroup-util test_mask_supported() when not running under ↵Martin Pitt
systemd Commit 5f4c5fef6 introduced this new test case, but this does not work in build chroots where cgroupfs is not mounted. So skip the test if systemd is not running.
2015-09-05Merge pull request #1140 from poettering/sd-event-signalsDavid Herrmann
A variety of sd-event, sd-login and cgroup fixes
2015-09-04tests: Skip tests which need to access /sys/fs/cgroup if that is not availableMartin Pitt
Commit efdb023 ("core: unified cgroup hierarchy support") introduced a new error ENOEXEC in cg_unified() if /sys/fs/cgroup/ is not available. Adjust the "skip" checks in various tests accordingly. Add a corresponding "skip" check to test-bus-creds as well, as sd_bus_creds_new_from_pid() now calls cg_unified() as well. This re-fixes "make check" in build chroots without /sys/fs/cgroup. https://github.com/systemd/systemd/issues/1132
2015-09-04test: add one more test case for parse_pid()Lennart Poettering
2015-09-04cgroup: always read the supported controllers from the root cgroup of the ↵Lennart Poettering
local container Otherwise we might end up thinking that we support more controllers than actually enabled for the container we are running in.
2015-09-04util: document why parse_uid() returns ENXIOLennart Poettering
parse_uid() returns EINVAL for invalid strings, but ENXIO for the (uid_t) -1 user ids in order to distinguish these two cases. Document this.
2015-09-01core: unified cgroup hierarchy supportLennart Poettering
This patch set adds full support the new unified cgroup hierarchy logic of modern kernels. A new kernel command line option "systemd.unified_cgroup_hierarchy=1" is added. If specified the unified hierarchy is mounted to /sys/fs/cgroup instead of a tmpfs. No further hierarchies are mounted. The kernel command line option defaults to off. We can turn it on by default as soon as the kernel's APIs regarding this are stabilized (but even then downstream distros might want to turn this off, as this will break any tools that access cgroupfs directly). It is possibly to choose for each boot individually whether the unified or the legacy hierarchy is used. nspawn will by default provide the legacy hierarchy to containers if the host is using it, and the unified otherwise. However it is possible to run containers with the unified hierarchy on a legacy host and vice versa, by setting the $UNIFIED_CGROUP_HIERARCHY environment variable for nspawn to 1 or 0, respectively. The unified hierarchy provides reliable cgroup empty notifications for the first time, via inotify. To make use of this we maintain one manager-wide inotify fd, and each cgroup to it. This patch also removes cg_delete() which is unused now. On kernel 4.2 only the "memory" controller is compatible with the unified hierarchy, hence that's the only controller systemd exposes when booted in unified heirarchy mode. This introduces a new enum for enumerating supported controllers, plus a related enum for the mask bits mapping to it. The core is changed to make use of this everywhere. This moves PID 1 into a new "init.scope" implicit scope unit in the root slice. This is necessary since on the unified hierarchy cgroups may either contain subgroups or processes but not both. PID 1 hence has to move out of the root cgroup (strictly speaking the root cgroup is the only one where processes and subgroups are still allowed, but in order to support containers nicey, we move PID 1 into the new scope in all cases.) This new unit is also used on legacy hierarchy setups. It's actually pretty useful on all systems, as it can then be used to filter journal messages coming from PID 1, and so on. The root slice ("-.slice") is now implicitly created and started (and does not require a unit file on disk anymore), since that's where "init.scope" is located and the slice needs to be started before the scope can. To check whether we are in unified or legacy hierarchy mode we use statfs() on /sys/fs/cgroup. If the .f_type field reports tmpfs we are in legacy mode, if it reports cgroupfs we are in unified mode. This patch set carefuly makes sure that cgls and cgtop continue to work as desired. When invoking nspawn as a service it will implicitly create two subcgroups in the cgroup it is using, one to move the nspawn process into, the other to move the actual container processes into. This is done because of the requirement that cgroups may either contain processes or other subgroups.
2015-09-01cgroup: drop "ignore_self" argument from cg_is_empty()Lennart Poettering
In all cases where the function (or cg_is_empty_recursive()) ignoring the calling process is actually wrong, as a process keeps a cgroup busy regardless if its the current one or another. Hence, let's simplify things and drop the "ignore_self" parameter.
2015-08-25test-util: fix a memleakThomas Hindoe Paaboel Andersen
2015-08-21dns-domain: add call for concatenating two domain namesLennart Poettering
This is specifically useful for appending the mDNS ".local" suffix to a single-label hostname in the most correct way. (used in later commit)
2015-08-07strv: Add strv_shell_escapeRichard Maw
This modifies the strv in-place, replacing strings with their escaped version. It's mostly just a convenience function for when you need to join a strv together because it's passed as a string to something, and the separator needs escaping.
2015-08-07util: Add shell_escapeRichard Maw
This is for shell-style \ escaping rather than quoting, which while it has the same effect in produced shell commands, is not exclusively useful for shell commands. shell_escape would be useful for producing sed commands, as you would be able to \ escape the normal special characters, plus whichever argument separator was chosen; or it could be used to escape arguments passed to the overlayfs mount command.
2015-08-07strv: convert strv_split_quotes into a generic strv_split_extractRichard Maw
strv_split_extract is to strv_split_quotes as extract_first_word was to unquote_first_word. Now there's extract_first_word for extracting a single argument, extract_many_words for extracting a bounded number of arguments, and strv_split_extract for extracting an arbitrary number of arguments.
2015-08-07util: Allow non-separator coalescing parsing in extract_first_wordRichard Maw
If EXTRACT_DONT_COALESCE_SEPARATORS is passed, then leading separators, trailing separators and spans of multiple separators aren't skipped, and empty arguments from before, after or between separators may be extracted.
2015-08-07util: Don't interpret quotes by default in extract_first_wordRichard Maw
This adds an EXTRACT_QUOTES option to allow the previous behaviour, of not interpreting any character inside ' or " quotes as separators.
2015-08-07util: change unquote_*_word to extract_*_wordRichard Maw
It now takes a separators argument, which defaults to WHITESPACE if NULL is passed.
2015-08-07Convert unquote_*_word users to expect isempty(p) after the last entryRichard Maw
This is so that, when called in a loop, unquote_first_word can distinguish between reaching the end of a string because it has consumed all the input before the end, and consuming all the input. This is important because we later add a flag that allows char *in = ""; char *out; unquote_first_word(&in, &out, flags); To put "" in out, and set in = NULL, so the trailing empty string of the input can be consumed, and mark that the input has been consumed.
2015-08-05Merge branch 'hostnamectl-dot-v2'Zbigniew Jędrzejewski-Szmek
Manual merge of https://github.com/systemd/systemd/pull/751.
2015-08-05hostname-util: get rid of unused parameter of hostname_cleanup()Zbigniew Jędrzejewski-Szmek
All users are now setting lowercase=false.
2015-08-05hostname-util: add relax parameter to hostname_is_validZbigniew Jędrzejewski-Szmek
Tests are modified to check behaviour with relax and without relax. New tests are added for hostname_cleanup(). Tests are moved a new file (test-hostname-util) because there's now a bunch of them. New parameter is not used anywhere, except in tests, so there should be no observable change.
2015-08-06tree-wide: fix indentationThomas Hindoe Paaboel Andersen
2015-08-04basic: add LIST_INSERT_BEFOREAlex Crawford
Similar in function to LIST_INSERT_AFTER, this will insert a new element into the list before the specified position. If the specified position is NULL, the element is added as the tail of the list.
2015-07-31Merge pull request #812 from zonque/testDavid Herrmann
Add some more tests
2015-07-31Merge pull request #814 from dvdhrm/mfreeDaniel Mack
tree-wide: introduce mfree()
2015-07-31test-socket-util: add test for in_addr_is_null()Daniel Mack
2015-07-31test-util: add more testsDaniel Mack
Add tests for safe_ato[iu]16() and some more unbase32hexmem() torture.
2015-07-31test: add test for static listsDaniel Mack
Test af-list and arphdr-list.
2015-07-31tree-wide: introduce mfree()David Herrmann
Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
2015-07-31Merge pull request #811 from namhyung/busctl-misc-v2Daniel Mack
busctl: Misc cleanups and a fix (v2)
2015-08-01busctl: add and use strcmp_ptr()Namhyung Kim
In member_compare_func(), it compares interface, type and name of members. But as it can contain NULL pointer, it needs to check them before calling strcmp(). So make it as a separate strcmp_ptr function (named after streq_ptr) so that it can be used by others. Also let streq_ptr() to use it in order to make the code simpler.
2015-07-31bitmap: make bitmap_clear free the bitmap arrayMartin Mikkelsen
Given two bitmaps and the following code: Bitmap *a = bitmap_new(), *b = bitmap_new(); bitmap_set(a, 1); bitmap_clear(a); bitmap_set(a, 0); bitmap_set(b, 0); These two bitmaps should now have the same bits set and they should be equal but bitmap_equal() will return false in this case because while bitmap_clear() resets the number of elements in the array it does not clear the array and bitmap_set() expects the array to be cleared. GREEDY_REALLOC0 looks at the allocated size and not the actual size so it does not clear any memory. Fix this by freeing the allocated memory and resetting the whole Bitmap to an initial state in bitmap_clear(). This also adds test code for this issue.
2015-07-31bitmap: fix bitmap_equal on bitmaps with unset bitsMartin Mikkelsen
Given two bitmaps and the following code: Bitmap *a = bitmap_new(), *b = bitmap_new(); bitmap_set(a, 0); bitmap_unset(a, 0); These two bitmaps should now have the same bits set and they should be equal but bitmap_equal() will return false in this case because the bitmaps array in a is larger because of the bit which was previously set. Fix this by comparing only the bits which exists in both bitmaps and then check that the rest of the bits (if any) is all zero. This also adds test code for this issue.
2015-07-29resolved: never attempt to resolve loopback addresses via DNS/LLMNR/mDNSLennart Poettering
We already refuse to resolve "localhost", hence we should also refuse resolving "127.0.0.1" and friends.
2015-07-28shared: dns-name - add dns_name_between()Tom Gundersen
Given three DNS names this function indicates if the second argument lies strictly between the first and the third according to the canonical DNS name order. Note that the order is circular, so the last name is considered to be before the first.
2015-07-28shared: dns-name - introduce dns_label_unescape_suffix()Tom Gundersen
Intended to be called repeatedly, and returns then successive unescaped labels from the most to the least significant (left to right). This is slightly inefficient as it scans the string three times (two would be sufficient): once to find the end of the string, once to find the beginning of each label and lastly once to do the actual unescaping. The latter two could be done in one go, but that seemed unnecessarily convoluted.