[Telepathy-commits] [telepathy-glib/master] tests: remove the option to carry on after a failure

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Mar 17 07:18:29 PDT 2009


Instead of raising a g_critical, attempting to continue, and returning 1
later, we might as well just crash out. This is consistent with GTest,
too.
---
 tests/asv.c                                     |   10 +---------
 tests/dbus/channel-introspect.c                 |    9 +--------
 tests/dbus/cli-group.c                          |    9 +--------
 tests/dbus/connection-bug-18845.c               |    9 +--------
 tests/dbus/connection-error.c                   |   10 +---------
 tests/dbus/connection-getinterfaces-failure.c   |    9 +--------
 tests/dbus/connection-handles.c                 |   10 +---------
 tests/dbus/connection-inject-bug16307.c         |    9 +--------
 tests/dbus/connection.c                         |    9 +--------
 tests/dbus/contacts-bug-19101.c                 |   10 +---------
 tests/dbus/contacts-mixin.c                     |   10 +---------
 tests/dbus/contacts.c                           |   10 +---------
 tests/dbus/finalized-in-invalidated-handler.c   |    9 +--------
 tests/dbus/group-mixin.c                        |    9 +--------
 tests/dbus/handle-set.c                         |   10 +---------
 tests/dbus/invalidated-while-invoking-signals.c |    9 +--------
 tests/dbus/message-mixin.c                      |   10 +---------
 tests/dbus/properties.c                         |   10 +---------
 tests/dbus/self-handle.c                        |   10 +---------
 tests/dbus/self-presence.c                      |   10 +---------
 tests/dbus/test-call-cancellation.c             |    9 +--------
 tests/dbus/test-dbus.c                          |    9 +--------
 tests/dbus/test-disconnection.c                 |   19 ++++---------------
 tests/dbus/text-mixin.c                         |   10 +---------
 tests/dbus/text-respawn.c                       |   10 +---------
 tests/dbus/unsupported-interface.c              |    9 +--------
 tests/lib/myassert.h                            |    6 +-----
 27 files changed, 30 insertions(+), 233 deletions(-)

