diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c index 7705c4877d3..3cf704134c0 100644 --- a/src/test/test-load-fragment.c +++ b/src/test/test-load-fragment.c @@ -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);