summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2015-01-22tests: use assert_se instead of assertRonny Chevalier
Otherwise they can be optimized away with -DNDEBUG
2015-01-22Assorted format fixesZbigniew Jędrzejewski-Szmek
Types used for pids and uids in various interfaces are unpredictable. Too bad.
2015-01-20util: make http url validity checks more generic, and move them to util.cLennart Poettering
2015-01-19import-raw: when downloading raw images, generate sparse files if we canLennart Poettering
2015-01-18Revert "test-exec: do not skip all the tests"David Herrmann
This reverts commit 68e68ca8106e7cd874682ae425843b48579c6539. We *need* root access to create cgroups. The only exception is if it is run from within a cgroup with "Delegate=yes". However, this is not always true and we really shouldn't rely on this. If your terminal runs from within a systemd --user instance, you're fine. Everyone else is not (like running from ssh, VTs, and so on..).
2015-01-17remove unneeded libgen.h includesCristian Rodríguez
2015-01-15test-path: do not skip tests if we are not rootRonny Chevalier
We can properly run the tests without being root
2015-01-15test-exec: do not skip all the testsRonny Chevalier
Only 5 tests cannot be executed if we are not root, so just skip them but not the whole set.
2015-01-14test: hashmap_put behaviour for equal keysMartin Pitt
Check string ops hashmap_put() for keys with a different pointer but the same value.
2015-01-13shared: add minimal firewall manipulation helpers for establishing NAT ↵Lennart Poettering
rules, using libiptc
2015-01-11fstab-util: fix priority parsing and add testZbigniew Jędrzejewski-Szmek
2015-01-11shared/util: respect buffer boundary on incomplete escape sequencesZbigniew Jędrzejewski-Szmek
cunescape_length_with_prefix() is called with the length as an argument, so it cannot rely on the buffer being NUL terminated. Move the length check before accessing the memory. When an incomplete escape sequence was given at the end of the buffer, c_l_w_p() would read past the end of the buffer. Fix this and add a test.
2015-01-11core/load-fragment: avoid allocating 0 bytes when given an invalid commandZbigniew Jędrzejewski-Szmek
With a command line like "@/something" we would allocate an array with 0 elements. Avoid that, and add a test too.
2015-01-11test-unit-file: don't access out-of-bounds memoryZbigniew Jędrzejewski-Szmek
Fixes an error introduced by me when the test was added.
2015-01-11Support negated fstab optionsZbigniew Jędrzejewski-Szmek
We would ignore options like "fail" and "auto", and for any option which takes a value the first assignment would win. Repeated and options equivalent to the default are rarely used, but they have been documented forever, and people might use them. Especially on the kernel command line it is easier to append a repeated or negated option at the end.
2015-01-11Add new function to filter fstab optionsZbigniew Jędrzejewski-Szmek
This fixes parsing of options in shared/generator.c. Existing code had some issues: - it would treate whitespace and semicolons as seperators. fstab(5) is pretty clear that only commas matter. And the syntax does not allow for spaces to be inserted in the field in fstab. Whitespace might be escaped, but then it should not seperate options. Treat whitespace and semicolons as any other character. - it assumed that x-systemd.device-timeout would always be followed by "=". But this is not guaranteed, hasmntopt will return this option even if there's no value. Uninitialized memory could be read. - some error paths would log, and inconsistently, some would just return an error code. Filtering is split out to a separate function and tests are added. Similar code paths in other places are adjusted to use the new function.
2015-01-11shared/list: add LIST_APPENDZbigniew Jędrzejewski-Szmek
2015-01-11test-path-lookup: add simple test for path lookup functionsZbigniew Jędrzejewski-Szmek
2015-01-11test-util: make sure that masking and overriding worksZbigniew Jędrzejewski-Szmek
2015-01-11Implement masking and overriding of generatorsZbigniew Jędrzejewski-Szmek
Sometimes it is necessary to stop a generator from running. Either because of a bug, or for testing, or some other reason. The only way to do that would be to rename or chmod the generator binary, which is inconvenient and does not survive upgrades. Allow masking and overriding generators similarly to units and other configuration files. For the systemd instance, masking would be more common, rather than overriding generators. For the user instances, it may also be useful for users to have generators in $XDG_CONFIG_HOME to augment or override system-wide generators. Directories are searched according to the usual scheme (/usr/lib, /usr/local/lib, /run, /etc), and files with the same name in higher priority directories override files with the same name in lower priority directories. Empty files and links to /dev/null mask a given name. https://bugs.freedesktop.org/show_bug.cgi?id=87230
2015-01-11Simplify execute_directory()Zbigniew Jędrzejewski-Szmek
Remove the optional sepearate opening of the directory, it would be just too complicated with the change to multiple directories. Move the middle of execute_directory() to a seperate function to make it easier to grok.
2015-01-09logind: unify how we cast between uid_t and pointers for hashmap keysLennart Poettering
2015-01-08machined: when cloning a raw disk image, also set the NOCOW flagLennart Poettering
2015-01-08test-verbs: add unit tests for verbs minilibDave Reisner
2015-01-07util: make use of kcmp() to compare fds, if it is availableLennart Poettering
2015-01-05journald: process SIGBUS for the memory maps we set upLennart Poettering
Even though we use fallocate() it appears that file systems like btrfs will trigger SIGBUS on certain low-disk-space situation. We should handle that, hence catch the signal, add it to a list of invalidated pages, and replace the page with an empty memory area. After each write check if SIGBUS was triggered, and consider the write invalid if it was. This should make journald a lot more robust with file systems where fallocate() is not reliable, for example all CoW file systems (btrfs...), where changing written data can fail with disk full errors. https://bugzilla.redhat.com/show_bug.cgi?id=1045810
2014-12-30tree-wide: spelling fixesVeres Lajos
https://github.com/vlajos/misspell_fixer https://github.com/torstehu/systemd/commit/b6fdeb618cf2f3ce1645b3315f15f482710c7ffa Thanks to Torstein Husebo <torstein@huseboe.net>.
2014-12-30macro: add DIV_ROUND_UP()David Herrmann
This macro calculates A / B but rounds up instead of down. We explicitly do *NOT* use: (A + B - 1) / A as it suffers from an integer overflow, even though the passed values are properly tested against overflow. Our test-cases show this behavior. Instead, we use: A / B + !!(A % B) Note that on "Real CPUs" this does *NOT* result in two divisions. Instead, instructions like idivl@x86 provide both, the quotient and the remainder. Therefore, both algorithms should perform equally well (I didn't verify this, though).
2014-12-29capability: use /proc/sys/kernel/cap_last_capDavid Herrmann
This file was introduced with linux-3.2, use it instead of probing for it via prctl(PR_CAPBSET_READ). For now, keep the old code for backwards compat. We can drop it once 3.2 is our lowest requirement. The test-cap-list code is extended to verify cap_last_cap() is the same as we'd get via prctl probing and /proc.
2014-12-29test: loopback - parse logging env varTom Gundersen
2014-12-28machined: add support for reporting image size via btrfs quotaLennart Poettering
2014-12-28tmpfiles: add new line type 'v' for creating btrfs subvolumesLennart Poettering
2014-12-26test: improve btrfs test caseLennart Poettering
2014-12-25test: wait for cloned thread to exitFilipe Brandenburger
In test_raw_clone, make sure the cloned thread calls _exit() and in the parent thread call waitpid(..., __WCLONE) to wait for the child thread to terminate, otherwise there is a race condition where the child thread will log to the console after the test process has already exited and the assertion from the child thread might not be enforced. The absence of this patch might also create problems for other tests that would be added after this one, since potentially both parent and child would run those tests as the child would continue running. Tested by confirming that the logs from the child are printed before the test terminates and that a false assertion in the child aborts the test with a core dump. [zj: also add check for the return value.]
2014-12-25test: only use assert_se in test_raw_cloneFilipe Brandenburger
The asserts used in the tests should never be allowed to be optimized away.
2014-12-25test: do not use last cap from kernel in test-cap-listFilipe Brandenburger
The new test-cap-list introduced in commit 2822da4fb7f891 uses the included table of capabilities. However, it uses cap_last_cap() which probes the kernel for the last available capability. On an older kernel (e.g. 3.10 from RHEL 7) that causes the test to fail with the following message: Assertion '!capability_to_name(cap_last_cap()+1)' failed at src/test/test-cap-list.c:30, function main(). Aborting. Fix it by exporting the size of the static table and using it in the test instead of the dynamic one from the current kernel. Tested by successfully running ./test-cap-list and the whole `make check` test suite with this patch on a RHEL 7 host.
2014-12-25machined: beef up machined image listing with creation/modification times of ↵Lennart Poettering
subvolumes We make use of the btrfs subvol crtime for this, and for gpt images of a manually managed xattr, if we can.
2014-12-23env-util: don't include files from src/core/Lennart Poettering
2014-12-23core: rearrange code so that libsystemd/sd-bus/ does not include header ↵Lennart Poettering
files from core Stuff in src/shared or src/libsystemd should *never* include code from src/core or any of the tools, so don't do that here either. It's not OK!
2014-12-22shared: json - support escaping utf16 surrogate pairsTom Gundersen
We originally only supported escaping ucs2 encoded characters (as \uxxxx). This only covers the BMP. Support escaping also utf16 surrogate pairs (on the form \uxxxx\uyyyy) to cover all of unicode.
2014-12-22shared: utf8 - support decoding the full utf16Tom Gundersen
We originally only supported the BMP (i.e., we treated UTF-16 as UCS-2).
2014-12-22shared: utf8 - support ucs4 -> utf8Tom Gundersen
Originally we only supported ucs2, so move the ucs4 version from libsystemd-terminal to shared and use that everywhere.
2014-12-19strv: ass new strv_is_uniq() and strv_reverse() callsLennart Poettering
2014-12-18load-fragment: allow quoting in command name and document allowed escapesZbigniew Jędrzejewski-Szmek
The handling of the command name and other arguments is unified. This simplifies things and should make them more predictable for users. Incidentally, this makes ExecStart handling match the .desktop file specification, apart for the requirment for an absolute path. https://bugs.freedesktop.org/show_bug.cgi?id=86171
2014-12-18Treat a trailing backslash as an errorZbigniew Jędrzejewski-Szmek
Commit a2a5291b3f5 changed the parser to reject unfinished quoted strings. Unfortunately it introduced an error where a trailing backslash would case an infinite loop. Of course this must fixed, but the question is what to to instead. Allowing trailing backslashes and treating them as normal characters would be one option, but this seems suboptimal. First, there would be inconsistency between handling of quoting and of backslashes. Second, a trailing backslash is most likely an error, at it seems better to point it out to the user than to try to continue. Updated rules: ExecStart=/bin/echo \\ → OK, prints a backslash ExecStart=/bin/echo \ → error ExecStart=/bin/echo "x → error ExecStart=/bin/echo "x"y → error
2014-12-18test-strv: use STRV_MAKEZbigniew Jędrzejewski-Szmek
2014-12-18test-cap-list: allow mismatch in caseZbigniew Jędrzejewski-Szmek
2014-12-18core: use raw_clone instead of fork in signal handlerZbigniew Jędrzejewski-Szmek
fork() is not async-signal-safe and calling it from the signal handler could result in a deadlock when at_fork() handlers are called. Using the raw clone() syscall sidesteps that problem. The tricky part is that raise() does not work, since getpid() does not work. Add raw_getpid() to get the real pid, and use kill() instead of raise(). https://bugs.freedesktop.org/show_bug.cgi?id=86604
2014-12-18test-unit-file: add test for semicolon escapingZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=87393
2014-12-16test-json: use fabsThomas Hindoe Paaboel Andersen