Tests: use a separate D-Bus session, if possible
authorAlberto Mardegan <alberto.mardegan@canonical.com>
Thu, 12 Apr 2012 11:32:16 +0000 (14:32 +0300)
committerAlberto Mardegan <alberto.mardegan@canonical.com>
Thu, 12 Apr 2012 11:32:16 +0000 (14:32 +0300)
Use the dbus-test-runner tool, if available, to run the tests in a
separate D-Bus session. In any case, set up environment variables so
that the signon daemon started in the tests will use its own storage,
and not mess up the user data.

tests/Makefile.am
tests/check_signon.c
tests/signon-glib-test.sh

index df648c3925a70266eab0d1d88aa5089c8ade9213..2fe761c1762410cef2c58c1820f62e10331da65b 100644 (file)
@@ -12,4 +12,4 @@ signon_glib_testsuite_LDADD = \
        $(DEPS_LIBS) \
        $(top_builddir)/libsignon-glib/libsignon-glib.la
 
-TESTS = signon-glib-testsuite
+TESTS = signon-glib-test.sh
index 4481b287e59d9912dc1fc638c3a9f3504e4b2a75..44d2f7fa72908c7c4ccf476746984a8b64de3dbf 100644 (file)
@@ -56,8 +56,6 @@ START_TEST(test_init)
     g_type_init ();
 
     g_debug("%s", G_STRFUNC);
-    system ("killall -9 signond");
-    system ("SSO_IDENTITY_TIMEOUT=5 SSO_AUTHSESSION_TIMEOUT=5 signond &");
     auth_service = signon_auth_service_new ();
     main_loop = g_main_loop_new (NULL, FALSE);
 
index 92dc89f29eb3023a082643db7182b08bb91e480b..01f722e3d2d3fed80d2bc1a4e7b4b85854e7b3a8 100755 (executable)
@@ -1,10 +1,29 @@
 #!/bin/sh
 
-if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
-    echo "No D-Bus session active; skipping tests."
-    exit 0
-fi
+# Environment variables for the signon daemon
+export SSO_LOGGING_LEVEL=2
+export SSO_STORAGE_PATH="/tmp"
+export SSO_DAEMON_TIMEOUT=5
+export SSO_IDENTITY_TIMEOUT=5
+export SSO_AUTHSESSION_TIMEOUT=5
 
+#Environment variables for the test application
 export G_MESSAGES_DEBUG=all
 
-signon-glib-testsuite
+TEST_APP=./signon-glib-testsuite
+
+# If dbus-test-runner exists, use it to run the tests in a separate D-Bus
+# session
+if command -v dbus-test-runner > /dev/null ; then
+    echo "Using dbus-test-runner"
+    dbus-test-runner -m 180 -t signond \
+        -t "$TEST_APP" -f com.nokia.SingleSignOn
+else
+    echo "Using existing D-Bus session"
+    pkill signond || true
+    trap "pkill -9 signond" EXIT
+    signond &
+    sleep 2
+
+    $TEST_APP
+fi