diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-09 17:13:14 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-12 03:09:11 +0200 |
commit | f4767dc081a66ed50079e7e0a8829522cc57c8c6 (patch) | |
tree | f46f72223df776bce938ff8c1c887e8ed2bdd089 /src/test/test-specifier.c | |
parent | specifier: rename variable (diff) | |
download | systemd-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.c | 33 |
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; |