summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:19:48 +0000
commit68ea0ad933488166b8f6a9f8f2ea0287436cea25 (patch)
tree6ef163ae03d2463b703658a35f46a5807e32c36d /src/test
parentAdding upstream version 256.2. (diff)
downloadsystemd-68ea0ad933488166b8f6a9f8f2ea0287436cea25.tar.xz
systemd-68ea0ad933488166b8f6a9f8f2ea0287436cea25.zip
Adding upstream version 256.4.upstream/256.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/meson.build8
-rw-r--r--src/test/test-install-root.c32
2 files changed, 30 insertions, 10 deletions
diff --git a/src/test/meson.build b/src/test/meson.build
index 3abbb94..9d3c7d6 100644
--- a/src/test/meson.build
+++ b/src/test/meson.build
@@ -274,7 +274,7 @@ executables += [
# only static linking apart from libdl, to make sure that the
# module is linked to all libraries that it uses.
'sources' : files('test-dlopen.c'),
- 'link_with' : libbasic,
+ 'link_with' : libbasic_static,
'dependencies' : libdl,
'install' : false,
'type' : 'manual',
@@ -410,7 +410,7 @@ executables += [
},
test_template + {
'sources' : files('test-sizeof.c'),
- 'link_with' : libbasic,
+ 'link_with' : libbasic_static,
},
test_template + {
'sources' : files('test-time-util.c'),
@@ -590,7 +590,7 @@ executables += [
test_template + {
'sources' : files('../libsystemd/sd-device/test-sd-device-thread.c'),
'link_with' : [
- libbasic,
+ libbasic_static,
libsystemd,
],
'dependencies' : threads,
@@ -598,7 +598,7 @@ executables += [
test_template + {
'sources' : files('../libudev/test-udev-device-thread.c'),
'link_with' : [
- libbasic,
+ libbasic_static,
libudev,
],
'dependencies' : threads,
diff --git a/src/test/test-install-root.c b/src/test/test-install-root.c
index 1e7ed27..433cf22 100644
--- a/src/test/test-install-root.c
+++ b/src/test/test-install-root.c
@@ -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) {