summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2014-11-05shared: unaligned - use void* instead of unaligned be16_t*Tom Gundersen
2014-11-05test: hashmap-plain - make coverity happyTom Gundersen
Check return value of hashmap_ensure_allocated(). CID#1250807.
2014-11-05test: fileio - make coverity happyTom Gundersen
Explicitly check the length of the read. Fixes CID#1250803.
2014-11-04test: use assert_se in test_hashmap_moveMichal Schmidt
2014-11-01shared: add helpers for unaligend BE read/writeTom Gundersen
2014-10-31Make bus errno mappings non-staticZbigniew Jędrzejewski-Szmek
__attribute__((used)) is not enough to force static variables to be carried over to a compiled program from a library. Mappings defined in libsystemd-shared.a were not visible in the compiled binaries. To ensure that the mappings are present in the final binary, the tables are made non-static and are given a real unique name by which they can be referenced. To use a mapping defined not in the local compilation unit (e.g. in a library) a reference to the mapping table is added. This is done by including a declaration in the header file. Expected values in test-engine are fixed to reflect the new mappings.
2014-10-31tests: add test-copyRonny Chevalier
2014-10-31tests: add tests for path_startswithRonny Chevalier
2014-10-31tests: add missing entry for LocalVariable to test-tablesRonny Chevalier
2014-10-31tests: add test-locale-utilRonny Chevalier
2014-10-31tests: add tests for strv.cRonny Chevalier
add tests for: - strv_find_startswith - strv_push_prepend - strv_consume_prepend
2014-10-31tests: add tests for fileio.cRonny Chevalier
add tests for the following functions: - write_string_file_no_create - load_env_file_pairs
2014-10-30test: test a corner case in hashmap_remove_and_replace()Michal Schmidt
2014-10-30test: adjust max load factor in test_hashmap_many()Michal Schmidt
A reimplementation of hashmaps will follow and it will use 0.8.
2014-10-27calendarspec: parse 'quarterly' and 'semi-annually' as shortcutsLennart Poettering
2014-10-23hashmap: allow hashmap_move() to failMichal Schmidt
It cannot fail in the current hashmap implementation, but it may fail in alternative implementations (unless a sufficiently large reservation has been placed beforehand).
2014-10-23test: add test for hashmap_reserve()Michal Schmidt
2014-10-23test: add and improve hashmap testsMichal Schmidt
Test more corner cases and error states in several tests. Add new tests for: hashmap_move hashmap_remove hashmap_remove2 hashmap_remove_value hashmap_remove_and_replace hashmap_get2 hashmap_first In test_hashmap_many additionally test with an intentionally bad hash function.
2014-10-23test: generate tests for OrderedHashmap from Hashmap testsMichal Schmidt
test-hashmap-ordered.c is generated from test-hashmap-plain.c simply by substituting "ordered_hashmap" for "hashmap" etc. In the cases where tests rely on the order of entries, a distinction between plain and ordered hashmaps is made using the ORDERED macro, which is defined only for test-hashmap-ordered.c.
2014-10-23mac: rename apis with mac_{selinux/smack}_ prefixWaLyong Cho
2014-10-17environment: append unit_id to error messages regarding EnvironmentFileLukas Nykryn
2014-10-12tests: fix some tests to pass in kojiZbigniew Jędrzejewski-Szmek
FAIL: test-engine ================= Cannot find cgroup mount point: No such file or directory Assertion 'r >= 0' failed at ../src/test/test-engine.c:46, function main(). Aborting. FAIL: test-sched-prio ===================== Cannot find cgroup mount point: No such file or directory Assertion 'r >= 0' failed at ../src/test/test-sched-prio.c:42, function main(). Aborting. FAIL: test-bus-cleanup ====================== Assertion 'sd_bus_open_system(&bus) >= 0' failed at ../src/libsystemd/sd-bus/test-bus-cleanup.c:40, function test_bus_open(). Aborting. after new: refcount 1
2014-10-04test: only use assert_seThomas Hindoe Paaboel Andersen
The asserts used in the tests should never be allowed to be optimized away
2014-10-03test-barrier: add checks after the barrier constructorThomas Hindoe Paaboel Andersen
Coverity seems to think that we can later end up with the "them" fd having a negative value. Even after a succesful barrier_create. Add some test to verify that the constructor went well. If coverity still complains then it must mean that it thinks the the value is overwritten later.
2014-10-01tests: add tests for {hashmap,set}_steal_firstZbigniew Jędrzejewski-Szmek
Just to make sure that coverity is wrong.
2014-09-30test-fileio: Remove dead checkThomas Hindoe Paaboel Andersen
t cannot be null here
2014-09-30test-date: don't fail test if log_max_level is higher than LOG_INFOThomas Hindoe Paaboel Andersen
2014-09-30test-path-util: fix a mem leak and avoid confusing coverityThomas Hindoe Paaboel Andersen
Found with coverity. Fixes CID#1237754 and #1237790
2014-09-29Do not format USEC_INFINITY as NULLZbigniew Jędrzejewski-Szmek
systemctl would print 'CPUQuotaPerSecUSec=(null)' for no limit. This does not look right. Since USEC_INFINITY is one of the valid values, format_timespan() could return NULL, and we should wrap every use of it in strna() or similar. But most callers didn't do that, and it seems more robust to return a string ("infinity") that makes sense most of the time, even if in some places the result will not be grammatically correct.
2014-09-22util: add alloca_align()David Herrmann
The alloca_align() helper is the alloca() equivalent of posix_memalign(). As there is no such function provided by glibc, we simply account for additional memory and return a pointer offset into the allocated memory to grant the alignment. Furthermore, alloca0_align() is added, which simply clears the allocated memory.
2014-09-22test-util: make valgrind happyDavid Herrmann
Properly free all temporary resources to make valgrind not complain about lost records.
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