chiark / gitweb /
shared/util: fix off-by-one error in tag_to_udev_node
[elogind.git] / src / test / test-unit-file.c
index 2075e8611551766ed45a137c76a89cb1c3041741..0413ae211746cee293a18709e37ebd0b28265e1f 100644 (file)
@@ -35,6 +35,7 @@
 #include "load-fragment.h"
 #include "strv.h"
 #include "fileio.h"
+#include "test-helper.h"
 
 static int test_unit_file_get_set(void) {
         int r;
@@ -301,17 +302,18 @@ static void test_install_printf(void) {
 
         _cleanup_free_ char *mid, *bid, *host;
 
-        assert_se((mid = specifier_machine_id('m', NULL, NULL)));
-        assert_se((bid = specifier_boot_id('b', NULL, NULL)));
+        assert_se(specifier_machine_id('m', NULL, NULL, &mid) >= 0 && mid);
+        assert_se(specifier_boot_id('b', NULL, NULL, &bid) >= 0 && bid);
         assert_se((host = gethostname_malloc()));
 
 #define expect(src, pattern, result)                                    \
         do {                                                            \
-                _cleanup_free_ char *t = install_full_printf(&src, pattern); \
+                _cleanup_free_ char *t = NULL;                          \
                 _cleanup_free_ char                                     \
                         *d1 = strdup(i.name),                           \
                         *d2 = strdup(i.path),                           \
                         *d3 = strdup(i.user);                           \
+                assert_se(install_full_printf(&src, pattern, &t) >= 0 || !result); \
                 memzero(i.name, strlen(i.name));                        \
                 memzero(i.path, strlen(i.path));                        \
                 memzero(i.user, strlen(i.user));                        \
@@ -366,7 +368,7 @@ int main(int argc, char *argv[]) {
         test_load_env_file_2();
         test_load_env_file_3();
         test_load_env_file_4();
-        test_install_printf();
+        TEST_REQ_RUNNING_SYSTEMD(test_install_printf());
 
         return r;
 }