diff options
-rw-r--r-- | src/analyze/analyze-verify.c | 3 | ||||
-rw-r--r-- | src/core/manager.c | 42 | ||||
-rw-r--r-- | src/core/manager.h | 9 | ||||
-rw-r--r-- | src/libudev/libudev.c | 3 | ||||
-rw-r--r-- | src/test/test-cgroup-mask.c | 2 | ||||
-rw-r--r-- | src/test/test-engine.c | 2 | ||||
-rw-r--r-- | src/test/test-execute.c | 2 | ||||
-rw-r--r-- | src/test/test-path.c | 2 | ||||
-rw-r--r-- | src/test/test-sched-prio.c | 2 |
9 files changed, 37 insertions, 30 deletions
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c index f475b6598c..4cdf632552 100644 --- a/src/analyze/analyze-verify.c +++ b/src/analyze/analyze-verify.c @@ -254,7 +254,8 @@ int verify_units(char **filenames, UnitFileScope scope, bool check_man, bool run Unit *units[strv_length(filenames)]; int i, count = 0; - const uint8_t flags = MANAGER_TEST_RUN_ENV_GENERATORS | + const uint8_t flags = MANAGER_TEST_RUN_BASIC | + MANAGER_TEST_RUN_ENV_GENERATORS | run_generators * MANAGER_TEST_RUN_GENERATORS; if (strv_isempty(filenames)) diff --git a/src/core/manager.c b/src/core/manager.c index fb0743b3d7..6140d06a7f 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -747,37 +747,43 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) { if (r < 0) return r; - r = sd_event_default(&m->event); + r = manager_setup_prefix(m); if (r < 0) return r; - r = manager_setup_run_queue(m); - if (r < 0) - return r; + m->udev = udev_new(); + if (!m->udev) + return -ENOMEM; - r = manager_setup_signals(m); + r = sd_event_default(&m->event); if (r < 0) return r; - r = manager_setup_cgroup(m); + r = manager_setup_run_queue(m); if (r < 0) return r; - r = manager_setup_time_change(m); - if (r < 0) - return r; + if (test_run_flags == MANAGER_TEST_RUN_MINIMAL) { + m->cgroup_root = strdup(""); + if (!m->cgroup_root) + return -ENOMEM; + } else { + r = manager_setup_signals(m); + if (r < 0) + return r; - r = manager_setup_sigchld_event_source(m); - if (r < 0) - return r; + r = manager_setup_cgroup(m); + if (r < 0) + return r; - m->udev = udev_new(); - if (!m->udev) - return -ENOMEM; + r = manager_setup_time_change(m); + if (r < 0) + return r; - r = manager_setup_prefix(m); - if (r < 0) - return r; + r = manager_setup_sigchld_event_source(m); + if (r < 0) + return r; + } if (MANAGER_IS_SYSTEM(m) && test_run_flags == 0) { r = mkdir_label("/run/systemd/units", 0755); diff --git a/src/core/manager.h b/src/core/manager.h index 93a29417df..80304a4010 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -96,10 +96,11 @@ typedef enum ManagerTimestamp { enum { /* 0 = run normally */ - MANAGER_TEST_RUN_MINIMAL = 1, /* run test w/o generators */ - MANAGER_TEST_RUN_ENV_GENERATORS = 2, /* also run env generators */ - MANAGER_TEST_RUN_GENERATORS = 4, /* also run unit generators */ - MANAGER_TEST_FULL = MANAGER_TEST_RUN_ENV_GENERATORS | MANAGER_TEST_RUN_GENERATORS, + MANAGER_TEST_RUN_MINIMAL = 1 << 1, /* create basic data structures */ + MANAGER_TEST_RUN_BASIC = 1 << 2, /* interact with the environment */ + MANAGER_TEST_RUN_ENV_GENERATORS = 1 << 3, /* also run env generators */ + MANAGER_TEST_RUN_GENERATORS = 1 << 4, /* also run unit generators */ + MANAGER_TEST_FULL = MANAGER_TEST_RUN_BASIC | MANAGER_TEST_RUN_ENV_GENERATORS | MANAGER_TEST_RUN_GENERATORS, }; assert_cc((MANAGER_TEST_FULL & UINT8_MAX) == MANAGER_TEST_FULL); diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c index 64904c5ffa..4af0f1e1c6 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -85,8 +85,7 @@ _public_ void udev_set_userdata(struct udev *udev, void *userdata) { /** * udev_new: * - * Create udev library context. This reads the udev configuration - * file, and fills in the default values. + * Create udev library context. This only allocates the basic data structure. * * The initial refcount is 1, and needs to be decremented to * release the resources of the udev library context. diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c index 88032e6e12..907531b045 100644 --- a/src/test/test-cgroup-mask.c +++ b/src/test/test-cgroup-mask.c @@ -45,7 +45,7 @@ static int test_cgroup_mask(void) { /* Prepare the manager. */ assert_se(set_unit_path(get_testdata_dir("")) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); - r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m); + r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m); if (IN_SET(r, -EPERM, -EACCES)) { puts("manager_new: Permission denied. Skipping test."); return EXIT_TEST_SKIP; diff --git a/src/test/test-engine.c b/src/test/test-engine.c index fb6f404a65..5d7cd8cfd5 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { /* prepare the test */ assert_se(set_unit_path(get_testdata_dir("")) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); - r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m); + r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); return EXIT_TEST_SKIP; diff --git a/src/test/test-execute.c b/src/test/test-execute.c index 0290220569..954080df36 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -628,7 +628,7 @@ static int run_tests(UnitFileScope scope, const test_function_t *tests) { assert_se(tests); - r = manager_new(scope, MANAGER_TEST_RUN_MINIMAL, &m); + r = manager_new(scope, MANAGER_TEST_RUN_BASIC, &m); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); return EXIT_TEST_SKIP; diff --git a/src/test/test-path.c b/src/test/test-path.c index 3f579b064d..880e54d81c 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -52,7 +52,7 @@ static int setup_test(Manager **m) { return -EXIT_TEST_SKIP; } - r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &tmp); + r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &tmp); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); return -EXIT_TEST_SKIP; diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c index 819c8e8ebf..abcda4dab5 100644 --- a/src/test/test-sched-prio.c +++ b/src/test/test-sched-prio.c @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) { /* prepare the test */ assert_se(set_unit_path(get_testdata_dir("")) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); - r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m); + r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); return EXIT_TEST_SKIP; |