Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1:Staging:C
systemd-mini
0001-test-engine-fix-access-to-unit-load-path.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-test-engine-fix-access-to-unit-load-path.patch of Package systemd-mini
diff -Naur systemd-210/Makefile.am systemd-210.mod/Makefile.am --- systemd-210/Makefile.am 2015-03-12 13:27:22.789021872 +0100 +++ systemd-210.mod/Makefile.am 2015-03-12 16:44:23.814429872 +0100 @@ -180,6 +180,7 @@ -DPOLKIT_AGENT_BINARY_PATH=\"$(bindir)/pkttyagent\" \ -DQUOTACHECK=\"$(QUOTACHECK)\" \ -DKEXEC=\"$(KEXEC)\" \ + -DTEST_DIR=\"$(abs_top_srcdir)/test\" \ -I $(top_srcdir)/src \ -I $(top_builddir)/src/shared \ -I $(top_srcdir)/src/shared \ diff -Naur systemd-210/src/core/cgroup.c systemd-210.mod/src/core/cgroup.c --- systemd-210/src/core/cgroup.c 2014-02-24 03:38:58.984488560 +0100 +++ systemd-210.mod/src/core/cgroup.c 2015-03-12 17:17:18.586264937 +0100 @@ -794,7 +794,6 @@ int manager_setup_cgroup(Manager *m) { _cleanup_free_ char *path = NULL; - char *e; int r; assert(m); @@ -819,6 +818,8 @@ * off. This is to support live upgrades from older systemd * versions where PID 1 was moved there. */ if (m->running_as == SYSTEMD_SYSTEM) { + char *e; + e = endswith(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE); if (!e) e = endswith(m->cgroup_root, "/system"); @@ -841,40 +842,44 @@ log_debug("Using cgroup controller " SYSTEMD_CGROUP_CONTROLLER ". File system hierarchy is at %s.", path); - /* 3. Install agent */ - if (m->running_as == SYSTEMD_SYSTEM) { - r = cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH); - if (r < 0) - log_warning("Failed to install release agent, ignoring: %s", strerror(-r)); - else if (r > 0) - log_debug("Installed release agent."); - else - log_debug("Release agent already installed."); - } + if (!m->test_run) { + /* 3. Install agent */ + if (m->running_as == SYSTEMD_SYSTEM) { + r = cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH); + if (r < 0) + log_warning("Failed to install release agent, ignoring: %s", strerror(-r)); + else if (r > 0) + log_debug("Installed release agent."); + else + log_debug("Release agent already installed."); + } + + /* 4. Make sure we are in the root cgroup */ + r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0); + if (r < 0) { + log_error("Failed to create root cgroup hierarchy: %s", strerror(-r)); + return r; + } + + /* 5. And pin it, so that it cannot be unmounted */ + if (m->pin_cgroupfs_fd >= 0) + close_nointr_nofail(m->pin_cgroupfs_fd); + + m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK); + if (r < 0) { + log_error("Failed to open pin file: %m"); + return -errno; + } + + + /* 6. Always enable hierarchial support if it exists... */ + cg_set_attribute("memory", "/", "memory.use_hierarchy", "1"); + } - /* 4. Make sure we are in the root cgroup */ - r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0); - if (r < 0) { - log_error("Failed to create root cgroup hierarchy: %s", strerror(-r)); - return r; - } - /* 5. And pin it, so that it cannot be unmounted */ - if (m->pin_cgroupfs_fd >= 0) - close_nointr_nofail(m->pin_cgroupfs_fd); - - m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK); - if (r < 0) { - log_error("Failed to open pin file: %m"); - return -errno; - } - - /* 6. Figure out which controllers are supported */ + /* 7. Figure out which controllers are supported */ m->cgroup_supported = cg_mask_supported(); - /* 7. Always enable hierarchial support if it exists... */ - cg_set_attribute("memory", "/", "memory.use_hierarchy", "1"); - return 0; } diff -Naur systemd-210/src/core/main.c systemd-210.mod/src/core/main.c --- systemd-210/src/core/main.c 2015-03-12 13:27:19.432997287 +0100 +++ systemd-210.mod/src/core/main.c 2015-03-12 15:19:12.042700240 +0100 @@ -1472,6 +1472,9 @@ goto finish; } + if (arg_action == ACTION_TEST) + skip_setup = true; + pager_open_if_enabled(); if (arg_action == ACTION_HELP) { @@ -1542,7 +1545,8 @@ if (arg_running_as == SYSTEMD_SYSTEM) { const char *virtualization = NULL; - log_info(PACKAGE_STRING " running in system mode. (" SYSTEMD_FEATURES ")"); + log_info(PACKAGE_STRING " running in %ssystem mode. (" SYSTEMD_FEATURES ")", + arg_action == ACTION_TEST ? "test " : "" ); detect_virtualization(&virtualization); if (virtualization) @@ -1559,7 +1563,8 @@ _cleanup_free_ char *t; t = uid_to_name(getuid()); - log_debug(PACKAGE_STRING " running in user mode for user "UID_FMT"/%s. (" SYSTEMD_FEATURES ")", getuid(), strna(t)); + log_debug(PACKAGE_STRING " running in %suser mode for user "UID_FMT"/%s. (" SYSTEMD_FEATURES ")", + arg_action == ACTION_TEST ? " test" : "", getuid(), t); } if (arg_running_as == SYSTEMD_SYSTEM && !skip_setup) { @@ -1617,7 +1622,7 @@ if (arg_running_as == SYSTEMD_SYSTEM) bump_rlimit_nofile(&saved_rlimit_nofile); - r = manager_new(arg_running_as, &m); + r = manager_new(arg_running_as, arg_action == ACTION_TEST, &m); if (r < 0) { log_error("Failed to allocate manager object: %s", strerror(-r)); goto finish; diff -Naur systemd-210/src/core/manager.c systemd-210.mod/src/core/manager.c --- systemd-210/src/core/manager.c 2015-03-12 13:27:19.524997962 +0100 +++ systemd-210.mod/src/core/manager.c 2015-03-12 15:19:12.043700246 +0100 @@ -466,6 +466,9 @@ 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 */ @@ -528,6 +531,9 @@ assert(m); + if (m->test_run) + return 0; + assert_se(sigaction(SIGCHLD, &sa, NULL) == 0); /* We make liberal use of realtime signals here. On @@ -660,7 +666,7 @@ 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; @@ -689,6 +695,8 @@ m->ask_password_inotify_fd = -1; m->have_ask_password = -EINVAL; /* we don't know */ + m->test_run = test_run; + r = manager_default_environment(m); if (r < 0) goto fail; @@ -770,6 +778,9 @@ }; int one = 1, r; + if (m->test_run) + return 0; + if (m->notify_fd < 0) { _cleanup_close_ int fd = -1; @@ -849,12 +860,10 @@ 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); @@ -881,6 +890,9 @@ assert(m); + if (m->test_run) + return 0; + try_bus_connect = m->kdbus_fd >= 0 || reexecuting || @@ -2909,6 +2921,9 @@ 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) { diff -Naur systemd-210/src/core/manager.h systemd-210.mod/src/core/manager.h --- systemd-210/src/core/manager.h 2015-03-12 13:27:19.524997962 +0100 +++ systemd-210.mod/src/core/manager.h 2015-03-12 15:19:12.043700246 +0100 @@ -211,6 +211,8 @@ bool taint_usr:1; + bool test_run:1; + ShowStatus show_status; bool confirm_spawn; bool no_console_output; @@ -257,7 +259,7 @@ int kdbus_fd; }; -int manager_new(SystemdRunningAs running_as, Manager **m); +int manager_new(SystemdRunningAs running_as, bool test_run, Manager **m); void manager_free(Manager *m); int manager_enumerate(Manager *m); diff -Naur systemd-210/src/test/test-cgroup-mask.c systemd-210.mod/src/test/test-cgroup-mask.c --- systemd-210/src/test/test-cgroup-mask.c 2014-02-19 17:53:50.226327296 +0100 +++ systemd-210.mod/src/test/test-cgroup-mask.c 2015-03-12 15:19:12.043700246 +0100 @@ -37,11 +37,10 @@ FILE *serial = NULL; FDSet *fdset = NULL; int r; - const char *dir = TEST_DIR; /* Prepare the manager. */ - assert_se(set_unit_path(dir) >= 0); - r = manager_new(SYSTEMD_USER, &m); + assert_se(set_unit_path(TEST_DIR) >= 0); + r = manager_new(SYSTEMD_USER, true, &m); if (r == -EPERM || r == -EACCES) { puts("manager_new: Permission denied. Skipping test."); return EXIT_TEST_SKIP; diff -Naur systemd-210/src/test/test-engine.c systemd-210.mod/src/test/test-engine.c --- systemd-210/src/test/test-engine.c 2014-02-13 03:42:34.627681754 +0100 +++ systemd-210.mod/src/test/test-engine.c 2015-03-12 15:19:12.043700246 +0100 @@ -25,15 +25,26 @@ #include <unistd.h> #include "manager.h" +#include "bus-util.h" int main(int argc, char *argv[]) { + _cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL; Manager *m = NULL; Unit *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *g = NULL, *h = NULL; + FILE *serial = NULL; + FDSet *fdset = NULL; Job *j; + int r; - assert_se(set_unit_path("test") >= 0); - - assert_se(manager_new(SYSTEMD_SYSTEM, &m) >= 0); + /* prepare the test */ + assert_se(set_unit_path(TEST_DIR) >= 0); + r = manager_new(SYSTEMD_USER, true, &m); + if (r == -EPERM || r == -EACCES || r == -EADDRINUSE || r == -EHOSTDOWN) { + printf("Skipping test: manager_new: %s", strerror(-r)); + return EXIT_TEST_SKIP; + } + assert(r >= 0); + assert_se(manager_startup(m, serial, fdset) >= 0); printf("Load1:\n"); assert_se(manager_load_unit(m, "a.service", NULL, NULL, &a) >= 0); @@ -42,7 +53,10 @@ manager_dump_units(m, stdout, "\t"); printf("Test1: (Trivial)\n"); - assert_se(manager_add_job(m, JOB_START, c, JOB_REPLACE, false, NULL, &j) == 0); + r = manager_add_job(m, JOB_START, c, JOB_REPLACE, false, &err, &j); + if (sd_bus_error_is_set(&err)) + log_error("error: %s: %s", err.name, err.message); + assert(r == 0); manager_dump_jobs(m, stdout, "\t"); printf("Load2:\n"); diff -Naur systemd-210/src/test/test-sched-prio.c systemd-210.mod/src/test/test-sched-prio.c --- systemd-210/src/test/test-sched-prio.c 2014-02-19 17:53:50.226327296 +0100 +++ systemd-210.mod/src/test/test-sched-prio.c 2015-03-12 15:19:12.043700246 +0100 @@ -31,11 +31,10 @@ FILE *serial = NULL; FDSet *fdset = NULL; int r; - const char *dir = TEST_DIR; /* prepare the test */ - assert_se(set_unit_path(dir) >= 0); - r = manager_new(SYSTEMD_USER, &m); + assert_se(set_unit_path(TEST_DIR) >= 0); + r = manager_new(SYSTEMD_USER, true, &m); if (r == -EPERM || r == -EACCES || r == -EADDRINUSE || r == -EHOSTDOWN) { printf("Skipping test: manager_new: %s", strerror(-r)); return EXIT_TEST_SKIP; diff -Naur systemd-210/src/test/test-unit-name.c systemd-210.mod/src/test/test-unit-name.c --- systemd-210/src/test/test-unit-name.c 2014-02-19 17:53:50.226327296 +0100 +++ systemd-210.mod/src/test/test-unit-name.c 2015-03-12 15:19:12.043700246 +0100 @@ -124,7 +124,7 @@ assert_se((root = getpwnam("root"))); assert_se(asprintf(&root_uid, "%d", (int) root->pw_uid) > 0); - r = manager_new(SYSTEMD_USER, &m); + r = manager_new(SYSTEMD_USER, true, &m); if (r == -EPERM || r == -EACCES || r == -EADDRINUSE) { puts("manager_new: Permission denied. Skipping test."); return EXIT_TEST_SKIP;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor