mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
test-install-root: introduce test case for #33411
This commit is contained in:
parent
4441cf330b
commit
9fb5a8ca24
@ -23,12 +23,14 @@ TEST(basic_mask_and_enable) {
|
||||
InstallChange *changes = NULL;
|
||||
size_t n_changes = 0;
|
||||
|
||||
assert_se(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "a.service", NULL) == -ENOENT);
|
||||
assert_se(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "b.service", NULL) == -ENOENT);
|
||||
assert_se(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "c.service", NULL) == -ENOENT);
|
||||
assert_se(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "d.service", NULL) == -ENOENT);
|
||||
assert_se(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "e.service", NULL) == -ENOENT);
|
||||
assert_se(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "f.service", NULL) == -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "a.service", NULL), -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "b.service", NULL), -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "c.service", NULL), -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "d.service", NULL), -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "e.service", NULL), -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "f.service", NULL), -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "g.service", NULL), -ENOENT);
|
||||
ASSERT_EQ(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "h.service", NULL), -ENOENT);
|
||||
|
||||
p = strjoina(root, "/usr/lib/systemd/system/a.service");
|
||||
assert_se(write_string_file(p,
|
||||
@ -197,6 +199,24 @@ TEST(basic_mask_and_enable) {
|
||||
changes = NULL; n_changes = 0;
|
||||
|
||||
assert_se(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "f.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
|
||||
|
||||
/* Test enabling units with only Alias= (unit_file_enable should return > 0 to indicate we did
|
||||
* something, #33411) */
|
||||
|
||||
p = strjoina(root, SYSTEM_CONFIG_UNIT_DIR "/g.service");
|
||||
ASSERT_OK(write_string_file(p,
|
||||
"[Install]\n"
|
||||
"Alias=h.service\n", WRITE_STRING_FILE_CREATE));
|
||||
|
||||
ASSERT_GT(unit_file_enable(RUNTIME_SCOPE_SYSTEM, 0, root, STRV_MAKE("g.service"), &changes, &n_changes), 0);
|
||||
install_changes_free(changes, n_changes);
|
||||
changes = NULL; n_changes = 0;
|
||||
|
||||
ASSERT_OK(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "g.service", &state));
|
||||
ASSERT_EQ(state, UNIT_FILE_ENABLED);
|
||||
|
||||
ASSERT_OK(unit_file_get_state(RUNTIME_SCOPE_SYSTEM, root, "h.service", &state));
|
||||
ASSERT_EQ(state, UNIT_FILE_ALIAS);
|
||||
}
|
||||
|
||||
TEST(linked_units) {
|
||||
|
Loading…
Reference in New Issue
Block a user