chiark / gitweb /
test: Make testing work on systems without or old systemd
[elogind.git] / src / test / test-unit-name.c
index 2fa0294882fcd73ee9e03cac41eb2ff0ac648000..c17692b845e5af80f469954acaf0baaec39b4ed5 100644 (file)
@@ -34,6 +34,7 @@
 #include "specifier.h"
 #include "util.h"
 #include "macro.h"
+#include "test-helper.h"
 
 static void test_replacements(void) {
 #define expect(pattern, repl, expected)                            \
@@ -124,7 +125,7 @@ static int test_unit_printf(void) {
         assert_se(asprintf(&root_uid, "%d", (int) root->pw_uid) > 0);
 
         r = manager_new(SYSTEMD_USER, false, &m);
-        if (r == -EPERM) {
+        if (r == -EPERM || r == -EACCES) {
                 puts("manager_new: Permission denied. Skipping test.");
                 return EXIT_TEST_SKIP;
         }
@@ -196,6 +197,8 @@ static int test_unit_printf(void) {
 }
 
 int main(int argc, char* argv[]) {
+        int rc = 0;
         test_replacements();
-        return test_unit_printf();
+        TEST_REQ_RUNNING_SYSTEMD(rc = test_unit_printf());
+        return rc;
 }