summaryrefslogtreecommitdiff
path: root/src/core/manager.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-07 08:41:24 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-20 19:48:16 -0400
commit0d8c31ff7237149b505290652864b4e7e866b2a7 (patch)
tree2a1497d3b0384fb7ab20c6010276be0e166619eb /src/core/manager.c
parentf0ea29eaeb3449822bfbdfa839b00e323dfc523e (diff)
test-engine: fix access to unit load path
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.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r--src/core/manager.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 9d9a713005..2e63c5ef1f 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -241,6 +241,9 @@ static int manager_setup_time_change(Manager *m) {
assert(m);
assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX));
+ if (m->test_run)
+ return 0;
+
/* Uses TFD_TIMER_CANCEL_ON_SET to get notifications whenever
* CLOCK_REALTIME makes a jump relative to CLOCK_MONOTONIC */
@@ -302,6 +305,9 @@ static int manager_setup_signals(Manager *m) {
assert(m);
+ if (m->test_run)
+ return 0;
+
/* We are not interested in SIGSTOP and friends. */
assert_se(sigaction(SIGCHLD, &sa, NULL) == 0);
@@ -409,7 +415,7 @@ static int manager_default_environment(Manager *m) {
return 0;
}
-int manager_new(SystemdRunningAs running_as, Manager **_m) {
+int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
Manager *m;
int r;
@@ -435,6 +441,8 @@ int manager_new(SystemdRunningAs running_as, Manager **_m) {
m->pin_cgroupfs_fd = m->notify_fd = m->signal_fd = m->time_change_fd = m->dev_autofs_fd = m->private_listen_fd = m->kdbus_fd = -1;
m->current_job_id = 1; /* start as id #1, so that we can leave #0 around as "null-like" value */
+ m->test_run = test_run;
+
r = manager_default_environment(m);
if (r < 0)
goto fail;
@@ -514,6 +522,9 @@ fail:
static int manager_setup_notify(Manager *m) {
int r;
+ if (m->test_run)
+ return 0;
+
if (m->notify_fd < 0) {
_cleanup_close_ int fd = -1;
union {
@@ -592,12 +603,10 @@ static int manager_setup_notify(Manager *m) {
static int manager_setup_kdbus(Manager *m) {
#ifdef ENABLE_KDBUS
_cleanup_free_ char *p = NULL;
-#endif
-#ifdef ENABLE_KDBUS
assert(m);
- if (m->kdbus_fd >= 0)
+ if (m->test_run || m->kdbus_fd >= 0)
return 0;
m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == SYSTEMD_SYSTEM, &p);
@@ -624,6 +633,9 @@ static int manager_connect_bus(Manager *m, bool reexecuting) {
assert(m);
+ if (m->test_run)
+ return 0;
+
try_bus_connect =
m->kdbus_fd >= 0 ||
reexecuting ||
@@ -2636,6 +2648,9 @@ void manager_run_generators(Manager *m) {
assert(m);
+ if (m->test_run)
+ return;
+
generator_path = m->running_as == SYSTEMD_SYSTEM ? SYSTEM_GENERATOR_PATH : USER_GENERATOR_PATH;
d = opendir(generator_path);
if (!d) {