test-condition: skip test if machine-id is missing

When building in a chroot there might not be any machine-id
This commit is contained in:
Luca Boccassi
2022-10-25 15:10:15 +01:00
parent 6cae57d9ad
commit b7af9b43a5
+5 -1
View 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);