summaryrefslogtreecommitdiff
path: root/src/test/test-specifier.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-05-10 00:13:14 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-05-12 10:09:11 +0900
commitf4767dc081a66ed50079e7e0a8829522cc57c8c6 (patch)
treef46f72223df776bce938ff8c1c887e8ed2bdd089 /src/test/test-specifier.c
parent695c5fee6d09318324347526292b142da7e449a7 (diff)
downloadsystemd-f4767dc081a66ed50079e7e0a8829522cc57c8c6.tar.gz
test: move test_specifier_printf() to test-specifier.c
Diffstat (limited to 'src/test/test-specifier.c')
-rw-r--r--src/test/test-specifier.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/test-specifier.c b/src/test/test-specifier.c
index 2648c1c3f5..cad4aa56ec 100644
--- a/src/test/test-specifier.c
+++ b/src/test/test-specifier.c
@@ -56,6 +56,38 @@ static const Specifier specifier_table[] = {
{}
};
+static void test_specifier_printf(void) {
+ static const Specifier table[] = {
+ { 'X', specifier_string, (char*) "AAAA" },
+ { 'Y', specifier_string, (char*) "BBBB" },
+ COMMON_SYSTEM_SPECIFIERS,
+ {}
+ };
+
+ _cleanup_free_ char *w = NULL;
+ int r;
+
+ log_info("/* %s */", __func__);
+
+ r = specifier_printf("xxx a=%X b=%Y yyy", table, NULL, &w);
+ assert_se(r >= 0);
+ assert_se(w);
+
+ puts(w);
+ assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
+
+ free(w);
+ r = specifier_printf("machine=%m, boot=%b, host=%H, version=%v, arch=%a", table, NULL, &w);
+ assert_se(r >= 0);
+ assert_se(w);
+ puts(w);
+
+ w = mfree(w);
+ specifier_printf("os=%o, os-version=%w, build=%B, variant=%W", table, NULL, &w);
+ if (w)
+ puts(w);
+}
+
static void test_specifiers(void) {
log_info("/* %s */", __func__);
@@ -76,6 +108,7 @@ int main(int argc, char *argv[]) {
test_specifier_escape();
test_specifier_escape_strv();
+ test_specifier_printf();
test_specifiers();
return 0;