mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 06:25:37 +03:00
manager: add a test flag to ignore dependencies
The MANAGER_TEST_RUN_IGNORE_DEPENDENCIES flag was added in order to allow the caller to skip the recursive loading of dependency units when loading specific unit files. This includes the default dependencies, the specified dependencies, the slice. This will be used by systemd-analyze to allow checking individual unit files in isolation.
This commit is contained in:
parent
1545051c79
commit
f14d6810e0
@ -128,11 +128,12 @@ typedef enum WatchdogType {
|
||||
#include "unit-name.h"
|
||||
|
||||
typedef enum ManagerTestRunFlags {
|
||||
MANAGER_TEST_NORMAL = 0, /* run normally */
|
||||
MANAGER_TEST_RUN_MINIMAL = 1 << 0, /* create basic data structures */
|
||||
MANAGER_TEST_RUN_BASIC = 1 << 1, /* interact with the environment */
|
||||
MANAGER_TEST_RUN_ENV_GENERATORS = 1 << 2, /* also run env generators */
|
||||
MANAGER_TEST_RUN_GENERATORS = 1 << 3, /* also run unit generators */
|
||||
MANAGER_TEST_NORMAL = 0, /* run normally */
|
||||
MANAGER_TEST_RUN_MINIMAL = 1 << 0, /* create basic data structures */
|
||||
MANAGER_TEST_RUN_BASIC = 1 << 1, /* interact with the environment */
|
||||
MANAGER_TEST_RUN_ENV_GENERATORS = 1 << 2, /* also run env generators */
|
||||
MANAGER_TEST_RUN_GENERATORS = 1 << 3, /* also run unit generators */
|
||||
MANAGER_TEST_RUN_IGNORE_DEPENDENCIES = 1 << 4, /* run while ignoring dependencies */
|
||||
MANAGER_TEST_FULL = MANAGER_TEST_RUN_BASIC | MANAGER_TEST_RUN_ENV_GENERATORS | MANAGER_TEST_RUN_GENERATORS,
|
||||
} ManagerTestRunFlags;
|
||||
|
||||
|
@ -3053,6 +3053,9 @@ int unit_add_dependency(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (u->manager && FLAGS_SET(u->manager->test_run_flags, MANAGER_TEST_RUN_IGNORE_DEPENDENCIES))
|
||||
return 0;
|
||||
|
||||
/* Note that ordering a device unit after a unit is permitted since it allows to start its job
|
||||
* running timeout at a specific time. */
|
||||
if (FLAGS_SET(a, UNIT_ATOM_BEFORE) && other->type == UNIT_DEVICE) {
|
||||
@ -3176,6 +3179,9 @@ int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, boo
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->manager && FLAGS_SET(u->manager->test_run_flags, MANAGER_TEST_RUN_IGNORE_DEPENDENCIES))
|
||||
return 0;
|
||||
|
||||
r = manager_load_unit(u->manager, name, NULL, NULL, &other);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -3195,6 +3201,9 @@ int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->manager && FLAGS_SET(u->manager->test_run_flags, MANAGER_TEST_RUN_IGNORE_DEPENDENCIES))
|
||||
return 0;
|
||||
|
||||
r = manager_load_unit(u->manager, name, NULL, NULL, &other);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -3312,6 +3321,9 @@ int unit_set_default_slice(Unit *u) {
|
||||
|
||||
assert(u);
|
||||
|
||||
if (u->manager && FLAGS_SET(u->manager->test_run_flags, MANAGER_TEST_RUN_IGNORE_DEPENDENCIES))
|
||||
return 0;
|
||||
|
||||
if (UNIT_GET_SLICE(u))
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user