[evolution-data-server/openismus-work-master] test-server-utils.c: Added TEST_INSTALLED_SERVICES env var



commit 2e0f12b21a5ee1c726186dc0dbb00e29935eec9a
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Fri Feb 8 19:14:33 2013 +0900

    test-server-utils.c: Added TEST_INSTALLED_SERVICES env var
    
    This allows us to run tests individually using the installed services,
    this makes it easier to trace the server process response to test
    cases using instrumentation tools such as gdb and valgrind.

 tests/test-server-utils/e-test-server-utils.c |   91 +++++++++++++++----------
 1 files changed, 56 insertions(+), 35 deletions(-)
---
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
index fe2fbc2..a9e33aa 100644
--- a/tests/test-server-utils/e-test-server-utils.c
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -46,6 +46,20 @@ typedef struct {
 	ETestServerClosure *closure;
 } FixturePair;
 
+static gboolean
+test_installed_services (void)
+{
+	static gint use_installed_services = -1;
+
+	if (use_installed_services < 0) {
+		if (g_getenv ("TEST_INSTALLED_SERVICES") != NULL)
+			use_installed_services = 1;
+		else
+			use_installed_services = 0;
+	}
+	return use_installed_services;
+}
+
 static void
 setup_environment (void)
 {
@@ -245,18 +259,20 @@ e_test_server_utils_setup (ETestServerFixture *fixture,
 
 	fixture->loop = g_main_loop_new (NULL, FALSE);
 
+	if (!test_installed_services ()) {
 #if !GLOBAL_DBUS_DAEMON
-	/* Create the global dbus-daemon for this test suite */
-	fixture->dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+		/* Create the global dbus-daemon for this test suite */
+		fixture->dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
 
-	/* Add the private directory with our in-tree service files */
-	g_test_dbus_add_service_dir (fixture->dbus, EDS_TEST_DBUS_SERVICE_DIR);
+		/* Add the private directory with our in-tree service files */
+		g_test_dbus_add_service_dir (fixture->dbus, EDS_TEST_DBUS_SERVICE_DIR);
 
-	/* Start the private D-Bus daemon */
-	g_test_dbus_up (fixture->dbus);
+		/* Start the private D-Bus daemon */
+		g_test_dbus_up (fixture->dbus);
 #else
-	fixture->dbus = global_test_dbus;
+		fixture->dbus = global_test_dbus;
 #endif
+	}
 
 	g_idle_add ((GSourceFunc) e_test_server_utils_bootstrap_idle, &pair);
 	g_main_loop_run (fixture->loop);
@@ -324,22 +340,24 @@ e_test_server_utils_teardown (ETestServerFixture *fixture,
 	g_main_loop_unref (fixture->loop);
 	fixture->loop = NULL;
 
+	if (!test_installed_services ()) {
 #if !GLOBAL_DBUS_DAEMON
-	/* Teardown the D-Bus Daemon
-	 *
-	 * Note that we intentionally leak the TestDBus daemon
-	 * in this case, presumably this is due to some leaked
-	 * GDBusConnection reference counting
-	 */
-	g_test_dbus_down (fixture->dbus);
-	g_object_unref (fixture->dbus);
-	fixture->dbus = NULL;
+		/* Teardown the D-Bus Daemon
+		 *
+		 * Note that we intentionally leak the TestDBus daemon
+		 * in this case, presumably this is due to some leaked
+		 * GDBusConnection reference counting
+		 */
+		g_test_dbus_down (fixture->dbus);
+		g_object_unref (fixture->dbus);
+		fixture->dbus = NULL;
 #else
-	fixture->dbus = NULL;
+		fixture->dbus = NULL;
 #endif
+	}
 
 	/* Cleanup work directory */
-	if (!closure->keep_work_directory)
+	if (!closure->keep_work_directory && !test_installed_services ())
 		delete_work_directory ();
 }
 
@@ -354,31 +372,34 @@ e_test_server_utils_run (void)
 	setup_environment ();
 
 #if GLOBAL_DBUS_DAEMON
+	if (!test_installed_services ()) {
+		/* Create the global dbus-daemon for this test suite */
+		global_test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
 
-	/* Create the global dbus-daemon for this test suite */
-	global_test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
-
-	/* Add the private directory with our in-tree service files */
-	g_test_dbus_add_service_dir (global_test_dbus, EDS_TEST_DBUS_SERVICE_DIR);
+		/* Add the private directory with our in-tree service files */
+		g_test_dbus_add_service_dir (global_test_dbus, EDS_TEST_DBUS_SERVICE_DIR);
 
-	/* Start the private D-Bus daemon */
-	g_test_dbus_up (global_test_dbus);
+		/* Start the private D-Bus daemon */
+		g_test_dbus_up (global_test_dbus);
+	}
 #endif
 
 	/* Run the GTest suite */
 	tests_ret = g_test_run ();
 
 #if GLOBAL_DBUS_DAEMON
-	/* Teardown the D-Bus Daemon
-	 *
-	 * Note that we intentionally leak the TestDBus daemon
-	 * in this case, presumably this is due to some leaked
-	 * GDBusConnection reference counting
-	 */
-	g_test_dbus_stop (global_test_dbus);
-	/* g_object_unref (global_test_dbus); */
-	global_test_dbus = NULL;
+	if (!test_installed_services ()) {
+		/* Teardown the D-Bus Daemon
+		 *
+		 * Note that we intentionally leak the TestDBus daemon
+		 * in this case, presumably this is due to some leaked
+		 * GDBusConnection reference counting
+		 */
+		g_test_dbus_stop (global_test_dbus);
+		/* g_object_unref (global_test_dbus); */
+		global_test_dbus = NULL;
+	}
 #endif
 
-  return tests_ret;
+	return tests_ret;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]