From 8028e303a98db4c3fb9a6da6f33c9d311c00f54d Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Wed, 12 Dec 2012 14:23:30 +0900 Subject: [PATCH] Removing e-source-registry-test.c and e-test-dbus-utils.[ch] The source registry test checks if sources can be created in the registry, this is already asserted by e-test-server-utils in the fixture test. Removing the e-test-dbus-utils.[ch] and tests/tools directory in favour of new testing framework added in test-server-utils directory. --- configure.ac | 1 - tests/Makefile.am | 2 +- tests/libedataserver/Makefile.am | 10 -- tests/libedataserver/e-source-registry-test.c | 152 --------------------- tests/libedataserver/e-source-test.c | 2 + tests/libedataserver/e-test-dbus-utils.c | 184 -------------------------- tests/libedataserver/e-test-dbus-utils.h | 34 ----- tests/tools/Makefile.am | 5 - tests/tools/dbus-session.sh | 114 ---------------- tests/tools/eds.sh | 36 ----- tests/tools/with-session-bus-eds.sh | 45 ------- 11 files changed, 3 insertions(+), 582 deletions(-) delete mode 100644 tests/libedataserver/e-source-registry-test.c delete mode 100644 tests/libedataserver/e-test-dbus-utils.c delete mode 100644 tests/libedataserver/e-test-dbus-utils.h delete mode 100644 tests/tools/Makefile.am delete mode 100644 tests/tools/dbus-session.sh delete mode 100644 tests/tools/eds.sh delete mode 100755 tests/tools/with-session-bus-eds.sh diff --git a/configure.ac b/configure.ac index 212736c..9d4e771 100644 --- a/configure.ac +++ b/configure.ac @@ -1627,7 +1627,6 @@ tests/libecal/Makefile tests/libecal/client/Makefile tests/libedata-cal/Makefile tests/libedataserver/Makefile -tests/tools/Makefile docs/Makefile docs/reference/Makefile docs/reference/addressbook/Makefile diff --git a/tests/Makefile.am b/tests/Makefile.am index 6c5f457..cffe9a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = libedataserver libebook libecal libedata-cal tools +SUBDIRS = libedataserver libebook libecal libedata-cal @GNOME_CODE_COVERAGE_RULES@ diff --git a/tests/libedataserver/Makefile.am b/tests/libedataserver/Makefile.am index efc7d9a..7dc05e3 100644 --- a/tests/libedataserver/Makefile.am +++ b/tests/libedataserver/Makefile.am @@ -4,7 +4,6 @@ NULL = TESTS = \ e-source-test \ - e-source-registry-test \ e-user-prompter-test \ $(NULL) @@ -29,12 +28,6 @@ e_source_test_SOURCES = \ e-source-test.c \ $(NULL) -e_source_registry_test_SOURCES = \ - e-source-registry-test.c \ - e-test-dbus-utils.c \ - e-test-dbus-utils.h \ - $(NULL) - e_user_prompter_test_SOURCES = \ e-user-prompter-test.c \ $(NULL) @@ -42,9 +35,6 @@ e_user_prompter_test_SOURCES = \ e_source_test_CPPFLAGS = $(test_CPPFLAGS) e_source_test_LDADD = $(test_LDADD) -e_source_registry_test_CPPFLAGS = $(test_CPPFLAGS) -e_source_registry_test_LDADD = $(test_LDADD) - e_user_prompter_test_CPPFLAGS = $(test_CPPFLAGS) e_user_prompter_test_LDADD = $(top_builddir)/libebackend/libebackend-1.2.la $(test_LDADD) diff --git a/tests/libedataserver/e-source-registry-test.c b/tests/libedataserver/e-source-registry-test.c deleted file mode 100644 index d5111f7..0000000 --- a/tests/libedataserver/e-source-registry-test.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * e-source-registry-test.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - */ - -#include "e-test-dbus-utils.h" - -#include - -typedef struct _TestClosure TestClosure; -typedef struct _TestFixture TestFixture; - -struct _TestClosure { - GTestDBus *test_dbus; - const gchar *base_directory; -}; - -struct _TestFixture { - ESourceRegistry *registry; - GMainLoop *main_loop; -}; - -static void -test_fixture_setup_session (TestFixture *fixture, - gconstpointer user_data) -{ - const TestClosure *closure = user_data; - GError *error = NULL; - - g_assert (fixture->registry == NULL); - g_assert (fixture->main_loop == NULL); - - g_test_dbus_up (closure->test_dbus); - - fixture->registry = e_source_registry_new_sync (NULL, &error); - g_assert_no_error (error); - - fixture->main_loop = g_main_loop_new (NULL, FALSE); -} - -static void -test_fixture_teardown_session (TestFixture *fixture, - gconstpointer user_data) -{ - const TestClosure *closure = user_data; - GError *error = NULL; - - g_object_unref (fixture->registry); - fixture->registry = NULL; - - g_main_loop_unref (fixture->main_loop); - fixture->main_loop = NULL; - - g_test_dbus_stop (closure->test_dbus); - - e_test_clean_base_directories (&error); - g_assert_no_error (error); -} - -static gboolean -test_commit_source_idle_cb (gpointer user_data) -{ - TestFixture *fixture = user_data; - ESource *source; - gchar *uid; - GError *error = NULL; - - /* Configure a minimal scratch source. */ - source = e_source_new (NULL, NULL, &error); - g_assert_no_error (error); - e_source_set_parent (source, "local-stub"); - e_source_set_display_name (source, "Test Commit Source"); - - /* Note the ESource UID. */ - uid = e_source_dup_uid (source); - - /* Submit the scratch source. */ - e_source_registry_commit_source_sync ( - fixture->registry, source, NULL, &error); - g_assert_no_error (error); - - /* Discard the scratch source. */ - g_object_unref (source); - - /* Verify the registry has an ESource with the same UID. */ - source = e_source_registry_ref_source (fixture->registry, uid); - - g_free (uid); - - if (source != NULL) { - g_object_unref (source); - } else { - g_test_fail (); - } - - g_main_loop_quit (fixture->main_loop); - - return FALSE; -} - -static void -test_commit_source (TestFixture *fixture, - gconstpointer user_data) -{ - g_test_bug ("685986"); - g_idle_add (test_commit_source_idle_cb, fixture); - g_main_loop_run (fixture->main_loop); -} - -gint -main (gint argc, - gchar **argv) -{ - TestClosure closure; - gint retval; - - g_type_init (); - - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugzilla.gnome.org/"); - - closure.base_directory = e_test_setup_base_directories (); - closure.test_dbus = e_test_setup_dbus_session (); - - g_test_add ( - "/e-source-registry-test/CommitSource", - TestFixture, &closure, - test_fixture_setup_session, - test_commit_source, - test_fixture_teardown_session); - - retval = g_test_run (); - - /* XXX Something is leaking a GDBusConnection reference. - * Leave this disabled until I can track it down. */ - /* g_object_unref (closure.test_dbus); */ - - return retval; -} diff --git a/tests/libedataserver/e-source-test.c b/tests/libedataserver/e-source-test.c index bb14f5d..d6b6da0 100644 --- a/tests/libedataserver/e-source-test.c +++ b/tests/libedataserver/e-source-test.c @@ -124,7 +124,9 @@ static void test_fixture_teardown_key_file (TestFixture *fixture, gconstpointer test_data) { +#if 0 /* ACCOUNT_MGMT */ teardown_test_source (&fixture->test); +#endif } static void diff --git a/tests/libedataserver/e-test-dbus-utils.c b/tests/libedataserver/e-test-dbus-utils.c deleted file mode 100644 index 7bc592e..0000000 --- a/tests/libedataserver/e-test-dbus-utils.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * e-test-dbus-utils.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - */ - -#include -#include -#include - -#include "e-test-dbus-utils.h" - -#include - -static GOnce base_directories_once = G_ONCE_INIT; - -static void -test_setup_xdg_data_home (const gchar *base_directory) -{ - gchar *filename; - - g_assert (base_directory != NULL); - - filename = g_build_filename (base_directory, "share", NULL); - - g_print ("XDG_DATA_HOME=%s\n", filename); - g_assert (g_setenv ("XDG_DATA_HOME", filename, TRUE)); - g_assert_cmpstr (g_get_user_data_dir (), ==, filename); - - g_free (filename); -} - -static void -test_setup_xdg_cache_home (const gchar *base_directory) -{ - gchar *filename; - - g_assert (base_directory != NULL); - - filename = g_build_filename (base_directory, "cache", NULL); - - g_print ("XDG_CACHE_HOME=%s\n", filename); - g_assert (g_setenv ("XDG_CACHE_HOME", filename, TRUE)); - g_assert_cmpstr (g_get_user_cache_dir (), ==, filename); - - g_free (filename); -} - -static void -test_setup_xdg_config_home (const gchar *base_directory) -{ - gchar *filename; - - g_assert (base_directory != NULL); - - filename = g_build_filename (base_directory, "config", NULL); - - g_print ("XDG_CONFIG_HOME=%s\n", filename); - g_assert (g_setenv ("XDG_CONFIG_HOME", filename, TRUE)); - g_assert_cmpstr (g_get_user_config_dir (), ==, filename); - - g_free (filename); -} - -static gpointer -test_setup_base_directories_once (gpointer unused) -{ - gchar *base_directory; - - /* Do not invoke g_get_user_cache_dir() here because that will - * permanently set the cache directory result and we won't be - * able to override it with an environment variable. */ - base_directory = g_build_filename ( - g_get_home_dir (), - ".cache", "evolution", - "tmp", "test-home-XXXXXX", NULL); - - mkdtemp (base_directory); - - test_setup_xdg_data_home (base_directory); - test_setup_xdg_cache_home (base_directory); - test_setup_xdg_config_home (base_directory); - - return base_directory; -} - -const gchar * -e_test_setup_base_directories (void) -{ - g_once ( - &base_directories_once, - test_setup_base_directories_once, NULL); - - return base_directories_once.retval; -} - -gboolean -e_test_clean_base_directories (GError **error) -{ - GFile *file; - gboolean success = TRUE; - const gchar *user_data_dir; - const gchar *user_cache_dir; - const gchar *user_config_dir; - - e_test_setup_base_directories (); - - user_data_dir = g_get_user_data_dir (); - g_assert (strstr (user_data_dir, "test-home") != NULL); - - user_cache_dir = g_get_user_cache_dir (); - g_assert (strstr (user_cache_dir, "test-home") != NULL); - - user_config_dir = g_get_user_config_dir (); - g_assert (strstr (user_config_dir, "test-home") != NULL); - - if (success) { - file = g_file_new_for_path (user_data_dir); - success = e_file_recursive_delete_sync (file, NULL, error); - g_object_unref (file); - } - - if (success) { - file = g_file_new_for_path (user_cache_dir); - success = e_file_recursive_delete_sync (file, NULL, error); - g_object_unref (file); - } - - if (success) { - file = g_file_new_for_path (user_config_dir); - success = e_file_recursive_delete_sync (file, NULL, error); - g_object_unref (file); - } - - return success; -} - -static void -register_dbus_service_dir (GTestDBus *test_dbus, - const gchar *data_dir) -{ - gchar *service_dir; - - service_dir = g_build_filename (data_dir, "dbus-1", "services", NULL); - - g_print ("Adding service dir: %s\n", service_dir); - g_test_dbus_add_service_dir (test_dbus, service_dir); - - g_free (service_dir); -} - -GTestDBus * -e_test_setup_dbus_session (void) -{ - GTestDBus *test_dbus; - const gchar * const *system_data_dirs; - gint ii; - - e_test_setup_base_directories (); - - system_data_dirs = g_get_system_data_dirs (); - g_assert (system_data_dirs != NULL); - - test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); - register_dbus_service_dir (test_dbus, DATADIR); - - for (ii = 0; system_data_dirs[ii] != NULL; ii++) { - register_dbus_service_dir (test_dbus, system_data_dirs[ii]); - } - - return test_dbus; -} diff --git a/tests/libedataserver/e-test-dbus-utils.h b/tests/libedataserver/e-test-dbus-utils.h deleted file mode 100644 index f12b7d5..0000000 --- a/tests/libedataserver/e-test-dbus-utils.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * e-test-dbus-utils.h - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - */ - -#ifndef E_TEST_DBUS_UTILS_H -#define E_TEST_DBUS_UTILS_H - -#include - -G_BEGIN_DECLS - -const gchar * e_test_setup_base_directories (void); -gboolean e_test_clean_base_directories (GError **error); - -GTestDBus * e_test_setup_dbus_session (void); - -G_END_DECLS - -#endif /* E_TEST_DBUS_UTILS_H */ - diff --git a/tests/tools/Makefile.am b/tests/tools/Makefile.am deleted file mode 100644 index 8552112..0000000 --- a/tests/tools/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -EXTRA_DIST = \ - with-session-bus-eds.sh \ - dbus-session.sh - --include $(top_srcdir)/git.mk diff --git a/tests/tools/dbus-session.sh b/tests/tools/dbus-session.sh deleted file mode 100644 index 1f805bf..0000000 --- a/tests/tools/dbus-session.sh +++ /dev/null @@ -1,114 +0,0 @@ -# -# Helper functions to start your own D-Bus session. -# -# Refactored from with-session-bush.sh (from telepathy-glib). -# -# The canonical location of this program is the telepathy-glib tools/ -# directory, please synchronize any changes with that copy. -# -# Copyright (C) 2007-2008,2011 Collabora Ltd. -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. - - -dbus_daemon_args="--print-address=5 --print-pid=6 --fork" -dbus_verbose=0 -dbus_me=with-session-bus -dbus_sleep=0 -dbus_with_session="" -dbus_config_file="" - -# Params: -# verbose: 0 for off and 1 for on -# -dbus_init () { - exec 5> $dbus_me-$$.address - exec 6> $dbus_me-$$.pid - dbus_verbose=$1 -} - -dbus_usage () -{ - echo "usage: $me [options] -- program [program_options]" >&2 - echo "Requires write access to the current directory." >&2 - echo "" >&2 - echo "If \$WITH_SESSION_BUS_FORK_DBUS_MONITOR is set, fork dbus-monitor" >&2 - echo "with the arguments in \$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT." >&2 - echo "The output of dbus-monitor is saved in $me-.dbus-monitor-logs" >&2 - exit 2 -} - -dbus_parse_args () { - while test "z$1" != "z--"; do - case "$1" in - --sleep=*) - sleep="$1" - dbus_sleep="${sleep#--sleep=}" - shift - ;; - --session) - dbus_with_session="--session" - shift - ;; - --config-file=*) - # FIXME: assumes config file doesn't contain any special characters - dbus_config_file="$1" - shift - ;; - *) - dbus_usage - ;; - esac - done -} - -dbus_start () { - local args="$dbus_daemon_args $dbus_with_session $dbus_config_file " - - if [ $dbus_verbose -gt 0 ] ; then - echo -n "dbus args $args " - fi - - dbus-daemon $args - - { - if [ $dbus_verbose -gt 0 ] ; then - echo -n "Temporary bus daemon is "; cat $dbus_me-$$.address; - fi - } >&2 - - { - if [ $dbus_verbose -gt 0 ] ; then - echo -n "Temporary bus daemon PID is "; head -n1 $dbus_me-$$.pid; - fi - } >&2 - - DBUS_SESSION_BUS_ADDRESS="`cat $dbus_me-$$.address`" - export DBUS_SESSION_BUS_ADDRESS - - if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then - if [ $dbus_verbose -gt 0 ] ; then - echo -n "Forking dbus-monitor " \ - "$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2 - fi - dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \ - > $dbus_me-$$.dbus-monitor-logs 2>&1 & - fi -} - -# -# This should be called for INT, HUP and TERM signals -# -dbus_stop () { - pid=`head -n1 $dbus_me-$$.pid` - if test -n "$pid" ; then - if [ $dbus_verbose -gt 0 ] ; then - echo "Killing temporary bus daemon: $pid" >&2 - fi - kill -INT "$pid" - fi - rm -f $dbus_me-$$.address - rm -f $dbus_me-$$.pid -} diff --git a/tests/tools/eds.sh b/tests/tools/eds.sh deleted file mode 100644 index c892cfe..0000000 --- a/tests/tools/eds.sh +++ /dev/null @@ -1,36 +0,0 @@ -# -# Helper functions to start your own e-d-s instance. This depends -# on you having your own D-Bus session bus started (first). -# -# -# Copyright (C) 2011 Collabora Ltd. -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. - -eds_tmpdir=$(mktemp -d) - -eds_init_settings () { - export XDG_DATA_HOME=$eds_tmpdir/.local - export XDG_CACHE_HOME=$eds_tmpdir/.cache - export XDG_CONFIG_HOME=$eds_tmpdir/.config -} - -# This makes sure that our locally-built service starts, -# in our already-started private D-Bus session, -# so we don't need to use a .service file to make sure that it will be -# activated instead. -eds_start() { - #$(top_builddir)/services/evolution-addressbook-factory/evolution-addressbook-factory -r - $cur_dir"/../../services/evolution-addressbook-factory/evolution-addressbook-factory" -r& - eds_pid=$! -} - -# This should be called on INT TERM and EXIT -eds_stop () { - kill $eds_pid - rm -rf $eds_tmpdir - rm -rf $eds_tmpdir -} - diff --git a/tests/tools/with-session-bus-eds.sh b/tests/tools/with-session-bus-eds.sh deleted file mode 100755 index 416b8bb..0000000 --- a/tests/tools/with-session-bus-eds.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# with-session-bus-eds.sh - run a program with a temporary D-Bus session daemon -# -# interesting bits have been move into dbus to permit reusability -# -# Copyright (C) 2007-2008 Collabora Ltd. -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. - - -cur_dir=`dirname $0` - -. $cur_dir"/dbus-session.sh" -. $cur_dir"/eds.sh" - -dbus_parse_args $@ -while test "z$1" != "z--"; do - shift -done -shift -if test "z$1" = "z"; then dbus_usage; fi - -cleanup () -{ - eds_stop - dbus_stop -} - -trap cleanup INT HUP TERM - -eds_init_settings -eds_start -dbus_init 0 - -dbus_start - -e=0 -"$@" || e=$? - -trap - INT HUP TERM -cleanup - -exit $e -- 2.7.4