diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-04-15 18:02:10 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-04-16 09:21:13 +0200 |
commit | 9f7fcf80ad2bd69d1267e782ac2c846e40bf2c7d (patch) | |
tree | 13df8fb07a17f82341dce17865b9477ca498953e /src/test | |
parent | cb68860ece01406b51257ce65c065f44c4ab9aaf (diff) | |
download | systemd-9f7fcf80ad2bd69d1267e782ac2c846e40bf2c7d.tar.gz |
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.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-specifier.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/test-specifier.c b/src/test/test-specifier.c index 6d4093ec05..d2a7f922bd 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; |