chiark / gitweb /
tests: skip bus test if bus cannot be opened
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 27 Mar 2013 01:07:46 +0000 (21:07 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 27 Mar 2013 03:50:44 +0000 (23:50 -0400)
To make the result more visible, special return value
is used to tell automake that the test was skipped. While
at it, use the same return value in other skipped tests.

src/libsystemd-bus/test-bus-chat.c
src/shared/macro.h
src/test/test-sched-prio.c
src/test/test-unit-name.c

index bdcca18c84f808639e39c00374b5a75aa52165b7..e124b247d1d1e23c5092e32676089ba95ac8d939 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "log.h"
 #include "util.h"
+#include "macro.h"
 
 #include "sd-bus.h"
 #include "bus-message.h"
@@ -543,8 +544,10 @@ int main(int argc, char *argv[]) {
         int q, r;
 
         r = server_init(&bus);
-        if (r < 0)
-                return EXIT_FAILURE;
+        if (r < 0) {
+                log_info("Failed to connect to bus, skipping tests.");
+                return EXIT_TEST_SKIP;
+        }
 
         log_info("Initialized...");
 
index 80cb2f0892f9a2d41ae9918cb5644e99e6bca3f6..898784ac839945ff26803a0cfb13728fd401de06 100644 (file)
@@ -46,6 +46,9 @@
 #define _introspect_(x) __attribute__((section("introspect." x)))
 #define _alignas_(x) __attribute__((aligned(__alignof(x))))
 
+/* automake test harness */
+#define EXIT_TEST_SKIP 77
+
 #define XSTRINGIFY(x) #x
 #define STRINGIFY(x) XSTRINGIFY(x)
 
index c57f6a3671295f7fb4af08461d63a51cfed39da3..ba0aacf79dfe422147ee7d2514b34bbfa1902d8d 100644 (file)
@@ -22,7 +22,7 @@
 #include <sched.h>
 
 #include "manager.h"
-
+#include "macro.h"
 
 int main(int argc, char *argv[]) {
         Manager *m;
@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
         r = manager_new(SYSTEMD_USER, &m);
         if (r == -EPERM) {
                 puts("manager_new: Permission denied. Skipping test.");
-                return EXIT_SUCCESS;
+                return EXIT_TEST_SKIP;
         }
         assert(r >= 0);
         assert_se(manager_startup(m, serial, fdset) >= 0);
index 0b6b56394ee6abba0b63cec7b0e4096cd5cde347..aba36e4df1ad072e75e200757d396d051decfa9f 100644 (file)
@@ -108,7 +108,7 @@ static void test_replacements(void) {
 #undef expect
 }
 
-static void test_unit_printf(void) {
+static int test_unit_printf(void) {
         Manager *m;
         Unit *u, *u2;
         int r;
@@ -126,7 +126,7 @@ static void test_unit_printf(void) {
         r = manager_new(SYSTEMD_USER, &m);
         if (r == -EPERM) {
                 puts("manager_new: Permission denied. Skipping test.");
-                return;
+                return EXIT_TEST_SKIP;
         }
         assert(r == 0);
 
@@ -189,11 +189,11 @@ static void test_unit_printf(void) {
         expect(u2, "%b", bid);
         expect(u2, "%H", host);
         expect(u2, "%t", "/run/user/*");
+
+        return 0;
 }
 
 int main(int argc, char* argv[]) {
         test_replacements();
-        test_unit_printf();
-
-        return 0;
+        return test_unit_printf();
 }