]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-condition: skip test if machine-id is missing
authorLuca Boccassi <bluca@debian.org>
Mon, 24 Oct 2022 23:56:44 +0000 (00:56 +0100)
committerLuca Boccassi <bluca@debian.org>
Tue, 25 Oct 2022 14:10:15 +0000 (15:10 +0100)
When building in a chroot there might not be any machine-id

src/test/test-condition.c

index 8fcaacc1721203f002576039d19bc7e1b9b7d562..4cd23d8e2135bba4ec65f986a66894bd5aa9f9ab 100644 (file)
@@ -247,8 +247,12 @@ TEST(condition_test_host) {
         _cleanup_free_ char *hostname = NULL;
         Condition *condition;
         sd_id128_t id;
+        int r;
 
-        assert_se(sd_id128_get_machine(&id) >= 0);
+        r = sd_id128_get_machine(&id);
+        if (IN_SET(r, -ENOENT, -ENOMEDIUM))
+                return (void) log_tests_skipped("/etc/machine-id missing");
+        assert_se(r >= 0);
 
         condition = condition_new(CONDITION_HOST, SD_ID128_TO_STRING(id), false, false);
         assert_se(condition);