diff options
author | Luca Boccassi <bluca@debian.org> | 2022-10-25 02:05:04 +0200 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2022-10-25 17:00:26 +0200 |
commit | 0baddbebe5057a4dd570f24f99ce0c31e7cdc143 (patch) | |
tree | 121366d847b6dcca64ef455e9d5ee287bbb19308 /src/test/test-id128.c | |
parent | test-fs-util: do not fail if machine-id is missing (diff) | |
download | systemd-0baddbebe5057a4dd570f24f99ce0c31e7cdc143.tar.xz systemd-0baddbebe5057a4dd570f24f99ce0c31e7cdc143.zip |
test-id128: do not fail if machine-id is missing
When building in a chroot there might not be any machine-id
Diffstat (limited to 'src/test/test-id128.c')
-rw-r--r-- | src/test/test-id128.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/test/test-id128.c b/src/test/test-id128.c index 5da7b0ec1a..4b71c5c00b 100644 --- a/src/test/test-id128.c +++ b/src/test/test-id128.c @@ -38,7 +38,7 @@ TEST(id128) { assert_se(!sd_id128_in_set(id, ID128_WALDI)); assert_se(!sd_id128_in_set(id, ID128_WALDI, ID128_WALDI)); - if (sd_booted() > 0) { + if (sd_booted() > 0 && access("/etc/machine-id", F_OK) >= 0) { assert_se(sd_id128_get_machine(&id) == 0); printf("machine: %s\n", sd_id128_to_string(id, t)); @@ -145,11 +145,13 @@ TEST(id128) { assert_se(id128_read_fd(fd, ID128_UUID, &id2) >= 0); assert_se(sd_id128_equal(id, id2)); - assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id) >= 0); - assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id2) >= 0); - assert_se(sd_id128_equal(id, id2)); - assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(51,df,0b,4b,c3,b0,4c,97,80,e2,99,b9,8c,a3,73,b8), &id2) >= 0); - assert_se(!sd_id128_equal(id, id2)); + if (sd_booted() > 0 && access("/etc/machine-id", F_OK) >= 0) { + assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id) >= 0); + assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(f0,3d,aa,eb,1c,33,4b,43,a7,32,17,29,44,bf,77,2e), &id2) >= 0); + assert_se(sd_id128_equal(id, id2)); + assert_se(sd_id128_get_machine_app_specific(SD_ID128_MAKE(51,df,0b,4b,c3,b0,4c,97,80,e2,99,b9,8c,a3,73,b8), &id2) >= 0); + assert_se(!sd_id128_equal(id, id2)); + } } TEST(sd_id128_get_invocation) { @@ -168,6 +170,9 @@ TEST(benchmark_sd_id128_get_machine_app_specific) { unsigned iterations = slow_tests_enabled() ? 1000000 : 1000; usec_t t, q; + if (access("/etc/machine-id", F_OK) < 0 && errno == ENOENT) + return (void) log_tests_skipped("/etc/machine-id does not exist"); + log_info("/* %s (%u iterations) */", __func__, iterations); sd_id128_t id = ID128_WALDI, id2; |