]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: move test_specifier_printf() to test-specifier.c
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 9 May 2021 15:13:14 +0000 (00:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 May 2021 01:09:11 +0000 (10:09 +0900)
src/test/test-specifier.c
src/test/test-strv.c

index 2648c1c3f516377835358e5bfb1cb3f64bc6f60b..cad4aa56eca3bb848509e1ab03252809e008e38a 100644 (file)
@@ -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;
index 039bb2c78af326c33db50d7f7e2d4b924c703d9f..134525288f1a4b971e2bf49cb5d63a8a4d118564 100644 (file)
@@ -3,42 +3,9 @@
 #include "alloc-util.h"
 #include "escape.h"
 #include "nulstr-util.h"
-#include "specifier.h"
 #include "string-util.h"
 #include "strv.h"
 
-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_str_in_set(void) {
         log_info("/* %s */", __func__);
 
@@ -1022,7 +989,6 @@ static void test_strv_fnmatch(void) {
 }
 
 int main(int argc, char *argv[]) {
-        test_specifier_printf();
         test_str_in_set();
         test_strptr_in_set();
         test_startswith_set();