summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
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.
2014-07-17test-pty: silence a warningThomas Hindoe Paaboel Andersen
2014-07-17shared: add PTY helperDavid Herrmann
This Pty API wraps the ugliness that is POSIX PTY. It takes care of: - edge-triggered HUP handling (avoid heavy CPU-usage on vhangup) - HUP vs. input-queue draining (handle HUP _after_ draining the whole input queue) - SIGCHLD vs. HUP (HUP is no reliable way to catch PTY deaths, always use SIGCHLD. Otherwise, vhangup() and friends will break.) - Output queue buffering (async EPOLLOUT handling) - synchronous setup (via Barrier API) At the same time, the PTY API does not execve(). It simply fork()s and leaves everything else to the caller. Usually, they execve() but we support other setups, too. This will be needed by multiple UI binaries (systemd-console, systemd-er, ...) so it's placed in src/shared/. It's not strictly related to libsystemd-terminal, so it's not included there.
2014-07-17shared: add generic IPC barrierDavid Herrmann
The "Barrier" object is a simple inter-process barrier implementation. It allows placing synchronization points and waiting for the other side to reach it. Additionally, it has an abortion-mechanism as second-layer synchronization to send abortion-events asynchronously to the other side. The API is usually used to synchronize processes during fork(). However, it can be extended to pass state through execve() so you could synchronize beyond execve(). Usually, it's used like this (error-handling replaced by assert() for simplicity): Barrier b; r = barrier_init(&b); assert_se(r >= 0); pid = fork(); assert_se(pid >= 0); if (pid == 0) { barrier_set_role(&b, BARRIER_CHILD); ...do child post-setup... if (CHILD_SETUP_FAILED) exit(1); ...child setup done... barrier_place(&b); if (!barrier_sync(&b)) { /* parent setup failed */ exit(1); } barrier_destroy(&b); /* redundant as execve() and exit() imply this */ /* parent & child setup successful */ execve(...); } barrier_set_role(&b, BARRIER_PARENT); ...do parent post-setup... if (PARENT_SETUP_FAILED) { barrier_abort(&b); /* send abortion event */ barrier_wait_abortion(&b); /* wait for child to abort (exit() implies abortion) */ barrier_destroy(&b); ...bail out... } ...parent setup done... barrier_place(&b); if (!barrier_sync(&b)) { ...child setup failed... ; barrier_destroy(&b); ...bail out... } barrier_destroy(&b); ...child setup successfull... This is the most basic API. Using barrier_place() to place barriers and barrier_sync() to perform a full synchronization between both processes. barrier_abort() places an abortion barrier which superceeds any other barriers, exit() (or barrier_destroy()) places an abortion-barrier that queues behind existing barriers (thus *not* replacing existing barriers unlike barrier_abort()). This example uses hard-synchronization with wait_abortion(), sync() and friends. These are all optional. Barriers are highly dynamic and can be used for one-way synchronization or even no synchronization at all (postponing it for later). The sync() call performs a full two-way synchronization. The API is documented and should be fairly self-explanatory. A test-suite shows some special semantics regarding abortion, wait_next() and exit(). Internally, barriers use two eventfds and a pipe. The pipe is used to detect exit()s of the remote side as eventfds do not allow that. The eventfds are used to place barriers, one for each side. Barriers itself are numbered, but the numbers are reused once both sides reached the same barrier, thus you cannot address barriers by the index. Moreover, the numbering is implicit and we only store a counter. This makes the implementation itself very lightweight, which is probably negligible considering that we need 3 FDs for a barrier.. Last but not least: This barrier implementation is quite heavy. It's definitely not meant for fast IPC synchronization. However, it's very easy to use. And given the *HUGE* overhead of fork(), the barrier-overhead should be negligible.
2014-07-16test-tables: add new entriesZbigniew Jędrzejewski-Szmek
One missing string found. A few things had to be moved around to make it possible to test them.
2014-07-16test-socket-util: silence warningsThomas Hindoe Paaboel Andersen
2014-07-15shared/socket-util: add function to query remote addressZbigniew Jędrzejewski-Szmek
2014-07-11shared: fix coding-style for ring-buffer implementationDavid Herrmann
We use "typedef struct Ring Ring" with camel-case for internal objects. So rename "struct ring" to "Ring".
2014-07-11util: fix has cc check and add testZbigniew Jędrzejewski-Szmek
2014-07-10shared: split out in_addr related calls from socket-util.[ch] into its ↵Lennart Poettering
private in-addr-util.[ch] These are enough calls for a new file, and they are sufficiently different from the sockaddr-related calls, hence let's split this out.
2014-07-03machinectl: show /etc/os-release information of container in status outputLennart Poettering
2014-07-03test: print library tuple in testLennart Poettering
2014-07-02util: when unescaping strings, don't allow smuggling in of additional NUL bytesLennart Poettering
Better safe than sorry.
2014-06-30tests: add missing XDG_RUNTIME_DIR env variableRonny Chevalier
Otherwise the test fails because specifier_runtime() returns -ENOTSUP when XDG_RUNTIME_DIR is not set.
2014-06-24tests: add test-ratelimitRonny Chevalier
2014-06-24tests: add tests to test-unit-nameRonny Chevalier
add tests for: - unit_instance_is_valid - unit_prefix_is_valid - unit_name_change_suffix - unit_name_build - unit_name_is_instance - build_subslice - unit_name_to_instance - unit_name_escape
2014-06-22consistently order cleanup attribute before typeThomas Hindoe Paaboel Andersen
2014-06-22tests: add test_fdset_removeRonny Chevalier
2014-06-22tests: add test-asyncRonny Chevalier
2014-06-22tests: add test-capabilityRonny Chevalier
2014-06-20test: ensure conf_files_list returns absolute pathsMichael Marineau
2014-06-20test: unit test for using alternate roots with path_strv_resolveMichael Marineau
2014-06-19tests: add tests for strv_extendfRonny Chevalier
2014-06-19tests: add tests to test-utilRonny Chevalier
add tests for: - filename_is_safe - ascii_strlower - files_same - is_valid_documentation_url - file_in_same_dir - endswith - close_nointr - unlink_noerrno - readlink_and_make_absolute - read_one_char - ignore_signals - strshorten
2014-06-19tests: add missing returnRonny Chevalier
2014-06-18networkd: add a number of calls to manipulate in_addr_union structsLennart Poettering
2014-06-17install: beef up preset logic to limit to only enable or only disable, and ↵Lennart Poettering
do all-unit preset operations The new "systemctl preset-all" command may now be used to put all installed units back into the enable/disable state the vendor/admin encoded in preset files. Also, introduce "systemctl --preset-mode=enable-only" and "systemctl --preset-mode=disable-only" to only apply the enable or only the disable operations of a "systemctl preset" or "systemctl preset-all" operation. "systemctl preset-all" implements this RFE: https://bugzilla.redhat.com/show_bug.cgi?id=630174
2014-06-16tests: unlink temp file used in testRonny Chevalier
2014-06-16tests: add tests to test-hashmapRonny Chevalier
add tests for: - hashmap_remove_and_put - hashmap_first_key - hashmap_last - hashmap_steal_first_key - hashmap_clear_free_free
2014-06-16tests: add test-fdsetRonny Chevalier
2014-06-16tests: add test-socket-utilRonny Chevalier
2014-06-06bus: add basic dbus1 policy parserLennart Poettering
Enforcement is still missing, but at least we can parse it now.
2014-06-04core: rename ReadOnlySystem= to ProtectSystem= and add a third value for ↵Lennart Poettering
also mounting /etc read-only Also, rename ProtectedHome= to ProtectHome=, to simplify things a bit. With this in place we now have two neat options ProtectSystem= and ProtectHome= for protecting the OS itself (and optionally its configuration), and for protecting the user's data.
2014-06-03core: add new ReadOnlySystem= and ProtectedHome= settings for service unitsLennart Poettering
ReadOnlySystem= uses fs namespaces to mount /usr and /boot read-only for a service. ProtectedHome= uses fs namespaces to mount /home and /run/user inaccessible or read-only for a service. This patch also enables these settings for all our long-running services. Together they should be good building block for a minimal service sandbox, removing the ability for services to modify the operating system or access the user's private data.
2014-05-25test-path-util: add tests for path_make_relative()Tanu Kaskinen
2014-05-25test-unit-file: skip if unit_file_get_list returns permission deniedCristian Rodríguez