]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-load-fragment: do not fail if machine-id is missing
authorLuca Boccassi <bluca@debian.org>
Tue, 25 Oct 2022 13:41:54 +0000 (14:41 +0100)
committerLuca Boccassi <bluca@debian.org>
Tue, 25 Oct 2022 15:00:26 +0000 (16:00 +0100)
When building in a chroot there might not be any machine-id

src/test/test-load-fragment.c

index 7705c4877d3efb11498a540e774e2c4043955d2f..3cf704134c0b08dcfa76e7f7ffc6a48c37965c7d 100644 (file)
@@ -518,8 +518,10 @@ TEST(install_printf, .sd_booted = true) {
 
         _cleanup_free_ char *mid = NULL, *bid = NULL, *host = NULL, *gid = NULL, *group = NULL, *uid = NULL, *user = NULL;
 
-        assert_se(specifier_machine_id('m', NULL, NULL, NULL, &mid) >= 0 && mid);
-        assert_se(specifier_boot_id('b', NULL, NULL, NULL, &bid) >= 0 && bid);
+        if (access("/etc/machine-id", F_OK) >= 0)
+                assert_se(specifier_machine_id('m', NULL, NULL, NULL, &mid) >= 0 && mid);
+        if (sd_booted() > 0)
+                assert_se(specifier_boot_id('b', NULL, NULL, NULL, &bid) >= 0 && bid);
         assert_se(host = gethostname_malloc());
         assert_se(group = gid_to_name(getgid()));
         assert_se(asprintf(&gid, UID_FMT, getgid()) >= 0);