summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-26 17:11:19 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-04-16 13:06:07 +0100
commita6b68598c42d34383d24cf424e0fe740a0bfffb2 (patch)
tree6fade8b8f09271e759ae53e38053e648f5cb1a1d
parentb7e56c18a961fc9717fd399077b2d5a1126669cb (diff)
downloaddbus-a6b68598c42d34383d24cf424e0fe740a0bfffb2.tar.gz
dbus-a6b68598c42d34383d24cf424e0fe740a0bfffb2.tar.bz2
dbus-a6b68598c42d34383d24cf424e0fe740a0bfffb2.zip
tests: provide g_test_skip() emulation for older GLib
We don't hard-depend on a new enough GLib to have g_test_skip(); if our GLib is older, fake it using g_test_message() and degrade to reporting it as a pass rather than a skip. Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
-rw-r--r--test/fdpass.c8
-rw-r--r--test/test-utils-glib.c29
-rw-r--r--test/test-utils-glib.h8
3 files changed, 28 insertions, 17 deletions
diff --git a/test/fdpass.c b/test/fdpass.c
index 9a9d0ed6..a706c927 100644
--- a/test/fdpass.c
+++ b/test/fdpass.c
@@ -93,14 +93,6 @@ typedef struct {
int fd_before;
} Fixture;
-#if !GLIB_CHECK_VERSION (2, 38, 0)
-#define g_test_skip(s) my_test_skip (s)
-static inline void my_test_skip (const gchar *s)
-{
- g_message ("SKIP: %s", s);
-}
-#endif
-
#ifdef HAVE_UNIX_FD_PASSING
static void oom (const gchar *doing) G_GNUC_NORETURN;
diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c
index e112f8e5..667f72a4 100644
--- a/test/test-utils-glib.c
+++ b/test/test-utils-glib.c
@@ -118,7 +118,7 @@ spawn_dbus_daemon (const gchar *binary,
#ifdef DBUS_UNIX
if (getuid () != 0)
{
- g_message ("SKIP: cannot use alternative uid when not uid 0");
+ g_test_skip ("cannot use alternative uid when not uid 0");
return NULL;
}
@@ -132,7 +132,11 @@ spawn_dbus_daemon (const gchar *binary,
if (pwd == NULL)
{
- g_message ("SKIP: user '%s' does not exist", DBUS_USER);
+ gchar *message = g_strdup_printf ("user '%s' does not exist",
+ DBUS_USER);
+
+ g_test_skip (message);
+ g_free (message);
return NULL;
}
@@ -143,7 +147,11 @@ spawn_dbus_daemon (const gchar *binary,
if (pwd == NULL)
{
- g_message ("SKIP: user '%s' does not exist", DBUS_TEST_USER);
+ gchar *message = g_strdup_printf ("user '%s' does not exist",
+ DBUS_TEST_USER);
+
+ g_test_skip (message);
+ g_free (message);
return NULL;
}
@@ -153,7 +161,7 @@ spawn_dbus_daemon (const gchar *binary,
g_assert_not_reached ();
}
#else
- g_message ("SKIP: cannot use alternative uid on Windows");
+ g_test_skip ("cannot use alternative uid on Windows");
return NULL;
#endif
}
@@ -222,8 +230,9 @@ test_get_dbus_daemon (const gchar *config_file,
if (g_getenv ("DBUS_TEST_DATA") == NULL)
{
- g_message ("SKIP: set DBUS_TEST_DATA to a directory containing %s",
+ g_test_message ("set DBUS_TEST_DATA to a directory containing %s",
config_file);
+ g_test_skip ("DBUS_TEST_DATA not set");
return NULL;
}
@@ -256,7 +265,7 @@ test_get_dbus_daemon (const gchar *config_file,
{
if (config_file != NULL || user != TEST_USER_ME)
{
- g_message ("SKIP: cannot use DBUS_TEST_DAEMON_ADDRESS for "
+ g_test_skip ("cannot use DBUS_TEST_DAEMON_ADDRESS for "
"unusally-configured dbus-daemon");
address = NULL;
}
@@ -335,8 +344,9 @@ test_connect_to_bus_as_user (TestMainContext *ctx,
if (ruid != 0 || euid != 0 || suid != 0)
{
- g_message ("SKIP: not uid 0 (ruid=%ld euid=%ld suid=%ld)",
+ g_test_message ("not uid 0 (ruid=%ld euid=%ld suid=%ld)",
(unsigned long) ruid, (unsigned long) euid, (unsigned long) suid);
+ g_test_skip ("not uid 0");
return NULL;
}
@@ -344,7 +354,8 @@ test_connect_to_bus_as_user (TestMainContext *ctx,
if (pwd == NULL)
{
- g_message ("SKIP: getpwnam(\"%s\"): %s", username, g_strerror (errno));
+ g_test_message ("getpwnam(\"%s\"): %s", username, g_strerror (errno));
+ g_test_skip ("not uid 0");
return NULL;
}
@@ -370,7 +381,7 @@ test_connect_to_bus_as_user (TestMainContext *ctx,
return test_connect_to_bus (ctx, address);
default:
- g_message ("SKIP: setresuid() not available, or unsure about "
+ g_test_skip ("setresuid() not available, or unsure about "
"credentials-passing semantics on this platform");
return NULL;
}
diff --git a/test/test-utils-glib.h b/test/test-utils-glib.h
index ce1b2976..acacee0a 100644
--- a/test/test-utils-glib.h
+++ b/test/test-utils-glib.h
@@ -83,4 +83,12 @@ void test_init (int *argcp, char ***argvp);
void test_progress (char symbol);
+#if !GLIB_CHECK_VERSION (2, 38, 0)
+#define g_test_skip(s) my_test_skip (s)
+static inline void my_test_skip (const gchar *s)
+{
+ g_test_message ("SKIP: %s", s);
+}
+#endif
+
#endif