diff --git a/tests/asv.c b/tests/asv.c
index 18b9bd0..545bb98 100644
--- a/tests/asv.c
+++ b/tests/asv.c
@@ -7,14 +7,6 @@
 
 #include "tests/lib/myassert.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 int main (int argc, char **argv)
 {
   GHashTable *hash;
@@ -683,5 +675,5 @@ int main (int argc, char **argv)
 
   g_hash_table_destroy (hash);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/channel-introspect.c b/tests/dbus/channel-introspect.c
index 1487ba1..741ad60 100644
--- a/tests/dbus/channel-introspect.c
+++ b/tests/dbus/channel-introspect.c
@@ -22,17 +22,10 @@
 
 #define IDENTIFIER "them at example.org"
 
-static int fail = 0;
 static GError *invalidated = NULL;
 static GMainLoop *mainloop;
 
 static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
-static void
 channel_ready (TpChannel *channel,
                const GError *error,
                gpointer user_data)
@@ -479,5 +472,5 @@ main (int argc,
   g_free (chan_path);
   g_free (props_chan_path);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/cli-group.c b/tests/dbus/cli-group.c
index 186ef89..297a8cd 100644
--- a/tests/dbus/cli-group.c
+++ b/tests/dbus/cli-group.c
@@ -24,7 +24,6 @@
 #include "tests/lib/textchan-group.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
 static GMainLoop *mainloop;
 SimpleConnection *service_conn;
 gchar *conn_path;
@@ -38,12 +37,6 @@ TpChannelGroupChangeReason expected_reason = TP_CHANNEL_GROUP_CHANGE_REASON_NONE
 gboolean expecting_invalidated = FALSE;
 
 static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
-static void
 group_members_changed_cb (TpChannel *chan_,
                           gchar *message,
                           GArray *added,
@@ -462,5 +455,5 @@ main (int argc,
   g_free (name);
   g_free (conn_path);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/connection-bug-18845.c b/tests/dbus/connection-bug-18845.c
index 2120c39..2e7f2b2 100644
--- a/tests/dbus/connection-bug-18845.c
+++ b/tests/dbus/connection-bug-18845.c
@@ -17,15 +17,8 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/simple-conn.h"
 
-static int fail = 0;
 static GMainLoop *mainloop;
 
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static GError invalidated_for_test = { 0, TP_ERROR_PERMISSION_DENIED,
       "No connection for you!" };
 
@@ -126,5 +119,5 @@ main (int argc,
   g_object_unref (dbus);
   g_main_loop_unref (mainloop);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/connection-error.c b/tests/dbus/connection-error.c
index 83f2e63..fc12cdc 100644
--- a/tests/dbus/connection-error.c
+++ b/tests/dbus/connection-error.c
@@ -17,14 +17,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/simple-conn.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static int connection_errors;
 
 static void
@@ -169,5 +161,5 @@ main (int argc,
   g_object_unref (dbus);
   g_main_loop_unref (mainloop);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/connection-getinterfaces-failure.c b/tests/dbus/connection-getinterfaces-failure.c
index 7edca2a..ae63b97 100644
--- a/tests/dbus/connection-getinterfaces-failure.c
+++ b/tests/dbus/connection-getinterfaces-failure.c
@@ -59,16 +59,9 @@ bug15306_conn_iface_init (gpointer g_iface,
 #undef IMPLEMENT
 }
 
-static int fail = 0;
 static GMainLoop *mainloop;
 
 static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
-static void
 on_status_changed (TpConnection *connection,
                    guint status,
                    guint reason,
@@ -141,5 +134,5 @@ main (int argc,
   g_free (name);
   g_free (conn_path);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/connection-handles.c b/tests/dbus/connection-handles.c
index 3c60168..e9dd69c 100644
--- a/tests/dbus/connection-handles.c
+++ b/tests/dbus/connection-handles.c
@@ -23,14 +23,6 @@
 #include "tests/lib/simple-conn.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 typedef struct {
     GMainLoop *loop;
     GError *error /* initialized to 0 */;
@@ -358,5 +350,5 @@ main (int argc,
 
   g_object_unref (dbus);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/connection-inject-bug16307.c b/tests/dbus/connection-inject-bug16307.c
index da63ebe..93129fc 100644
--- a/tests/dbus/connection-inject-bug16307.c
+++ b/tests/dbus/connection-inject-bug16307.c
@@ -16,15 +16,8 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/bug16307-conn.h"
 
-static int fail = 0;
 static GMainLoop *mainloop;
 
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 typedef struct {
     gboolean ready;
     GError *error /* initialized to NULL statically */;
@@ -84,5 +77,5 @@ main (int argc,
   g_object_unref (dbus);
   g_main_loop_unref (mainloop);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/connection.c b/tests/dbus/connection.c
index d04bba2..dcd8604 100644
--- a/tests/dbus/connection.c
+++ b/tests/dbus/connection.c
@@ -17,15 +17,8 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/simple-conn.h"
 
-static int fail = 0;
 static GMainLoop *mainloop;
 
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static GError invalidated_for_test = { 0, TP_ERROR_PERMISSION_DENIED,
       "No connection for you!" };
 
@@ -240,5 +233,5 @@ main (int argc,
   g_object_unref (dbus);
   g_main_loop_unref (mainloop);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/contacts-bug-19101.c b/tests/dbus/contacts-bug-19101.c
index 50c1109..85625dc 100644
--- a/tests/dbus/contacts-bug-19101.c
+++ b/tests/dbus/contacts-bug-19101.c
@@ -10,14 +10,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 typedef struct {
     GMainLoop *loop;
     GError *error /* initialized to 0 */;
@@ -195,5 +187,5 @@ main (int argc,
 
   g_object_unref (dbus);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/contacts-mixin.c b/tests/dbus/contacts-mixin.c
index 7ce9b4e..4f66b12 100644
--- a/tests/dbus/contacts-mixin.c
+++ b/tests/dbus/contacts-mixin.c
@@ -18,14 +18,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static void
 test_no_features (ContactsConnection *service_conn,
                   TpConnection *client_conn,
@@ -223,5 +215,5 @@ main (int argc,
   g_object_unref (dbus);
   g_array_free (handles, TRUE);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c
index d297143..0d93423 100644
--- a/tests/dbus/contacts.c
+++ b/tests/dbus/contacts.c
@@ -25,14 +25,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 typedef struct {
     GMainLoop *loop;
     GError *error /* initialized to 0 */;
@@ -989,5 +981,5 @@ main (int argc,
 
   g_object_unref (dbus);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/finalized-in-invalidated-handler.c b/tests/dbus/finalized-in-invalidated-handler.c
index dfd3650..8dd1c17 100644
--- a/tests/dbus/finalized-in-invalidated-handler.c
+++ b/tests/dbus/finalized-in-invalidated-handler.c
@@ -18,16 +18,9 @@
 #include "tests/lib/simple-conn.h"
 #include "tests/lib/textchan-null.h"
 
-static int fail = 0;
 static GMainLoop *mainloop;
 
 static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
-static void
 on_invalidated (TpChannel *chan,
                 guint domain,
                 gint code,
@@ -150,5 +143,5 @@ main (int argc,
   g_free (conn_path);
   g_free (chan_path);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/group-mixin.c b/tests/dbus/group-mixin.c
index 4511bcc..d56977e 100644
--- a/tests/dbus/group-mixin.c
+++ b/tests/dbus/group-mixin.c
@@ -23,7 +23,6 @@
 
 #define IDENTIFIER "them at example.org"
 
-static int fail = 0;
 static GMainLoop *mainloop;
 TestTextChannelGroup *service_chan;
 TpChannel *chan = NULL;
@@ -42,12 +41,6 @@ static TpChannelGroupChangeReason expected_reason;
 static diff_checker expected_diffs;
 
 static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
-static void
 expect_signals (const gchar *message,
                 TpHandle actor,
                 TpChannelGroupChangeReason reason,
@@ -601,5 +594,5 @@ main (int argc,
   g_free (conn_path);
   g_free (chan_path);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/handle-set.c b/tests/dbus/handle-set.c
index f908c46..eebc840 100644
--- a/tests/dbus/handle-set.c
+++ b/tests/dbus/handle-set.c
@@ -10,14 +10,6 @@
 
 #include "tests/lib/myassert.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 int
 main (int argc,
       char **argv)
@@ -116,5 +108,5 @@ main (int argc,
 
   g_object_unref (G_OBJECT (repo));
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/invalidated-while-invoking-signals.c b/tests/dbus/invalidated-while-invoking-signals.c
index b7c18a7..009668b 100644
--- a/tests/dbus/invalidated-while-invoking-signals.c
+++ b/tests/dbus/invalidated-while-invoking-signals.c
@@ -16,16 +16,9 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/simple-conn.h"
 
-static int fail = 0;
 static GMainLoop *mainloop;
 
 static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
-static void
 on_status_changed (TpConnection *connection,
                    guint status,
                    guint reason,
@@ -110,5 +103,5 @@ main (int argc,
   g_free (name);
   g_free (path);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c
index d70e103..13c3438 100644
--- a/tests/dbus/message-mixin.c
+++ b/tests/dbus/message-mixin.c
@@ -19,14 +19,6 @@
 #include "examples/cm/echo-message-parts/conn.h"
 #include "tests/lib/myassert.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static guint received_count = 0;
 static guint last_received_id = 0;
 static guint last_received_sender = 0;
@@ -1092,5 +1084,5 @@ main (int argc,
   g_free (last_received_text);
   g_free (last_message_sent_token);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/properties.c b/tests/dbus/properties.c
index 7f96db7..b2c43d6 100644
--- a/tests/dbus/properties.c
+++ b/tests/dbus/properties.c
@@ -101,14 +101,6 @@ test_properties_class_init (TestPropertiesClass *cls)
       G_STRUCT_OFFSET (TestPropertiesClass, props));
 }
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static void
 print_asv_item (gpointer key,
                 gpointer value,
@@ -191,5 +183,5 @@ main (int argc, char **argv)
   g_object_unref (obj);
   g_object_unref (proxy);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/self-handle.c b/tests/dbus/self-handle.c
index e8f0bb2..6409e3f 100644
--- a/tests/dbus/self-handle.c
+++ b/tests/dbus/self-handle.c
@@ -19,14 +19,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static void
 on_self_handle_changed (TpConnection *client_conn,
                         GParamSpec *param_spec G_GNUC_UNUSED,
@@ -140,5 +132,5 @@ main (int argc,
 
   g_object_unref (dbus);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/self-presence.c b/tests/dbus/self-presence.c
index 0165477..b91bc6f 100644
--- a/tests/dbus/self-presence.c
+++ b/tests/dbus/self-presence.c
@@ -19,14 +19,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static void
 test_simple_presence (ContactsConnection *service_conn,
                       TpConnection *client_conn)
@@ -265,5 +257,5 @@ main (int argc,
 
   g_object_unref (dbus);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/test-call-cancellation.c b/tests/dbus/test-call-cancellation.c
index 8f30065..5f66b45 100644
--- a/tests/dbus/test-call-cancellation.c
+++ b/tests/dbus/test-call-cancellation.c
@@ -29,18 +29,11 @@ static TpDBusDaemon *z;
 static TpIntSet *method_ok;
 static TpIntSet *method_error;
 static TpIntSet *freed_user_data;
-int fail = 0;
 static gpointer copy_of_d;
 static gpointer copy_of_g;
 static gpointer copy_of_h;
 static gpointer copy_of_i;
 
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 enum {
     TEST_A,
     TEST_B,
@@ -475,5 +468,5 @@ main (int argc,
   tp_intset_destroy (method_ok);
   tp_intset_destroy (method_error);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/test-dbus.c b/tests/dbus/test-dbus.c
index 386724f..d8c6ce8 100644
--- a/tests/dbus/test-dbus.c
+++ b/tests/dbus/test-dbus.c
@@ -11,13 +11,6 @@ static TpDBusDaemon *bus;
 static GMainLoop *mainloop;
 static gchar *two = "2", *five = "5";
 static gboolean had_owners = FALSE;
-int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
 
 static void
 noc (TpDBusDaemon *obj,
@@ -250,5 +243,5 @@ main (int argc,
   g_main_loop_unref (mainloop);
   mainloop = NULL;
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/test-disconnection.c b/tests/dbus/test-disconnection.c
index 6ed6df5..b7da4e6 100644
--- a/tests/dbus/test-disconnection.c
+++ b/tests/dbus/test-disconnection.c
@@ -25,13 +25,6 @@ static TpDBusDaemon *h;
 static TpDBusDaemon *z;
 static TpIntSet *caught_signal;
 static TpIntSet *freed_user_data;
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
 
 enum {
     TEST_A,
@@ -84,9 +77,8 @@ prop_changed (TpProxy *proxy,
               gpointer user_data,
               GObject *weak_object)
 {
-  g_critical ("prop_changed called - a signal connection which should have "
+  g_error ("prop_changed called - a signal connection which should have "
       "failed has succeeded. Args: proxy=%p user_data=%p", proxy, user_data);
-  fail = 1;
 }
 
 static void
@@ -97,9 +89,8 @@ dummy_noc (TpDBusDaemon *proxy,
            gpointer user_data,
            GObject *weak_object)
 {
-  g_critical ("dummy_noc called - a signal connection which should have "
+  g_error ("dummy_noc called - a signal connection which should have "
       "failed has succeeded. Args: proxy=%p user_data=%p", proxy, user_data);
-  fail = 1;
 }
 
 static void
@@ -131,10 +122,8 @@ noc (TpDBusDaemon *proxy,
       want_object = (GObject *) a;
       break;
     default:
-      g_critical ("%c (%p) got the signal, which shouldn't have happened",
+      g_error ("%c (%p) got the signal, which shouldn't have happened",
           'a' + which, proxy);
-      fail = 1;
-      return;
     }
 
   g_message ("Expecting proxy %p, weak object %p", want_proxy, want_object);
@@ -382,5 +371,5 @@ main (int argc,
   tp_intset_destroy (freed_user_data);
   tp_intset_destroy (caught_signal);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/text-mixin.c b/tests/dbus/text-mixin.c
index a032d24..7329287 100644
--- a/tests/dbus/text-mixin.c
+++ b/tests/dbus/text-mixin.c
@@ -20,14 +20,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static guint received_count = 0;
 static guint last_received_id = 0;
 static guint last_received_sender = 0;
@@ -327,5 +319,5 @@ main (int argc,
   g_free (last_sent_text);
   g_free (last_received_text);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/text-respawn.c b/tests/dbus/text-respawn.c
index f2b5ee8..d117ed3 100644
--- a/tests/dbus/text-respawn.c
+++ b/tests/dbus/text-respawn.c
@@ -20,14 +20,6 @@
 #include "tests/lib/myassert.h"
 #include "tests/lib/util.h"
 
-static int fail = 0;
-
-static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
 static guint received_count = 0;
 static guint last_received_id = 0;
 static guint last_received_time = 0;
@@ -274,5 +266,5 @@ main (int argc,
   g_free (last_sent_text);
   g_free (last_received_text);
 
-  return fail;
+  return 0;
 }
diff --git a/tests/dbus/unsupported-interface.c b/tests/dbus/unsupported-interface.c
index 51190a9..a3d9955 100644
--- a/tests/dbus/unsupported-interface.c
+++ b/tests/dbus/unsupported-interface.c
@@ -4,19 +4,12 @@
 
 #include "tests/lib/myassert.h"
 
-static int fail = 0;
 static gboolean had_unsupported = FALSE;
 static gboolean had_supported = FALSE;
 static GMainLoop *mainloop = NULL;
 static gboolean freed_user_data[] = { FALSE, FALSE, FALSE, FALSE };
 
 static void
-myassert_failed (void)
-{
-  fail = 1;
-}
-
-static void
 supported_cb (TpDBusDaemon *bus_daemon,
               const gchar **names,
               const GError *error,
@@ -126,5 +119,5 @@ main (int argc,
   MYASSERT (!freed_user_data[2], " (signal connection, supported)");
   MYASSERT (freed_user_data[3], " (signal connection, unsupported)");
 
-  return fail;
+  return 0;
 }
diff --git a/tests/lib/myassert.h b/tests/lib/myassert.h
index 7d67faa..f9f8f81 100644
--- a/tests/lib/myassert.h
+++ b/tests/lib/myassert.h
@@ -4,16 +4,12 @@
 #include <glib.h>
 #include <telepathy-glib/util.h>
 
-/* code using this header must define */
-static void myassert_failed (void);
-
 #define MYASSERT(assertion, extra_format, ...)\
   G_STMT_START {\
       if (!(assertion))\
         {\
-          g_critical ("\n%s:%d: Assertion failed: %s" extra_format,\
+          g_error ("\n%s:%d: Assertion failed: %s" extra_format,\
             __FILE__, __LINE__, #assertion, ##__VA_ARGS__);\
-          myassert_failed ();\
         }\
   } G_STMT_END
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list