summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2014-09-18tests: fix resource & mem leaksRonny Chevalier
2014-09-16test: silence a coverity reportThomas Hindoe Paaboel Andersen
We check the actual contents of the file on the line after but we might as well also check the number of bytes read here. Found by coverity. Fixes: CID#1237521
2014-09-16libudev: util - drop util_delete_path()Tom Gundersen
Use rmdir_parents() from src/shared instead.
2014-09-15hashmap, set: remove unused functionsMichal Schmidt
The following hashmap_* and set_* functions/macros have never had any users in systemd's history: *_iterate_backwards *_iterate_skip *_last *_FOREACH_BACKWARDS Remove this dead code.
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
2014-09-14test: fix test of uid-rangeThomas Hindoe Paaboel Andersen
The number of uid's in the range should be tested instead of written directly. The test still passes with the fix checks. Found with Coverity. Fixes: CID#1237714 - 1237722
2014-09-11udev: timeout - warn after a third of the timeout before killingTom Gundersen
2014-09-11test: fix mem-leak in fdopen() testDavid Herrmann
We must free FILE* after function return to not leak resources. Note that this also closes our fd as fdopen() takes ownership of it. Reported by Philippe De Swert (via coverity).
2014-09-08namespace: add support for custom kdbus endpointDaniel Mack
If a path to a previously created custom kdbus endpoint is passed in, bind-mount a new devtmpfs that contains a 'bus' node, which in turn in bind-mounted with the custom endpoint. This tmpfs then mounted over the kdbus subtree that refers to the current bus. This way, we can fake the bus node in order to lock down services with a kdbus custom endpoint policy.
2014-09-08bus: factor out bus policy itemsDaniel Mack
In order to re-use the policy definitions, factor them out into their own files.
2014-08-30cgroup-util: shorten cg_path_get_sessionZbigniew Jędrzejewski-Szmek
2014-08-28macro: use unique variable names for math-macrosDavid Herrmann
Similar to container_of(), we now use unique variable names for the bascic math macros MAX, MIN, CLAMP, LESS_BY. Furthermore, unit tests are added to verify they work as expected. For a rationale, see: commit fb835651aff79a1e7fc5795086c9b26e59a8e6ca Author: David Herrmann <dh.herrmann@gmail.com> Date: Fri Aug 22 14:41:37 2014 +0200 shared: make container_of() use unique variable names
2014-08-27shared: make container_of() use unique variable namesDavid Herrmann
If you stack container_of() macros, you will get warnings due to shadowing variables of the parent context. To avoid this, use unique names for variables. Two new helpers are added: UNIQ: This evaluates to a truly unique value never returned by any evaluation of this macro. It's a shortcut for __COUNTER__. UNIQ_T: Takes two arguments and concatenates them. It is a shortcut for CONCATENATE, but meant to defined typed local variables. As you usually want to use variables that you just defined, you need to reference the same unique value at least two times. However, UNIQ returns a new value on each evaluation, therefore, you have to pass the unique values into the macro like this: #define my_macro(a, b) __max_macro(UNIQ, UNIQ, (a), (b)) #define __my_macro(uniqa, uniqb, a, b) ({ typeof(a) UNIQ_T(A, uniqa) = (a); typeof(b) UNIQ_T(B, uniqb) = (b); MY_UNSAFE_MACRO(UNIQ_T(A, uniqa), UNIQ_T(B, uniqb)); }) This way, MY_UNSAFE_MACRO() can safely evaluate it's arguments multiple times as they are local variables. But you can also stack invocations to the macro my_macro() without clashing names. This is the same as if you did: #define my_macro(a, b) __max_macro(__COUNTER__, __COUNTER__, (a), (b)) #define __my_macro(prefixa, prefixb, a, b) ({ typeof(a) CONCATENATE(A, prefixa) = (a); typeof(b) CONCATENATE(B, prefixb) = (b); MY_UNSAFE_MACRO(CONCATENATE(A, prefixa), CONCATENATE(B, prefixb)); }) ...but in my opinion, the first macro is easier to write and read. This patch starts by converting container_of() to use this new helper. Other macros may follow (like MIN, MAX, CLAMP, ...).
2014-08-26test-util: use assert_se() for call to safe_mkdir with side effectFilipe Brandenburger
Otherwise it gets optimized out when CPPFLAGS='-DNDEBUG' is used. Tested: - make check TESTS='test-util' CPPFLAGS='-DNDEBUG'
2014-08-26test-path-util: use assert_se in all assertionsFilipe Brandenburger
Otherwise they get optimized out when CPPFLAGS='-DNDEBUG' is used, and that causes the tests to fail. Tested: - make check TESTS='test-path-util' CPPFLAGS='-DNDEBUG'
2014-08-22core: add support for a configurable system-wide start-up timeoutLennart Poettering
When this system-wide start-up timeout is hit we execute one of the failure actions already implemented for services that fail. This should not only be useful on embedded devices, but also on laptops which have the power-button reachable when the lid is closed. This devices, when in a backpack might get powered on by accident due to the easily reachable power button. We want to make sure that the system turns itself off if it starts up due this after a while. When the system manages to fully start-up logind will suspend the machine by default if the lid is closed. However, in some cases we don't even get as far as logind, and the boot hangs much earlier, for example because we ask for a LUKS password that nobody ever enters. Yeah, this is a real-life problem on my Yoga 13, which has one of those easily accessible power buttons, even if the device is closed.
2014-08-22shared: add MAXSIZE() and use it in resolvedDavid Herrmann
The MAXSIZE() macro takes two types and returns the size of the larger one. It is much simpler to use than MAX(sizeof(A), sizeof(B)) and also avoids any compiler-extensions, unlike CONST_MAX() and MAX() (which are needed to avoid evaluating arguments more than once). This was suggested by Daniele Nicolodi <daniele@grinta.net>. Also make resolved use this macro instead of CONST_MAX(). This enhances readability quite a bit.
2014-08-21core: allow informing systemd about service status changes with RELOADING=1 ↵Lennart Poettering
and STOPPING=1 sd_notify() messages
2014-08-20CONST_MAX breaks gcc on fedora 20 with optimiztationsystemd/v216Lennart Poettering
2014-08-19tmpfiles: add new 'r' line type to add UIDs/GIDs to the pool to allocate ↵Lennart Poettering
UIDs/GIDs from This way we can guarantee a limited amount of compatibility with login.defs, by generate an appopriate "r" line out of it, on package installation.
2014-08-19sysusers: add another column to sysusers files for the home directoryLennart Poettering
2014-08-18tests: add missing entry to test-tablesRonny Chevalier
2014-08-18tests: add tests for time-util.cRonny Chevalier
add tests for: - timezone_is_valid - get_timezones
2014-08-18tests: add test-condition-utilRonny Chevalier
2014-08-18tests: add tests for util.cRonny Chevalier
add tests for: - is_symlink - pid_is_unwaited - pid_is_alive - search_and_fopen - search_and_fopen_nulstr - glob_exists - execute_directory
2014-08-18tests: add test for fdset_iterateRonny Chevalier
2014-08-18tests: add tests for fileio.cRonny Chevalier
add tests for: - write_string_stream - write_string_file - sendfile_full
2014-08-18tests: add missing unlinkRonny Chevalier
2014-08-18tests: add tests for socket-util.cRonny Chevalier
add tests for: - socket_address_is - socket_address_is_netlink - sockaddr_equal
2014-08-15macro: add CONST_MAX() macroDavid Herrmann
The CONST_MAX() macro is similar to MAX(), but verifies that both arguments have the same type and are constant expressions. Furthermore, the result of CONST_MAX() is again a constant-expression. CONST_MAX() avoids any statement-expressions and other non-trivial expression-types. This avoids rather arbitrary restrictions in both GCC and LLVM, which both either fail with statement-expressions inside type-declarations or statement-expressions inside static-const initializations. If anybody knows how to circumvent this, please feel free to unify CONST_MAX() and MAX().
2014-08-15test: fix strtod test for realDavid Herrmann
The "0,5" syntax was actually right. The real problem is, the test should only run if the local system has the de_DE.UTF-8 locale. Therefore, skip the tests if setlocale() fails. This is kinda ugly, as it is done silently, but we cannot skip partial tests with the current infrastructure. Should be fine this way.
2014-08-15test: fix strtod() testDavid Herrmann
One strtod() test is broken since: commit 8e211000025940b770794abf5754de61b4add0af Author: Thomas Hindoe Paaboel Andersen <phomes@gmail.com> Date: Mon Aug 4 23:13:31 2014 +0200 test: use fabs on doubles The commit was right, so no reason to revert it, but the test was broken before and only worked by coincidence. Convert "0,5" to "0.5" so we don't depend on locales for double conversion (or well, we depend on "C" which seems reasonable).
2014-08-13util: allow strappenda to take any number of argsDave Reisner
This makes strappenda3 redundant, so we remove its usage and definition. Add a few tests along the way for sanity.
2014-08-11udev: never bypass our own logging framework and call vsyslog() directly ↵Lennart Poettering
from udev tools
2014-08-04test: use fabs on doublesThomas Hindoe Paaboel Andersen
2014-08-03Unify parse_argv styleZbigniew Jędrzejewski-Szmek
getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
2014-07-31Always prefer our headers to system headersZbigniew Jędrzejewski-Szmek
In practice this shouldn't make much difference, but sometimes our headers might be newer, and we want to test them.
2014-07-31Properly report invalid quoted stringsZbigniew Jędrzejewski-Szmek
$ systemd-analyze verify trailing-g.service [./trailing-g.service:2] Trailing garbage, ignoring. trailing-g.service lacks ExecStart setting. Refusing. Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument. Failed to create trailing-g.service/start: Invalid argument
2014-07-31Reject invalid quoted stringsZbigniew Jędrzejewski-Szmek
String which ended in an unfinished quote were accepted, potentially with bad memory accesses. Reject anything which ends in a unfished quote, or contains non-whitespace characters right after the closing quote. _FOREACH_WORD now returns the invalid character in *state. But this return value is not checked anywhere yet. Also, make 'word' and 'state' variables const pointers, and rename 'w' to 'word' in various places. Things are easier to read if the same name is used consistently. mbiebl_> am I correct that something like this doesn't work mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"' mbiebl_> systemd seems to strip of the quotes mbiebl_> systemctl status shows mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS $RootDir $MountPoint mbiebl_> which is pretty weird
2014-07-31test-strv: add test which shows access to random memoryZbigniew Jędrzejewski-Szmek
2014-07-29barrier: fix race in test-codeDavid Herrmann
The barrier_wait_next_twice* test-cases run: Parent: Child: set_alarm(10) sleep_for(1); ... set_alarm(1); sleep_for(2) ... Therefore, the parent exits after 2+ periods, the client's alarm fires after 2+ periods. This race turns out to be lost by the child on other machines, so avoid it by increasing the parent's sleep-interval to 4. This way, the client has 2 periods to run the barrier test, which is far more than enough.
2014-07-29udev: unify event timeout handlingKay Sievers
2014-07-29barrier: convert msecs to usecs in test-codeDavid Herrmann
Avoid using msecs in favor of usec_t. This is more consistent with the other parts of systemd and avoids the confusion between msec and usec. We always use usecs, end of story.
2014-07-27parse_boolean: require exact matchesAnsgar Burchardt
Require exact matches in all cases instead of treating strings starting with 't' ('f') as true (false). This is required for config_parse_protect_system to parse ProtectSystem=full correctly: it uses parse_boolean and only tries a more specific parsing function if that did not return a valid result. Thus "full" was treated as "false" before.
2014-07-26Add utility function to append root to pathZbigniew Jędrzejewski-Szmek
2014-07-20test-cgroup-mask: fix masks in test and enable by defaultZbigniew Jędrzejewski-Szmek
Commit 637f421e5c6a ("cgroups: always propagate controller membership to siblings") changed the mask propagation logic, but the test wasn't updated. Move to normal tests from manual tests, it should not touch the system anymore.
2014-07-20test-cgroup-mask: pass on kernels without memory controllerZbigniew Jędrzejewski-Szmek
It seems that unit_get_siblings_mask returns the controllers filtered by what is available, but get_members_mask and get_cgroup_mask do not. This just fixes the test following the symptoms.
2014-07-20test-engine: fix access to unit load pathZbigniew Jędrzejewski-Szmek
Also add a bit of debugging output to help diagnose problems, add missing units, and simplify cppflags. Move test-engine to normal tests from manual tests, it should now work without destroying the system.
2014-07-19core: remove systemd_running_as lookup functionsZbigniew Jędrzejewski-Szmek
They are unused and unlikely to ever be.
2014-07-18barrier: initalize file descriptors with -1Zbigniew Jędrzejewski-Szmek
Explicitly initalize descriptors using explicit assignment like bus_error. This makes barriers follow the same conventions as everything else and makes things a bit simpler too. Rename barier_init to barier_create so it is obvious that it is not about initialization. Remove some parens, etc.