From f60f8983396e1bd46bfe6196afd92484715a05a0 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Thu, 12 Apr 2012 14:32:16 +0300 Subject: [PATCH] Tests: use a separate D-Bus session, if possible 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 | 2 +- tests/check_signon.c | 2 -- tests/signon-glib-test.sh | 29 ++++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index df648c3..2fe761c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/check_signon.c b/tests/check_signon.c index 4481b28..44d2f7f 100644 --- a/tests/check_signon.c +++ b/tests/check_signon.c @@ -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); diff --git a/tests/signon-glib-test.sh b/tests/signon-glib-test.sh index 92dc89f..01f722e 100755 --- a/tests/signon-glib-test.sh +++ b/tests/signon-glib-test.sh @@ -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 -- 2.34.1