]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add tests for uuid/uint64 specifiers
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 15 Apr 2023 16:02:10 +0000 (18:02 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 16 Apr 2023 07:21:13 +0000 (09:21 +0200)
They're used in repart, but are not part of the "common" specifier
lists, so cover them explicitly.

src/test/test-specifier.c

index 6d4093ec05d618db6abc15be35ff9f93a5e080bc..d2a7f922bdf67eab7ffcb8e5a64322f6fb4ff741 100644 (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;