[libgnome-keyring] Don't try to run daemon tests if DBus is not running.
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnome-keyring] Don't try to run daemon tests if DBus is not running.
- Date: Fri, 10 Sep 2010 03:25:51 +0000 (UTC)
commit 4772da8f9539872c76f0b738e508c81ac482c5e9
Author: Stef Walter <stef memberwebs com>
Date: Fri Sep 10 03:22:02 2010 +0000
Don't try to run daemon tests if DBus is not running.
* Check for DBUS_SESSION_BUS_ADDRESS and don't run daemon tests.
* Cleanup test makefile variables a bit
https://bugzilla.gnome.org/show_bug.cgi?id=626455
egg/tests/Makefile.am | 4 ++--
library/tests/Makefile.am | 7 +++++--
tests/gtest-helpers.c | 38 +++++++++++++++++++++++++++++---------
tests/gtest.make | 15 ++++++++-------
4 files changed, 44 insertions(+), 20 deletions(-)
---
diff --git a/egg/tests/Makefile.am b/egg/tests/Makefile.am
index 20f8607..0efe754 100644
--- a/egg/tests/Makefile.am
+++ b/egg/tests/Makefile.am
@@ -1,10 +1,10 @@
# Test files should be listed in order they need to run
-UNIT_AUTO = \
+TEST_AUTO = \
test-dh.c \
unit-test-secmem.c
-UNIT_LIBS = \
+TEST_LIBS = \
$(top_builddir)/egg/libegg.la
include $(top_srcdir)/tests/gtest.make
diff --git a/library/tests/Makefile.am b/library/tests/Makefile.am
index d332320..9514c47 100644
--- a/library/tests/Makefile.am
+++ b/library/tests/Makefile.am
@@ -1,14 +1,17 @@
-UNIT_AUTO = \
+TEST_AUTO = \
test-memory.c \
test-keyrings.c \
test-other.c \
test-daemon-setup.c
-UNIT_LIBS = \
+TEST_LIBS = \
$(top_builddir)/egg/libegg.la \
$(top_builddir)/library/libgnome-keyring.la
+TEST_FLAGS = \
+ -DTEST_WITH_DAEMON
+
include $(top_srcdir)/tests/gtest.make
# ------------------------------------------------------------------
diff --git a/tests/gtest-helpers.c b/tests/gtest-helpers.c
index 2e79de2..fbdb5d7 100644
--- a/tests/gtest-helpers.c
+++ b/tests/gtest-helpers.c
@@ -39,7 +39,6 @@
static GStaticMutex memory_mutex = G_STATIC_MUTEX_INIT;
static const gchar *test_path = NULL;
-static pid_t daemon_pid = 0;
void
egg_memory_lock (void)
@@ -161,12 +160,23 @@ chdir_base_dir (char* argv0)
g_free (dir);
}
-static void
+#ifdef TEST_WITH_DAEMON
+
+static pid_t daemon_pid = 0;
+
+static gboolean
daemon_start ()
{
GError *err = NULL;
gchar *args[5];
- const gchar *path, *service;
+ const gchar *path, *service, *address;
+
+ /* Need to have DBUS running */
+ address = g_getenv ("DBUS_SESSION_BUS_ADDRESS");
+ if (!address || !address[0]) {
+ g_printerr ("\nNo DBUS session available, skipping tests!\n\n");
+ return FALSE;
+ }
path = g_getenv ("GNOME_KEYRING_TEST_PATH");
if (path && !path[0])
@@ -199,6 +209,8 @@ daemon_start ()
/* Let it startup properly */
sleep (2);
}
+
+ return TRUE;
}
static void
@@ -209,11 +221,13 @@ daemon_stop (void)
daemon_pid = 0;
}
+#endif /* TEST_WITH_DAEMON */
+
int
main (int argc, char* argv[])
{
GLogLevelFlags fatal_mask;
- int ret;
+ int ret = 0;
chdir_base_dir (argv[0]);
g_test_init (&argc, &argv, NULL);
@@ -224,13 +238,19 @@ main (int argc, char* argv[])
g_log_set_always_fatal (fatal_mask);
initialize_tests ();
- daemon_start ();
- start_tests ();
- ret = g_test_run ();
- stop_tests();
+#ifdef TEST_WITH_DAEMON
+ if (daemon_start ()) {
+#endif
+
+ start_tests ();
+ ret = g_test_run ();
+ stop_tests();
- daemon_stop();
+#ifdef TEST_WITH_DAEMON
+ daemon_stop();
+ }
+#endif
return ret;
}
diff --git a/tests/gtest.make b/tests/gtest.make
index 79b6e77..aba6c64 100644
--- a/tests/gtest.make
+++ b/tests/gtest.make
@@ -1,7 +1,8 @@
# The following need to be declared before this file is included:
-# UNIT_AUTO A list of C files with tests
-# UNIT_LIBS Libraries to link the tests to
+# TEST_AUTO A list of C files with tests
+# TEST_LIBS Libraries to link the tests to
+# TEST_FLAGS Flags for the tests
# ------------------------------------------------------------------------------
@@ -18,21 +19,21 @@ LIBS = \
noinst_PROGRAMS= \
run-auto-test
-run-auto-test.h: $(UNIT_AUTO) Makefile.am $(top_srcdir)/tests/prep-gtest.sh
- sh $(top_srcdir)/tests/prep-gtest.sh -b run-auto-test $(UNIT_AUTO)
+run-auto-test.h: $(TEST_AUTO) Makefile.am $(top_srcdir)/tests/prep-gtest.sh
+ sh $(top_srcdir)/tests/prep-gtest.sh -b run-auto-test $(TEST_AUTO)
run-auto-test.c: run-auto-test.h
run_auto_test_SOURCES = \
run-auto-test.c run-auto-test.h \
- $(UNIT_AUTO)
+ $(TEST_AUTO)
run_auto_test_LDADD = \
- $(UNIT_LIBS) \
+ $(TEST_LIBS) \
$(LIBRARY_LIBS)
run_auto_test_CFLAGS = \
- $(UNIT_FLAGS)
+ $(TEST_FLAGS)
BUILT_SOURCES = \
run-auto-test.c \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]