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.
This commit is contained in:
Frantisek Sumsal
2023-04-15 18:02:10 +02:00
parent cb68860ece
commit 9f7fcf80ad

View File

@@ -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;