diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-03-25 10:21:31 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-03-25 10:21:39 +0000 |
commit | 647a336103083065aa0342664d800846d3d308a6 (patch) | |
tree | 906ae08eaae1186b8408f986d18ab9abb6489621 | |
parent | d4fa8725b88b8337c7af68af16f95ca07a64fdd3 (diff) | |
parent | 256a8f67c22404a65d27628537d15d7164ae54d1 (diff) | |
download | telepathy-glib-647a336103083065aa0342664d800846d3d308a6.tar.gz |
Merge branch 'next-tap' into next
Reviewed-by: Xaveir Claessens
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 25 | ||||
-rw-r--r-- | tests/asv.c | 32 | ||||
-rw-r--r-- | tests/availability-cmp.c | 32 | ||||
-rw-r--r-- | tests/dbus/Makefile.am | 27 | ||||
-rw-r--r-- | tests/dbus/call-cancellation.c | 73 | ||||
-rw-r--r-- | tests/dbus/disconnection.c | 69 | ||||
-rw-r--r-- | tests/dbus/example-no-protocols.c | 34 | ||||
-rw-r--r-- | tests/dbus/finalized-in-invalidated-handler.c | 35 | ||||
-rw-r--r-- | tests/dbus/group-mixin.c | 34 | ||||
-rw-r--r-- | tests/dbus/handle-repo.c | 38 | ||||
-rw-r--r-- | tests/dbus/handle-set.c | 34 | ||||
-rw-r--r-- | tests/dbus/message-mixin.c | 34 | ||||
-rw-r--r-- | tests/dbus/run-test.sh.in | 31 | ||||
-rw-r--r-- | tests/dbus/self-presence.c | 34 | ||||
-rw-r--r-- | tests/dbus/text-respawn.c | 34 | ||||
-rw-r--r-- | tests/debug-domain.c | 32 | ||||
-rw-r--r-- | tests/gnio-util.c | 74 | ||||
-rw-r--r-- | tests/heap.c | 34 | ||||
-rw-r--r-- | tests/internal-debug.c | 34 | ||||
-rw-r--r-- | tests/intset.c | 33 | ||||
-rw-r--r-- | tests/logger/Makefile.am | 6 | ||||
-rw-r--r-- | tests/logger/dbus/Makefile.am | 6 | ||||
-rw-r--r-- | tests/logger/test-tpl-conf.c | 32 | ||||
-rw-r--r-- | tests/util-cxx.cpp | 32 | ||||
-rw-r--r-- | tests/util.c | 33 |
26 files changed, 733 insertions, 153 deletions
diff --git a/.gitignore b/.gitignore index efb972209..88ebcf765 100644 --- a/.gitignore +++ b/.gitignore @@ -147,6 +147,10 @@ telepathy-glib/version.h /test-driver /tests/all-errors-documented.py.log /tests/all-errors-documented.py.trs +/tests/**/tmp-cache +/tests/**/tmp-config +/tests/**/tmp-data +/tests/**/tmp-runtime tests/dbus/dbus-installed/session.conf tests/dbus/dbus-uninstalled/session.conf tests/dbus/run-test.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 3e162a616..22bb8a224 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,15 +32,31 @@ programs_list += \ test-util-cxx endif +CLEANFILES = + if ENABLE_INSTALLED_TESTS testsdir = @tpglibtestsdir@ tests_PROGRAMS = $(programs_list) tests_DATA = tpglib-tests.list +CLEANFILES += $(tests_DATA) + +insttestdir = ${datadir}/installed-tests/telepathy-glib +insttest_DATA = $(patsubst %,%.test,$(programs_list)) +CLEANFILES += $(insttest_DATA) + else noinst_PROGRAMS = $(programs_list) endif -tpglib-tests.list: +%.test: Makefile + $(AM_V_GEN)( echo '[Test]'; \ + echo 'Exec=${testsdir}/$* --tap'; \ + echo 'Type=session'; \ + echo 'Output=TAP'; \ + ) > $@.tmp + @mv $@.tmp $@ + +tpglib-tests.list: Makefile $(AM_V_GEN)echo $(programs_list) > $@ TESTS = $(programs_list) \ @@ -53,6 +69,10 @@ AM_TESTS_ENVIRONMENT = \ G_DEBUG=fatal_warnings,fatal_criticals$(maybe_gc_friendly) \ G_MESSAGES_DEBUG=all \ PYTHONPATH=@abs_top_srcdir@/tools \ + XDG_CACHE_HOME=@abs_builddir@/tmp-cache \ + XDG_CONFIG_HOME=@abs_builddir@/tmp-config \ + XDG_DATA_HOME=@abs_builddir@/tmp-data \ + XDG_RUNTIME_DIR=@abs_builddir@/tmp-runtime \ $(NULL) LOG_COMPILER = @@ -197,3 +217,6 @@ AM_CXXFLAGS = $(ERROR_CXXFLAGS) if HAVE_CXX test_util_cxx_SOURCES = util-cxx.cpp endif + +clean-local: + rm -fr tmp-cache tmp-config tmp-data tmp-runtime diff --git a/tests/asv.c b/tests/asv.c index 4e90bd055..cdba62d7a 100644 --- a/tests/asv.c +++ b/tests/asv.c @@ -28,7 +28,19 @@ g_assert_cmpstr (tp_asv_get_object_path (hash, key), ==, expected_value); \ g_assert_cmpstr (tp_vardict_get_object_path (vardict, key), ==, expected_value); \ -int main (int argc, char **argv) +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +static void +test (Fixture *f, + gconstpointer data) { GHashTable *hash; GVariant *vardict; @@ -283,6 +295,22 @@ int main (int argc, char **argv) g_hash_table_unref (hash); g_variant_unref (vardict); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/asv", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/availability-cmp.c b/tests/availability-cmp.c index 7b17b3747..df1e00bed 100644 --- a/tests/availability-cmp.c +++ b/tests/availability-cmp.c @@ -3,7 +3,19 @@ #include <glib.h> #include <telepathy-glib/connection.h> -int main (int argc, char **argv) +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +static void +test (Fixture *f, + gconstpointer data) { g_assert (tp_connection_presence_type_cmp_availability ( TP_CONNECTION_PRESENCE_TYPE_AWAY, TP_CONNECTION_PRESENCE_TYPE_UNSET) == 1); @@ -13,6 +25,22 @@ int main (int argc, char **argv) g_assert (tp_connection_presence_type_cmp_availability ( TP_CONNECTION_PRESENCE_TYPE_UNKNOWN, 100) == 0); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/availability-cmp", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am index 2f82aa82f..027defa81 100644 --- a/tests/dbus/Makefile.am +++ b/tests/dbus/Makefile.am @@ -57,6 +57,8 @@ tests_list = \ test-tls-certificate \ test-unsupported-interface +CLEANFILES = + if ENABLE_INSTALLED_TESTS managersdir = @tpglibtestsdir@/telepathy-1/managers/ managers_DATA = \ @@ -69,10 +71,26 @@ testsdir = @tpglibtestsdir@ tests_PROGRAMS = $(tests_list) tests_SCRIPTS = run-test.sh tests_DATA = tpglib-dbus-tests.list +CLEANFILES += \ + $(tests_DATA) \ + $(tests_SCRIPTS) \ + $(NULL) + +insttestdir = ${datadir}/installed-tests/telepathy-glib +insttest_DATA = $(patsubst %,%.test,$(tests_list)) +CLEANFILES += $(insttest_DATA) else noinst_PROGRAMS = $(tests_list) endif +%.test: Makefile + $(AM_V_GEN)( echo '[Test]'; \ + echo 'Exec=${testsdir}/run-test.sh $*'; \ + echo 'Type=session'; \ + echo 'Output=TAP'; \ + ) > $@.tmp + @mv $@.tmp $@ + TESTS = $(tests_list) tpglib-dbus-tests.list: @@ -283,8 +301,11 @@ AM_CFLAGS = $(ERROR_CFLAGS) AM_TESTS_ENVIRONMENT = \ abs_top_builddir=@abs_top_builddir@ \ + XDG_CACHE_HOME=@abs_builddir@/tmp-cache \ + XDG_CONFIG_HOME=@abs_builddir@/tmp-config \ XDG_DATA_HOME=@abs_builddir@ \ XDG_DATA_DIRS=@abs_srcdir@:$${XDG_DATA_DIRS:=/usr/local/share:/usr/share} \ + XDG_RUNTIME_DIR=@abs_builddir@/tmp-runtime \ G_SLICE=debug-blocks \ G_DEBUG=fatal_warnings,fatal_criticals$(maybe_gc_friendly) \ G_MESSAGES_DEBUG=all \ @@ -314,8 +335,7 @@ BUILT_SOURCES = \ run-test.sh \ $(NULL) -CLEANFILES = \ - $(BUILT_SOURCES) +CLEANFILES += $(BUILT_SOURCES) distclean-local: rm -f capture-*.log @@ -361,3 +381,6 @@ _gen/errors-check.h: $(top_srcdir)/spec/errors.xml \ $(top_srcdir)/tools/glib-errors-check-gen.py $(AM_V_at)$(MKDIR_P) _gen $(AM_V_GEN)$(PYTHON) $(top_srcdir)/tools/glib-errors-check-gen.py $< > $@ + +clean-local: + rm -fr tmp-cache tmp-config tmp-runtime diff --git a/tests/dbus/call-cancellation.c b/tests/dbus/call-cancellation.c index 724c8a189..3faeb0ac6 100644 --- a/tests/dbus/call-cancellation.c +++ b/tests/dbus/call-cancellation.c @@ -20,7 +20,7 @@ /* just for convenience, since it's used a lot */ #define PTR(ui) GUINT_TO_POINTER(ui) -/* state tracking */ +/* state tracking (FIXME: move this into the Fixture) */ static TpIntset *method_ok; static TpIntset *method_error; static TpIntset *freed_user_data; @@ -59,7 +59,8 @@ typedef struct { gboolean had_last_reply; } Fixture; -static Fixture *f; +/* FIXME: it would be better not to need this */ +static Fixture *global_fixture; static void destroy_user_data (gpointer user_data) @@ -92,6 +93,7 @@ method_cb (TpProxy *proxy, gpointer user_data, GObject *weak_object) { + Fixture *f = global_fixture; guint which = GPOINTER_TO_UINT (user_data); TpProxy *want_proxy = NULL; GObject *want_object = NULL; @@ -172,8 +174,18 @@ signal_cb (TpProxy *proxy, } static void -setup (void) +setup (Fixture *f, + gconstpointer data) { + global_fixture = f; + + tp_tests_abort_after (10); + tp_debug_set_flags ("all"); + + freed_user_data = tp_intset_sized_new (N_PROXIES); + method_ok = tp_intset_sized_new (N_PROXIES); + method_error = tp_intset_sized_new (N_PROXIES); + g_test_dbus_unset (); f->test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); g_test_dbus_up (f->test_dbus); @@ -200,7 +212,7 @@ setup (void) } static void -drop_private_connection (void) +drop_private_connection (Fixture *f) { dbus_g_connection_unref (f->private_dbusglib); f->private_dbusglib = NULL; @@ -210,7 +222,8 @@ drop_private_connection (void) } static void -teardown (void) +teardown (Fixture *f, + gconstpointer data) { tp_tests_assert_last_unref (&f->cd_service); tp_tests_assert_last_unref (&f->dbus_daemon); @@ -219,10 +232,17 @@ teardown (void) g_test_dbus_down (f->test_dbus); tp_tests_assert_last_unref (&f->test_dbus); + + tp_intset_destroy (freed_user_data); + tp_intset_destroy (method_ok); + tp_intset_destroy (method_error); + + global_fixture = NULL; } static TpProxy * -new_proxy (int which) +new_proxy (Fixture *f, + int which) { TpDBusDaemon *local_dbus_daemon; @@ -238,39 +258,24 @@ new_proxy (int which) NULL); } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { - Fixture fixture = { NULL }; GObject *b_stub, *i_stub, *j_stub, *k_stub; GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Because I said so" }; TpProxyPendingCall *pc; guint i; - tp_tests_abort_after (10); - tp_debug_set_flags ("all"); - - freed_user_data = tp_intset_sized_new (N_PROXIES); - method_ok = tp_intset_sized_new (N_PROXIES); - method_error = tp_intset_sized_new (N_PROXIES); - - /* it's on the stack, but it's valid until we leave main(), which will - * do for now... one day this test should use GTest, but this might - * not be that day */ - f = &fixture; - - setup (); - g_message ("Creating proxies"); for (i = TEST_A; i <= TEST_K; i++) { - f->proxies[i] = new_proxy (i); + f->proxies[i] = new_proxy (f, i); g_message ("%c=%p", 'a' + i, f->proxies[i]); } - f->proxies[TEST_Z] = new_proxy (TEST_Z); + f->proxies[TEST_Z] = new_proxy (f, TEST_Z); g_message ("z=%p", f->proxies[TEST_Z]); /* a survives */ @@ -454,7 +459,7 @@ main (int argc, MYASSERT (!tp_intset_is_member (method_error, TEST_Z), ""); g_message ("Dropping private D-Bus connection"); - drop_private_connection (); + drop_private_connection (f); /* the callback will be queued (to avoid reentrancy), so we don't get it * until the main loop runs */ MYASSERT (!tp_intset_is_member (freed_user_data, TEST_F), ""); @@ -540,12 +545,16 @@ main (int argc, MYASSERT (tp_intset_is_member (freed_user_data, TEST_J), ""); MYASSERT (tp_intset_is_member (freed_user_data, TEST_K), ""); MYASSERT (tp_intset_is_member (freed_user_data, TEST_Z), ""); +} - tp_intset_destroy (freed_user_data); - tp_intset_destroy (method_ok); - tp_intset_destroy (method_error); +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - teardown (); + g_test_add ("/call-cancellation", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/disconnection.c b/tests/dbus/disconnection.c index 890158c4a..9dc3db090 100644 --- a/tests/dbus/disconnection.c +++ b/tests/dbus/disconnection.c @@ -21,7 +21,7 @@ /* just for convenience, since it's used a lot */ #define PTR(ui) GUINT_TO_POINTER(ui) -/* state tracking */ +/* state tracking (FIXME: move this into the Fixture) */ static TpIntset *caught_signal; static TpIntset *freed_user_data; @@ -49,7 +49,8 @@ typedef struct { TpDBusDaemon *private_dbus_daemon; } Fixture; -static Fixture *f; +/* FIXME: it would be better not to need this */ +static Fixture *global_fixture; static void h_stub_destroyed (gpointer data, @@ -89,6 +90,7 @@ signal_cb (TpProxy *proxy, gpointer user_data, GObject *weak_object) { + Fixture *f = global_fixture; guint which = GPOINTER_TO_UINT (user_data); TpProxy *want_proxy = NULL; GObject *want_object = NULL; @@ -131,8 +133,17 @@ set_freed (gpointer user_data) } static void -setup (void) +setup (Fixture *f, + gconstpointer user_data) { + global_fixture = f; + + tp_tests_abort_after (10); + tp_debug_set_flags ("all"); + + freed_user_data = tp_intset_sized_new (N_PROXIES); + caught_signal = tp_intset_sized_new (N_PROXIES); + g_test_dbus_unset (); f->test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); g_test_dbus_up (f->test_dbus); @@ -159,7 +170,7 @@ setup (void) } static void -drop_private_connection (void) +drop_private_connection (Fixture *f) { dbus_g_connection_unref (f->private_dbusglib); f->private_dbusglib = NULL; @@ -169,7 +180,8 @@ drop_private_connection (void) } static void -teardown (void) +teardown (Fixture *f, + gconstpointer data) { tp_tests_assert_last_unref (&f->cd_service); tp_tests_assert_last_unref (&f->dbus_daemon); @@ -178,10 +190,16 @@ teardown (void) g_test_dbus_down (f->test_dbus); tp_tests_assert_last_unref (&f->test_dbus); + + tp_intset_destroy (freed_user_data); + tp_intset_destroy (caught_signal); + + global_fixture = NULL; } static TpProxy * -new_proxy (int which) +new_proxy (Fixture *f, + int which) { TpDBusDaemon *local_dbus_daemon; @@ -197,11 +215,10 @@ new_proxy (int which) NULL); } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { - Fixture fixture = { NULL }; GObject *stub; GError *error_out = NULL; GError err = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Because I said so" }; @@ -210,28 +227,15 @@ main (int argc, GHashTable *empty_asv; int i; - tp_tests_abort_after (10); - tp_debug_set_flags ("all"); - - freed_user_data = tp_intset_sized_new (N_PROXIES); - caught_signal = tp_intset_sized_new (N_PROXIES); - - /* it's on the stack, but it's valid until we leave main(), which will - * do for now... one day this test should use GTest, but this might - * not be that day */ - f = &fixture; - - setup (); - g_message ("Creating proxies"); for (i = TEST_A; i <= TEST_H; i++) { - f->proxies[i] = new_proxy (i); + f->proxies[i] = new_proxy (f, i); g_message ("%c=%p", 'a' + i, f->proxies[i]); } - f->proxies[TEST_Z] = new_proxy (TEST_Z); + f->proxies[TEST_Z] = new_proxy (f, TEST_Z); g_message ("z=%p", f->proxies[TEST_Z]); /* a survives */ @@ -344,7 +348,7 @@ main (int argc, g_assert_no_error (error_out); g_message ("Dropping private D-Bus connection"); - drop_private_connection (); + drop_private_connection (f); g_message ("Emitting signal"); empty_asv = tp_asv_new (NULL, NULL); @@ -429,11 +433,16 @@ main (int argc, MYASSERT (tp_intset_is_member (freed_user_data, TEST_G), ""); MYASSERT (tp_intset_is_member (freed_user_data, TEST_H), ""); MYASSERT (tp_intset_is_member (freed_user_data, TEST_Z), ""); +} - tp_intset_destroy (freed_user_data); - tp_intset_destroy (caught_signal); +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - teardown (); + g_test_add ("/disconnection", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/example-no-protocols.c b/tests/dbus/example-no-protocols.c index b63919adf..04ca46761 100644 --- a/tests/dbus/example-no-protocols.c +++ b/tests/dbus/example-no-protocols.c @@ -13,6 +13,16 @@ #include "tests/lib/util.h" +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + static void prepare (void) { @@ -90,9 +100,9 @@ early_cm_exited (TpConnectionManager *cm, *saw_exited = TRUE; } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { GMainLoop *mainloop; TpConnectionManager *early_cm, *late_cm; @@ -173,6 +183,22 @@ main (int argc, g_test_dbus_down (test_dbus); tp_tests_assert_last_unref (&test_dbus); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/example-no-protocols", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/finalized-in-invalidated-handler.c b/tests/dbus/finalized-in-invalidated-handler.c index 298ffd02e..6836da41a 100644 --- a/tests/dbus/finalized-in-invalidated-handler.c +++ b/tests/dbus/finalized-in-invalidated-handler.c @@ -21,6 +21,16 @@ #include "tests/lib/echo-chan.h" #include "tests/lib/util.h" +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + static GMainLoop *mainloop; gboolean shutdown_finished = FALSE; gboolean invalidated = FALSE; @@ -66,9 +76,9 @@ on_shutdown_finished (TpBaseConnection *base_conn, g_main_loop_quit (mainloop); } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { TpTestsSimpleConnection *service_conn; TpBaseConnection *service_conn_as_base; @@ -140,6 +150,23 @@ main (int argc, g_test_dbus_down (test_dbus); tp_tests_assert_last_unref (&test_dbus); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/finalized-in-invalidated-handler", + Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/group-mixin.c b/tests/dbus/group-mixin.c index 2d00d7b8b..f6c9ba8ea 100644 --- a/tests/dbus/group-mixin.c +++ b/tests/dbus/group-mixin.c @@ -27,6 +27,16 @@ #include "tests/lib/textchan-group.h" #include "tests/lib/util.h" +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + #define IDENTIFIER "them@example.org" static GMainLoop *mainloop; @@ -488,9 +498,9 @@ test_group_mixin (void) in_the_desert (); } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { TpTestsSimpleConnection *service_conn; TpBaseConnection *service_conn_as_base; @@ -555,6 +565,22 @@ main (int argc, g_test_dbus_down (test_dbus); tp_tests_assert_last_unref (&test_dbus); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/group-mixin", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/handle-repo.c b/tests/dbus/handle-repo.c index d7214d216..cda9940a8 100644 --- a/tests/dbus/handle-repo.c +++ b/tests/dbus/handle-repo.c @@ -12,8 +12,13 @@ #include "tests/lib/util.h" +typedef struct { + GTestDBus *test_dbus; +} Fixture; + static void -test_handles (void) +test_handles (Fixture *f, + gconstpointer data) { TpDBusDaemon *bus_daemon = tp_tests_dbus_daemon_dup_or_die (); TpHandleRepoIface *tp_repo = NULL; @@ -73,20 +78,33 @@ test_handles (void) g_object_unref (bus_daemon); } -int main (int argc, char **argv) +static void +setup (Fixture *f, + gconstpointer data) { - GTestDBus *test_dbus; - tp_tests_abort_after (10); g_test_dbus_unset (); - test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); - g_test_dbus_up (test_dbus); + f->test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); + g_test_dbus_up (f->test_dbus); +} - test_handles (); +static void +teardown (Fixture *f, + gconstpointer data) +{ + g_test_dbus_down (f->test_dbus); + tp_tests_assert_last_unref (&f->test_dbus); +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - g_test_dbus_down (test_dbus); - tp_tests_assert_last_unref (&test_dbus); + g_test_add ("/handle-repo", Fixture, NULL, setup, test_handles, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/handle-set.c b/tests/dbus/handle-set.c index c1782f191..4aa98c807 100644 --- a/tests/dbus/handle-set.c +++ b/tests/dbus/handle-set.c @@ -13,9 +13,19 @@ #include "tests/lib/myassert.h" #include "tests/lib/util.h" -int -main (int argc, - char **argv) +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +static void +test (Fixture *f, + gconstpointer data) { TpHandleRepoIface *repo = NULL; TpHandleSet *set = NULL; @@ -130,6 +140,22 @@ main (int argc, g_test_dbus_down (test_dbus); tp_tests_assert_last_unref (&test_dbus); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/handle-set", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c index cc1ccb7d8..6709355ec 100644 --- a/tests/dbus/message-mixin.c +++ b/tests/dbus/message-mixin.c @@ -28,6 +28,16 @@ #include "tests/lib/myassert.h" #include "tests/lib/util.h" +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + static guint message_received_count = 0; static guint last_message_received_sender = 0; static guint last_message_received_type = 0; @@ -144,9 +154,9 @@ on_messages_removed (TpChannel *chan, } } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { ExampleEcho2ConnectionManager *service_cm; TpBaseConnectionManager *service_cm_as_base; @@ -791,6 +801,22 @@ main (int argc, g_test_dbus_down (test_dbus); tp_tests_assert_last_unref (&test_dbus); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/message-mixin", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/run-test.sh.in b/tests/dbus/run-test.sh.in index c9ecb6cb5..60c07728b 100644 --- a/tests/dbus/run-test.sh.in +++ b/tests/dbus/run-test.sh.in @@ -1,13 +1,25 @@ #!/bin/sh +set -e + script_fullname=`readlink -e "@tpglibtestsdir@/run-test.sh"` if [ `readlink -e "$0"` != "$script_fullname" ] ; then - echo "This script is meant to be installed at $script_fullname" + echo "This script is meant to be installed at $script_fullname" >&2 exit 1 fi -XDG_DATA_DIRS=@tpglibtestsdir@:$XDG_DATA_DIRS +tmp="`mktemp -d`" + +XDG_CACHE_HOME="$tmp/cache" +export XDG_CACHE_HOME +XDG_CONFIG_HOME="$tmp/config" +export XDG_CONFIG_HOME +XDG_DATA_HOME="$tmp/localshare" +export XDG_DATA_HOME +XDG_DATA_DIRS=@tpglibtestsdir@:${XDG_DATA_DIRS:-/usr/local/share:/usr/share} export XDG_DATA_DIRS +XDG_RUNTIME_DIR="$tmp" +export XDG_RUNTIME_DIR G_SLICE=debug-blocks export G_SLICE G_DEBUG=fatal_warnings,fatal_criticals @@ -23,15 +35,16 @@ export GSETTINGS_BACKEND DBUS_SESSION_BUS_ADDRESS=this-is-clearly-not-valid export DBUS_SESSION_BUS_ADDRESS + if [ -n "$1" ] ; then - list="$1" + testname="$1" + shift else - echo "Usage: $0 testname" + echo "Usage: $0 testname" >&2 exit 1 fi -for i in $list ; do - echo "Testing $i" - @tpglibtestsdir@/tools/test-wrapper.sh @tpglibtestsdir@/$i -done - +e=0 +"@tpglibtestsdir@/$testname" --tap "$@" || e=$? +rm -fr "$tmp" +exit $e diff --git a/tests/dbus/self-presence.c b/tests/dbus/self-presence.c index 24c072735..971006a8d 100644 --- a/tests/dbus/self-presence.c +++ b/tests/dbus/self-presence.c @@ -24,6 +24,16 @@ #include "tests/lib/myassert.h" #include "tests/lib/util.h" +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + static void test_presence (TpTestsContactsConnection *service_conn, TpConnection *client_conn) @@ -115,9 +125,9 @@ test_presence (TpTestsContactsConnection *service_conn, g_free (value); } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { TpDBusDaemon *dbus; TpTestsContactsConnection *service_conn; @@ -206,6 +216,22 @@ main (int argc, g_test_dbus_down (test_dbus); tp_tests_assert_last_unref (&test_dbus); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/self-presence", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/dbus/text-respawn.c b/tests/dbus/text-respawn.c index e31be5780..8b4cc1e51 100644 --- a/tests/dbus/text-respawn.c +++ b/tests/dbus/text-respawn.c @@ -25,6 +25,16 @@ #include "tests/lib/myassert.h" #include "tests/lib/util.h" +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + static guint received_count = 0; static guint last_received_id = 0; static gint64 last_received_time = 0; @@ -129,9 +139,9 @@ build_message (TpChannelTextMessageType type, return out; } -int -main (int argc, - char **argv) +static void +test (Fixture *f, + gconstpointer data) { TpTestsEchoConnection *service_conn; TpBaseConnection *service_conn_as_base; @@ -349,6 +359,22 @@ main (int argc, g_test_dbus_down (test_dbus); tp_tests_assert_last_unref (&test_dbus); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/text-respawn", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/debug-domain.c b/tests/debug-domain.c index 8054691ac..e35adc7e0 100644 --- a/tests/debug-domain.c +++ b/tests/debug-domain.c @@ -44,7 +44,19 @@ handler (const gchar *log_domain, g_strfreev (parts); } -int main (int argc, char **argv) +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +static void +test (Fixture *f, + gconstpointer data) { TestItem i; @@ -57,6 +69,22 @@ int main (int argc, char **argv) i = items[item]; _tp_log (G_LOG_LEVEL_DEBUG, i.flag, "foo"); } +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/debug-domain", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/gnio-util.c b/tests/gnio-util.c index 1a5bd1dda..107d96cc0 100644 --- a/tests/gnio-util.c +++ b/tests/gnio-util.c @@ -16,6 +16,17 @@ #include <telepathy-glib/util.h> #include <telepathy-glib/gtypes.h> +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ + dbus_g_type_specialized_init (); +} + #define IPV4_ADDR "127.0.1.1" #define IPV6_ADDR "::1" #define UNIX_ADDR "/tmp/socket/test/123456" @@ -24,7 +35,8 @@ #define PORT 41414 static void -test_variant_to_sockaddr_ipv4 (void) +test_variant_to_sockaddr_ipv4 (Fixture *f, + gconstpointer data) { GSocketAddress *sockaddr; GInetSocketAddress *inetaddr; @@ -55,7 +67,8 @@ test_variant_to_sockaddr_ipv4 (void) } static void -test_variant_to_sockaddr_ipv6 (void) +test_variant_to_sockaddr_ipv6 (Fixture *f, + gconstpointer data) { GSocketAddress *sockaddr; GInetSocketAddress *inetaddr; @@ -86,7 +99,8 @@ test_variant_to_sockaddr_ipv6 (void) } static void -test_sockaddr_to_variant_ipv4 (void) +test_sockaddr_to_variant_ipv4 (Fixture *f, + gconstpointer data) { GInetAddress *hostaddr = g_inet_address_new_from_string (IPV4_ADDR); GSocketAddress *sockaddr = g_inet_socket_address_new (hostaddr, PORT); @@ -133,7 +147,8 @@ test_sockaddr_to_variant_ipv4 (void) } static void -test_sockaddr_to_variant_ipv6 (void) +test_sockaddr_to_variant_ipv6 (Fixture *f, + gconstpointer data) { GInetAddress *hostaddr = g_inet_address_new_from_string (IPV6_ADDR); GSocketAddress *sockaddr = g_inet_socket_address_new (hostaddr, PORT); @@ -181,7 +196,8 @@ test_sockaddr_to_variant_ipv6 (void) #ifdef HAVE_GIO_UNIX static void -test_variant_to_sockaddr_unix (void) +test_variant_to_sockaddr_unix (Fixture *f, + gconstpointer data) { GArray *array; GValue value = { 0, }; @@ -214,7 +230,8 @@ test_variant_to_sockaddr_unix (void) } static void -test_variant_to_sockaddr_abstract_unix (void) +test_variant_to_sockaddr_abstract_unix (Fixture *f, + gconstpointer data) { GArray *array; GValue value = { 0, }; @@ -249,7 +266,8 @@ test_variant_to_sockaddr_abstract_unix (void) } static void -test_sockaddr_to_variant_unix (void) +test_sockaddr_to_variant_unix (Fixture *f, + gconstpointer data) { GSocketAddress *sockaddr = g_unix_socket_address_new (UNIX_ADDR); GValue *variant; @@ -273,7 +291,8 @@ test_sockaddr_to_variant_unix (void) } static void -test_sockaddr_to_variant_abstract_unix (void) +test_sockaddr_to_variant_abstract_unix (Fixture *f, + gconstpointer data) { GSocketAddress *sockaddr = g_unix_socket_address_new_with_type ( ABST_ADDR, ABST_ADDR_LEN, G_UNIX_SOCKET_ADDRESS_ABSTRACT); @@ -299,21 +318,38 @@ test_sockaddr_to_variant_abstract_unix (void) } #endif /* HAVE_GIO_UNIX */ +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + int -main (int argc, char **argv) +main (int argc, + char **argv) { - dbus_g_type_specialized_init (); + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/variant-to-sockaddr/ipv4", Fixture, NULL, + setup, test_variant_to_sockaddr_ipv4, teardown); + g_test_add ("/variant-to-sockaddr/ipv6", Fixture, NULL, + setup, test_variant_to_sockaddr_ipv6, teardown); + g_test_add ("/sockaddr-to-variant/ipv4", Fixture, NULL, + setup, test_sockaddr_to_variant_ipv4, teardown); + g_test_add ("/sockaddr-to-variant/ipv6", Fixture, NULL, + setup, test_sockaddr_to_variant_ipv6, teardown); - test_variant_to_sockaddr_ipv4 (); - test_variant_to_sockaddr_ipv6 (); - test_sockaddr_to_variant_ipv4 (); - test_sockaddr_to_variant_ipv6 (); #ifdef HAVE_GIO_UNIX - test_variant_to_sockaddr_unix (); - test_variant_to_sockaddr_abstract_unix (); - test_sockaddr_to_variant_unix (); - test_sockaddr_to_variant_abstract_unix (); + g_test_add ("/variant-to-sockaddr/unix", Fixture, NULL, + setup, test_variant_to_sockaddr_unix, teardown); + g_test_add ("/variant-to-sockaddr/abstract-unix", Fixture, NULL, + setup, test_variant_to_sockaddr_abstract_unix, teardown); + g_test_add ("/sockaddr-to-variant/unix", Fixture, NULL, + setup, test_sockaddr_to_variant_unix, teardown); + g_test_add ("/sockaddr-to-variant/abstract-unix", Fixture, NULL, + setup, test_sockaddr_to_variant_abstract_unix, teardown); #endif /* HAVE_GIO_UNIX */ - return 0; + return g_test_run (); } diff --git a/tests/heap.c b/tests/heap.c index 79539c8b4..30654d75d 100644 --- a/tests/heap.c +++ b/tests/heap.c @@ -12,9 +12,19 @@ static gint comparator_fn (gconstpointer a, gconstpointer b) return (a < b) ? -1 : (a == b) ? 0 : 1; } -int -main (int argc, - char **argv) +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +static void +test (Fixture *f, + gconstpointer data) { TpHeap *heap = tp_heap_new (comparator_fn, NULL); guint prev = 0; @@ -36,6 +46,22 @@ main (int argc, } tp_heap_destroy (heap); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/heap", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/internal-debug.c b/tests/internal-debug.c index d0b3249a7..5a04cbd5d 100644 --- a/tests/internal-debug.c +++ b/tests/internal-debug.c @@ -58,13 +58,41 @@ test_debugging_again (void) g_assert (DEBUGGING == 1); } -int -main (int argc, char **argv) +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +static void +test (Fixture *f, + gconstpointer data) { /* We enable debugging for IM, but not for the connection. */ tp_debug_set_flags ("im"); test_debugging (); test_not_debugging (); test_debugging_again (); - return 0; +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/internal-debug", Fixture, NULL, setup, test, teardown); + + return g_test_run (); } diff --git a/tests/intset.c b/tests/intset.c index 7cc3bbc0b..662ee4bac 100644 --- a/tests/intset.c +++ b/tests/intset.c @@ -4,6 +4,16 @@ #include <telepathy-glib/intset.h> #include <telepathy-glib/util.h> +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + static void iterate_fast (TpIntset *set) { @@ -28,7 +38,10 @@ test_iteration (TpIntset *set) iterate_fast (set); } -int main (int argc, char **argv) +/* FIXME: split this up into sensible test-cases */ +static void +test (Fixture *f, + gconstpointer data) { TpIntset *set1 = tp_intset_new (); TpIntset *a, *b, *copy; @@ -200,6 +213,22 @@ int main (int argc, char **argv) a = NULL; value = NULL; b = NULL; +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/intset", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/logger/Makefile.am b/tests/logger/Makefile.am index ef61231dd..938187d14 100644 --- a/tests/logger/Makefile.am +++ b/tests/logger/Makefile.am @@ -29,7 +29,10 @@ AM_CFLAGS = \ AM_TESTS_ENVIRONMENT = \ G_DEBUG=fatal-warnings,fatal-criticals \ TPL_TEST_MODE=true \ + XDG_CACHE_HOME=@abs_builddir@/tmp-cache \ + XDG_CONFIG_HOME=@abs_builddir@/tmp-config \ XDG_DATA_HOME=@abs_top_srcdir@/tests/logger/logs \ + XDG_RUNTIME_DIR=@abs_builddir@/tmp-runtime \ $(NULL) check-valgrind: $(TESTS) @@ -52,3 +55,6 @@ check_c_sources = \ include $(top_srcdir)/tools/check-coding-style.mk check-local: check-coding-style + +clean-local: + rm -fr tmp-cache tmp-config tmp-runtime diff --git a/tests/logger/dbus/Makefile.am b/tests/logger/dbus/Makefile.am index 35ddb5335..c322cea66 100644 --- a/tests/logger/dbus/Makefile.am +++ b/tests/logger/dbus/Makefile.am @@ -45,8 +45,11 @@ AM_TESTS_ENVIRONMENT = \ TPL_TEST_LOG_DIR=@abs_top_srcdir@/tests/logger/logs \ HOME=@abs_top_srcdir@/tests/logger/logs \ GSETTINGS_SCHEMA_DIR=@abs_srcdir@/data \ + XDG_CACHE_HOME=@abs_builddir@/tmp-cache \ + XDG_CONFIG_HOME=@abs_builddir@/tmp-config \ XDG_DATA_HOME=@abs_top_srcdir@/tests/logger/logs \ XDG_DATA_DIRS=@abs_srcdir@ \ + XDG_RUNTIME_DIR=@abs_builddir@/tmp-runtime \ G_SLICE=debug-blocks \ TPL_DEBUG=all \ G_DEBUG=fatal_warnings,fatal_criticals$(maybe_gc_friendly) \ @@ -73,3 +76,6 @@ CLEANFILES = $(BUILT_SOURCES) distclean-local: rm -f capture-*.log rm -rf _gen + +clean-local: + rm -fr tmp-cache tmp-config tmp-data tmp-runtime diff --git a/tests/logger/test-tpl-conf.c b/tests/logger/test-tpl-conf.c index cd7c8d33f..e9c8c4c13 100644 --- a/tests/logger/test-tpl-conf.c +++ b/tests/logger/test-tpl-conf.c @@ -5,8 +5,19 @@ #include <telepathy-logger/conf-internal.h> #include <telepathy-logger/debug.h> -int -main (int argc, char **argv) +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +static void +test (Fixture *f, + gconstpointer data) { TplConf *conf, *conf2; @@ -29,7 +40,22 @@ main (int argc, char **argv) /* proper disposal for the singleton when no references are present */ g_object_unref (conf); +} - return 0; +static void +teardown (Fixture *f, + gconstpointer data) +{ } +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/tpl-conf", Fixture, NULL, setup, test, teardown); + + return g_test_run (); +} diff --git a/tests/util-cxx.cpp b/tests/util-cxx.cpp index b8b822e36..42213c08a 100644 --- a/tests/util-cxx.cpp +++ b/tests/util-cxx.cpp @@ -23,7 +23,19 @@ #include <gio/gio.h> #include <telepathy-glib/util.h> -int main (int argc, char **argv) +typedef struct { + int dummy; +} Fixture; + +extern "C" void +setup (Fixture *f, + gconstpointer data) +{ +} + +extern "C" void +test (Fixture *f, + gconstpointer data) { GObject *o; GHashTable *h; @@ -36,6 +48,22 @@ int main (int argc, char **argv) h = g_hash_table_new (NULL, NULL); tp_clear_boxed (G_TYPE_HASH_TABLE, &h); +} + +extern "C" void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/util/cxx", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } diff --git a/tests/util.c b/tests/util.c index 3b0b7c952..cd359ca54 100644 --- a/tests/util.c +++ b/tests/util.c @@ -6,6 +6,16 @@ #include <telepathy-glib/util.h> +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + void test_strv_contains (void); void @@ -292,7 +302,10 @@ test_utf8_make_valid (void) } } -int main (int argc, char **argv) +/* FIXME: split this up into sensible test-cases */ +static void +test (Fixture *f, + gconstpointer data) { GPtrArray *ptrarray; gchar *string; @@ -332,6 +345,22 @@ int main (int argc, char **argv) test_value_array_build (); test_utf8_make_valid (); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/util", Fixture, NULL, setup, test, teardown); - return 0; + return g_test_run (); } |