From: Frantisek Sumsal Date: Sat, 15 Apr 2023 16:02:10 +0000 (+0200) Subject: test: add tests for uuid/uint64 specifiers X-Git-Tag: v254-rc1~707^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f7fcf80ad2bd69d1267e782ac2c846e40bf2c7d;p=thirdparty%2Fsystemd.git test: add tests for uuid/uint64 specifiers They're used in repart, but are not part of the "common" specifier lists, so cover them explicitly. --- diff --git a/src/test/test-specifier.c b/src/test/test-specifier.c index 6d4093ec05d..d2a7f922bdf 100644 --- a/src/test/test-specifier.c +++ b/src/test/test-specifier.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "sd-id128.h" + #include "alloc-util.h" #include "log.h" #include "specifier.h" @@ -144,6 +146,31 @@ TEST(specifiers) { } } +/* Bunch of specifiers that are not part of the common lists */ +TEST(specifiers_assorted) { + const sd_id128_t id = SD_ID128_ALLF; + const uint64_t llu = UINT64_MAX; + const Specifier table[] = { + /* Used in src/partition/repart.c */ + { 'a', specifier_uuid, &id }, + { 'b', specifier_uint64, &llu }, + {} + }; + + for (const Specifier *s = table; s->specifier; s++) { + char spec[3]; + _cleanup_free_ char *resolved = NULL; + int r; + + xsprintf(spec, "%%%c", s->specifier); + + r = specifier_printf(spec, SIZE_MAX, table, NULL, NULL, &resolved); + assert_se(r >= 0); + + log_info("%%%c → %s", s->specifier, resolved); + } +} + TEST(specifiers_missing_data_ok) { _cleanup_free_ char *resolved = NULL;