summaryrefslogtreecommitdiff
path: root/src/test
Commit message (Collapse)AuthorAgeFilesLines
* basic: bitmap - complete fix for bitshift overflowTom Gundersen2015-07-171-0/+8
| | | | | The bug found by David existed in several places, fix them all. Also extend the tests to cover these cases.
* bitmap: use external iteratorTom Gundersen2015-07-161-2/+3
| | | | | | | | | | | | | | | | | | | | | | Reuse the Iterator object from hashmap.h and expose a similar API. This allows us to do { Iterator i; unsigned n; BITMAP_FOREACH(n, b, i) { Iterator j; unsigned m; BITMAP_FOREACH(m, b, j) { ... } } } without getting confused. Requested by David.
* basic: util - add base32hexmem() function similar to hexmem()Tom Gundersen2015-07-141-0/+175
| | | | This implements more of RFC4648.
* basic: add a Bitmap implementationTom Gundersen2015-07-141-0/+96
| | | | For when a Hashmap is overkill.
* basic: util - add base64mem() function similar to hexmem()Tom Gundersen2015-07-121-0/+100
| | | | | This implements RFC4648 for a slightly more compact representation of binary data compared to hex (6 bits per character rather than 4).
* basic: util - fix errorhandling in unhexmem()Tom Gundersen2015-07-121-0/+25
| | | | | | | | | | | | | | We were ignoring failures from unhexchar, which meant that invalid hex characters were being turned into garbage rather than the string rejected. Fix this by making unhexmem return an error code, also change the API slightly, to return the size of the returned memory, reflecting the fact that the memory is a binary blob,and not a string. For convenience, still append a trailing NULL byte to the returned memory (not included in the returned size), allowing callers to treat it as a string without doing a second copy.
* Merge pull request #500 from zonque/fileioLennart Poettering2015-07-084-21/+31
|\ | | | | fileio: consolidate write_string_file*()
| * fileio: consolidate write_string_file*()Daniel Mack2015-07-064-19/+19
| | | | | | | | | | | | | | Merge write_string_file(), write_string_file_no_create() and write_string_file_atomic() into write_string_file() and provide a flags mask that allows combinations of atomic writing, newline appending and automatic file creation. Change all users accordingly.
| * fileio: add 'enforce_newline' argument to write_string_stream()Daniel Mack2015-07-061-2/+12
| | | | | | | | | | Add a flag to control whether write_string_stream() should always enforce a trailing newline character in the file.
* | treewide: fix typos of let'sZbigniew Jędrzejewski-Szmek2015-07-061-1/+1
|/
* test: fix test-copy without /etc/os-release.Dimitri John Ledkov2015-06-231-1/+3
|
* Merge pull request #289 from michich/hashmap-small-cleanupLennart Poettering2015-06-181-32/+11
|\ | | | | a tiny hashmap cleanup
| * hashmap: allow NULL key in ordered_hashmap_next()Michal Schmidt2015-06-171-32/+11
| | | | | | | | | | | | 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.
* | test: disable test-barrier by defaultDavid Herrmann2015-06-181-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | load-fragment: reset the list on an ExecStart= containing only whitespaceFilipe Brandenburger2015-06-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | load-fragment: use unquote_first_word in config_parse_execFilipe Brandenburger2015-06-171-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | tests: additional cases in test-unit-fileFilipe Brandenburger2015-06-171-2/+68
| | | | | | | | | | | | | | | | | | | | 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.
* | util: Introduce unquote_first_word_and_warnFilipe Brandenburger2015-06-171-0/+145
| | | | | | | | | | | | | | | | | | 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.
* | util: New flag UNQUOTE_UNESCAPE_RELAX for unquote_first_wordFilipe Brandenburger2015-06-171-0/+94
|/ | | | | | | | | | | | | | | | 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
* Merge pull request #176 from filbranden/test_cgroup_mask1Lennart Poettering2015-06-171-5/+5
|\ | | | | test-cgroup-mask: unit_get_sibling_mask ignores cgroup_supported
| * test-cgroup-mask: unit_get_sibling_mask ignores cgroup_supportedFilipe Brandenburger2015-06-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #197 from dvdhrm/hashmapMichal Schmidt2015-06-161-0/+1
|\ \ | | | | | | hashmap: fix iterators to not skip entries
| * | hashmap: fix iterators to not skip entriesDavid Herrmann2015-06-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #214 from poettering/signal-rework-2Lennart Poettering2015-06-152-2/+2
|\ \ \ | | | | | | | | everywhere: port everything to sigprocmask_many() and friends
| * | | everywhere: port everything to sigprocmask_many() and friendsLennart Poettering2015-06-152-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | util: when creating temporary file names, allow including extra id string in itLennart Poettering2015-06-151-0/+37
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | firewall: rename fw-util.[ch] → firewall-util.[ch]Daniel Mack2015-06-151-1/+1
| | | | | | | | | | | | | | | The names fw-util.[ch] are too ambiguous, better rename the files to firewall-util.[ch]. Also rename the test accordingly.
* | | test-netlink-manual: typo fixThomas Hindoe Paaboel Andersen2015-06-141-1/+1
|/ / | | | | | | No functional change, but looked weird.
* | sd-netlink: rename from sd-rtnlTom Gundersen2015-06-131-27/+27
|/
* sd-rtnl: make joining broadcast groups implicitTom Gundersen2015-06-111-1/+1
|
* Merge pull request #6 from xnox/drop-nameLennart Poettering2015-06-111-10/+10
|\ | | | | shared: Drop 'name=' prefix from SYSTEMD_CGROUP_CONTROLLER define.
| * shared: Drop 'name=' prefix from SYSTEMD_CGROUP_CONTROLLER define.Dimitri John Ledkov2015-06-021-10/+10
| | | | | | | | | | | | | | | | | | | | | | 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.
* | resolve: move dns routines into sharedNick Owens2015-06-101-0/+192
| |
* | test-copy: test copy_bytes()Zbigniew Jędrzejewski-Szmek2015-06-101-0/+35
| |
* | path-util: Fix path_is_mount_point for parent mount points in symlink modeMartin Pitt2015-06-091-2/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | test-util: fix a memleakThomas Hindoe Paaboel Andersen2015-06-031-0/+2
| |
* | test-unit-file.c: fixup the test for commit 3b51f8ddd5Harald Hoyer2015-06-031-1/+1
| |
* | util: fix another cunescape() regressionDaniel Mack2015-06-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | udevd: simplify signal mask handlingTom Gundersen2015-06-031-9/+4
|/ | | | | | | | 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.
* test-unit-file: add test for improperly escaped exec stringDaniel Mack2015-06-011-0/+19
| | | | | | | | | 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
* test-fdset: add more testsRonny Chevalier2015-05-301-0/+53
| | | | | | | add tests for the following functions: - fdset_new_array - fdset_steal_first - fdset_isempty
* tests: add test-conf-parserRonny Chevalier2015-05-301-0/+234
|
* util: split out signal-util.[ch] from util.[ch]Lennart Poettering2015-05-292-0/+2
| | | | No functional changes.
* udevd: event - port spawn_wait() to sd-eventTom Gundersen2015-05-291-7/+0
| | | | | | | | | 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.
* path-util: Change path_is_mount_point() symlink arg from bool to flagsMartin Pitt2015-05-291-16/+16
| | | | | This makes path_is_mount_point() consistent with fd_is_mount_point() wrt. flags.
* path-util: Fix path_is_mount_point for filesMartin Pitt2015-05-291-13/+63
| | | | | | | | | | | | | | | | | | | | 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.
* test: hostname - test that hostname is truly initializedTom Gundersen2015-05-251-0/+7
| | | | Fixes CID CID 1299638 (use after free).
* json: minor style fixesv220Lennart Poettering2015-05-211-2/+3
|
* test.json: fix build on x86-32 where int and intmax_t differLennart Poettering2015-05-211-1/+1
|
* json: fix a mem leakThomas Hindoe Paaboel Andersen2015-05-191-3/+1
|