summaryrefslogtreecommitdiffstats
path: root/src/test/test-specifier.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-05-09 17:13:14 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-05-12 03:09:11 +0200
commitf4767dc081a66ed50079e7e0a8829522cc57c8c6 (patch)
treef46f72223df776bce938ff8c1c887e8ed2bdd089 /src/test/test-specifier.c
parentspecifier: rename variable (diff)
downloadsystemd-f4767dc081a66ed50079e7e0a8829522cc57c8c6.tar.xz
systemd-f4767dc081a66ed50079e7e0a8829522cc57c8c6.zip
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;