[systemd-devel] [PATCH 3/3] test-strv.c: ported test_specifier_printf() to _cleanup_free_ + assert_se + cleanup

Daniel Buch boogiewasthere at gmail.com
Sun Feb 17 11:15:52 PST 2013


---
 src/test/test-strv.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index e33568c..1718f56 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -27,7 +27,7 @@
 #include "strv.h"
 
 static void test_specifier_printf(void) {
-        char *w;
+        _cleanup_free_ char *w = NULL;
 
         const Specifier table[] = {
                 { 'a', specifier_string, (char*) "AAAA" },
@@ -36,8 +36,10 @@ static void test_specifier_printf(void) {
         };
 
         w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
-        printf("<%s>\n", w);
-        free(w);
+        puts(w);
+
+        assert_se(w);
+        assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
 }
 
 static void test_strv_find(void) {
-- 
1.8.1.3



More information about the systemd-devel mailing list