chiark / gitweb /
util: when using basename() for creating temporary files, verify the resulting name...
[elogind.git] / src / test / test-unit-name.c
index 256e820c224ee85c5c5f688a5b3142515800885f..65b6975a69e0488cfeeb2adaa37252dc42d3a696 100644 (file)
@@ -135,7 +135,7 @@ static int test_unit_printf(void) {
 #define expect(unit, pattern, expected)                                 \
         {                                                               \
                 char *e;                                                \
-                _cleanup_free_ char *t;                                 \
+                _cleanup_free_ char *t = NULL;                          \
                 assert_se(unit_full_printf(unit, pattern, &t) >= 0);    \
                 printf("result: %s\nexpect: %s\n", t, expected);        \
                 if ((e = endswith(expected, "*")))                      \
@@ -159,6 +159,7 @@ static int test_unit_printf(void) {
 
         /* normal unit */
         expect(u, "%n", "blah.service");
+        expect(u, "%f", "/blah");
         expect(u, "%N", "blah");
         expect(u, "%p", "blah");
         expect(u, "%P", "blah");
@@ -178,6 +179,7 @@ static int test_unit_printf(void) {
 
         expect(u2, "%n", "blah@foo-foo.service");
         expect(u2, "%N", "blah@foo-foo");
+        expect(u2, "%f", "/foo/foo");
         expect(u2, "%p", "blah");
         expect(u2, "%P", "blah");
         expect(u2, "%i", "foo-foo");