From c0c4534f0e2a28a85b71c240e090b8d5d25f8511 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 5 Mar 2012 13:37:26 +0000 Subject: WiP: better diagnostics for all --- tests/dbus/account-manager.c | 2 +- tests/dbus/call-channel.c | 2 +- tests/dbus/channel.c | 2 +- tests/dbus/contacts-bug-19101.c | 2 +- tests/dbus/contacts-slow-path.c | 26 +++++++++++++------------- tests/dbus/contacts.c | 36 ++++++++++++++++++------------------ tests/dbus/handle-repo.c | 2 +- tests/dbus/params-cm.c | 13 +++++++------ tests/debug-domain.c | 6 +++--- tests/gnio-util.c | 2 +- tests/internal-debug.c | 10 +++++----- 11 files changed, 52 insertions(+), 51 deletions(-) diff --git a/tests/dbus/account-manager.c b/tests/dbus/account-manager.c index 7d764f318..4d0e75866 100644 --- a/tests/dbus/account-manager.c +++ b/tests/dbus/account-manager.c @@ -311,7 +311,7 @@ finish_assert_am_not_activatable_action (TpDBusDaemon *proxy, { guint i; - g_assert (error == NULL); + g_assert_no_error (error); for (i=0; names[i] != NULL; i++) { diff --git a/tests/dbus/call-channel.c b/tests/dbus/call-channel.c index 90b77bc53..ca9c27445 100644 --- a/tests/dbus/call-channel.c +++ b/tests/dbus/call-channel.c @@ -1020,7 +1020,7 @@ test_dtmf (Test *test, run_until_active (test); contents = tp_call_channel_get_contents (test->call_chan); - g_assert (contents->len == 1); + g_assert_cmpuint (contents->len, ==, 1); content = g_ptr_array_index (contents, 0); tp_cli_call_content_interface_media_connect_to_dtmf_change_requested (content, diff --git a/tests/dbus/channel.c b/tests/dbus/channel.c index bb3235f88..b4c536532 100644 --- a/tests/dbus/channel.c +++ b/tests/dbus/channel.c @@ -655,7 +655,7 @@ test_contacts (Test *test, /* There is ourself and the new contact, get the new one */ contacts = tp_channel_group_dup_members_contacts (test->channel_room); g_assert (contacts != NULL); - g_assert (contacts->len == 2); + g_assert_cmpuint (contacts->len, ==, 2); contact = g_ptr_array_index (contacts, 0); if (!tp_strdiff (tp_contact_get_identifier (contact), "me@test.com")) contact = g_ptr_array_index (contacts, 1); diff --git a/tests/dbus/contacts-bug-19101.c b/tests/dbus/contacts-bug-19101.c index 77474e15e..35296e288 100644 --- a/tests/dbus/contacts-bug-19101.c +++ b/tests/dbus/contacts-bug-19101.c @@ -41,7 +41,7 @@ by_id_cb (TpConnection *connection, Result *result = user_data; g_assert (result->contacts == NULL); - g_assert (result->error == NULL); + g_assert_no_error (result->error); g_assert (result->good_ids == NULL); g_assert (result->bad_ids == NULL); diff --git a/tests/dbus/contacts-slow-path.c b/tests/dbus/contacts-slow-path.c index b518b8083..721d5e3d2 100644 --- a/tests/dbus/contacts-slow-path.c +++ b/tests/dbus/contacts-slow-path.c @@ -65,7 +65,7 @@ by_handle_cb (TpConnection *connection, g_assert (result->invalid == NULL); g_assert (result->contacts == NULL); - g_assert (result->error == NULL); + g_assert_no_error (result->error); g_assert (result->good_ids == NULL); g_assert (result->bad_ids == NULL); @@ -182,7 +182,7 @@ test_by_handle (Fixture *f, result.invalid = NULL; g_ptr_array_unref (result.contacts); result.contacts = NULL; - g_assert (result.error == NULL); + g_assert_no_error (result.error); /* Replace one of the invalid handles with a valid one */ handles[2] = tp_handle_ensure (service_repo, "dora", NULL, NULL); @@ -248,7 +248,7 @@ test_by_handle (Fixture *f, g_main_loop_unref (result.loop); g_array_unref (result.invalid); g_ptr_array_unref (result.contacts); - g_assert (result.error == NULL); + g_assert_no_error (result.error); } static void @@ -323,7 +323,7 @@ test_no_features (Fixture *f, g_main_loop_unref (result.loop); g_array_unref (result.invalid); g_ptr_array_unref (result.contacts); - g_assert (result.error == NULL); + g_assert_no_error (result.error); } static void @@ -338,7 +338,7 @@ upgrade_cb (TpConnection *connection, g_assert (result->invalid == NULL); g_assert (result->contacts == NULL); - g_assert (result->error == NULL); + g_assert_no_error (result->error); g_assert (result->good_ids == NULL); g_assert (result->bad_ids == NULL); @@ -459,7 +459,7 @@ test_upgrade (Fixture *f, result.invalid = NULL; g_ptr_array_unref (result.contacts); result.contacts = NULL; - g_assert (result.error == NULL); + g_assert_no_error (result.error); tp_connection_upgrade_contacts (client_conn, 3, contacts, @@ -524,7 +524,7 @@ test_upgrade (Fixture *f, g_main_loop_unref (result.loop); g_ptr_array_unref (result.contacts); g_assert (result.invalid == NULL); - g_assert (result.error == NULL); + g_assert_no_error (result.error); } typedef struct @@ -782,7 +782,7 @@ test_features (Fixture *f, g_main_loop_unref (result.loop); g_array_unref (result.invalid); g_ptr_array_unref (result.contacts); - g_assert (result.error == NULL); + g_assert_no_error (result.error); } static void @@ -799,7 +799,7 @@ by_id_cb (TpConnection *connection, g_assert (result->invalid == NULL); g_assert (result->contacts == NULL); - g_assert (result->error == NULL); + g_assert_no_error (result->error); g_assert (result->good_ids == NULL); g_assert (result->bad_ids == NULL); @@ -1027,7 +1027,7 @@ test_by_handle_again (Fixture *f, /* clean up before doing the second request */ reset_result (&result); - g_assert (result.error == NULL); + g_assert_no_error (result.error); /* silently remove the object from D-Bus, so that if the second request * makes any D-Bus calls, it will fail (but the client conn isn't @@ -1065,7 +1065,7 @@ test_by_handle_again (Fixture *f, g_assert_no_error (result.error); g_assert (ok); - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); weak_pointer = contact; @@ -1116,7 +1116,7 @@ test_by_handle_upgrade (Fixture *f, /* clean up before doing the second request */ reset_result (&result); - g_assert (result.error == NULL); + g_assert_no_error (result.error); /* the second request enables the Alias feature, so it must make more D-Bus * round trips */ @@ -1133,7 +1133,7 @@ test_by_handle_upgrade (Fixture *f, g_assert (g_ptr_array_index (result.contacts, 0) == contact); g_assert_cmpstr (tp_contact_get_alias (contact), ==, "Alice in Wonderland"); - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); weak_pointer = contact; diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c index a7a4d8d6c..d6ea70998 100644 --- a/tests/dbus/contacts.c +++ b/tests/dbus/contacts.c @@ -99,7 +99,7 @@ by_handle_cb (TpConnection *connection, g_assert (result->invalid == NULL); g_assert (result->contacts == NULL); - g_assert (result->error == NULL); + g_assert_no_error (result->error); g_assert (result->good_ids == NULL); g_assert (result->bad_ids == NULL); @@ -662,7 +662,7 @@ test_avatar_data (Fixture *f, rand_str[i] = letters[g_random_int_range (0, strlen (letters))]; rand_str[RAND_STR_LEN] = '\0'; dir = g_build_filename (g_get_tmp_dir (), rand_str, NULL); - g_assert (g_mkdir (dir, 0700) == 0); + g_assert_cmpint (g_mkdir (dir, 0700), ==, 0); g_setenv ("XDG_CACHE_HOME", dir, TRUE); g_assert_cmpstr (g_get_user_cache_dir (), ==, dir); @@ -760,7 +760,7 @@ test_by_handle (Fixture *f, /* clean up before doing the second request */ reset_result (&result); - g_assert (result.error == NULL); + g_assert_no_error (result.error); /* Replace one of the invalid handles with a valid one */ handles[2] = tp_handle_ensure (service_repo, "dora", NULL, NULL); @@ -820,7 +820,7 @@ test_by_handle (Fixture *f, tp_tests_proxy_run_until_dbus_queue_processed (client_conn); /* remaining cleanup */ - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); g_main_loop_unref (result.loop); } @@ -927,7 +927,7 @@ test_by_handle_again (Fixture *f, /* clean up before doing the second request */ reset_result (&result); - g_assert (result.error == NULL); + g_assert_no_error (result.error); make_the_connection_disappear (f); @@ -946,7 +946,7 @@ test_by_handle_again (Fixture *f, put_the_connection_back (f); - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); weak_pointer = contact; @@ -997,7 +997,7 @@ test_by_handle_upgrade (Fixture *f, /* clean up before doing the second request */ reset_result (&result); - g_assert (result.error == NULL); + g_assert_no_error (result.error); /* the second request enables the Alias feature, so it must make more D-Bus * round trips */ @@ -1014,7 +1014,7 @@ test_by_handle_upgrade (Fixture *f, g_assert (g_ptr_array_index (result.contacts, 0) == contact); g_assert_cmpstr (tp_contact_get_alias (contact), ==, "Alice in Wonderland"); - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); weak_pointer = contact; @@ -1064,7 +1064,7 @@ test_no_features (Fixture *f, for (i = 0; i < 3; i++) contacts[i] = g_object_ref (g_ptr_array_index (result.contacts, i)); - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); for (i = 0; i < 3; i++) @@ -1118,7 +1118,7 @@ upgrade_cb (TpConnection *connection, g_assert (result->invalid == NULL); g_assert (result->contacts == NULL); - g_assert (result->error == NULL); + g_assert_no_error (result->error); g_assert (result->good_ids == NULL); g_assert (result->bad_ids == NULL); @@ -1322,7 +1322,7 @@ test_upgrade (Fixture *f, } /* clean up before doing the second request */ - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); tp_connection_upgrade_contacts (client_conn, @@ -1343,7 +1343,7 @@ test_upgrade (Fixture *f, } g_assert (result.invalid == NULL); - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); for (i = 0; i < 3; i++) @@ -1631,7 +1631,7 @@ test_features (Fixture *f, for (i = 0; i < 3; i++) contacts[i] = g_object_ref (g_ptr_array_index (result.contacts, i)); - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); for (i = 0; i < 3; i++) @@ -1830,7 +1830,7 @@ by_id_cb (TpConnection *connection, g_assert (result->invalid == NULL); g_assert (result->contacts == NULL); - g_assert (result->error == NULL); + g_assert_no_error (result->error); g_assert (result->good_ids == NULL); g_assert (result->bad_ids == NULL); @@ -2049,7 +2049,7 @@ test_capabilities_without_contact_caps (Fixture *f, " contact %u", i); } - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); g_main_loop_unref (result.loop); } @@ -2108,7 +2108,7 @@ test_prepare_contact_caps_without_request (Fixture *f, MYASSERT (caps == NULL, ""); } - g_assert (result.error == NULL); + g_assert_no_error (result.error); reset_result (&result); g_main_loop_unref (result.loop); } @@ -2364,7 +2364,7 @@ assert_no_location (TpContact *contact) GHashTable *retrieved_location = tp_contact_get_location (contact); if (retrieved_location != NULL) - g_assert (g_hash_table_size (retrieved_location) == 0); + g_assert_cmpuint (g_hash_table_size (retrieved_location), ==, 0); } /* This is a regression test for an issue where the LOCATION feature would @@ -2423,7 +2423,7 @@ test_no_location (Fixture *f, assert_no_location (contact); put_the_connection_back (f); - g_assert (f->result.error == NULL); + g_assert_no_error (f->result.error); reset_result (&f->result); /* Despite Alice not currently having a published location, we should diff --git a/tests/dbus/handle-repo.c b/tests/dbus/handle-repo.c index ec8002486..e4e384ba8 100644 --- a/tests/dbus/handle-repo.c +++ b/tests/dbus/handle-repo.c @@ -52,7 +52,7 @@ test_handles (void) /* It's not there to start with */ handle = tp_handle_lookup (tp_repo, jid, NULL, NULL); - g_assert (handle == 0); + g_assert_cmpuint (handle, ==, 0); /* ... but when we call tp_handle_ensure we get a new ref to it [ref 1] */ handle = tp_handle_ensure (tp_repo, jid, NULL, NULL); g_assert (handle != 0); diff --git a/tests/dbus/params-cm.c b/tests/dbus/params-cm.c index 9a4a6bb75..87d10c399 100644 --- a/tests/dbus/params-cm.c +++ b/tests/dbus/params-cm.c @@ -150,7 +150,7 @@ test_set_params (Test *test, params = tp_tests_param_connection_manager_steal_params_last_conn (); g_assert (params != NULL); - g_assert (!tp_strdiff (params->a_string, "a string")); + g_assert_cmpstr (params->a_string, ==, "a string"); g_assert_cmpint (params->a_int16, ==, G_MININT16); g_assert_cmpint (params->a_int32, ==, G_MININT32); g_assert_cmpuint (params->a_uint16, ==, G_MAXUINT16); @@ -163,15 +163,16 @@ test_set_params (Test *test, g_assert_cmpuint (g_strv_length (params->a_array_of_strings), ==, g_strv_length (array_of_strings)); for (i = 0; array_of_strings[i] != NULL; i++) - g_assert (!tp_strdiff (params->a_array_of_strings[i], array_of_strings[i])); + g_assert_cmpstr (params->a_array_of_strings[i], ==, array_of_strings[i]); g_assert_cmpuint (params->a_array_of_bytes->len, ==, array_of_bytes->len); for (i = 0; i < array_of_bytes->len; i++) - g_assert (params->a_array_of_bytes->data[i] == array_of_bytes->data[i]); + g_assert_cmpuint (params->a_array_of_bytes->data[i], ==, + array_of_bytes->data[i]); - g_assert (!tp_strdiff (params->a_object_path, "/A/Object/Path")); - g_assert (!tp_strdiff (params->lc_string, "filter me")); - g_assert (!tp_strdiff (params->uc_string, "FILTER ME")); + g_assert_cmpstr (params->a_object_path, ==, "/A/Object/Path"); + g_assert_cmpstr (params->lc_string, ==, "filter me"); + g_assert_cmpstr (params->uc_string, ==, "FILTER ME"); tp_tests_param_connection_manager_free_params (params); g_hash_table_unref (parameters); diff --git a/tests/debug-domain.c b/tests/debug-domain.c index 37ef41804..1a833e3dc 100644 --- a/tests/debug-domain.c +++ b/tests/debug-domain.c @@ -41,9 +41,9 @@ handler (const gchar *log_domain, g_assert_cmpuint (log_level, ==, G_LOG_LEVEL_DEBUG); g_assert_cmpuint (g_strv_length (parts), ==, 2); - g_assert (!tp_strdiff (parts[0], "tp-glib")); - g_assert (!tp_strdiff (parts[1], i.domain)); - g_assert (!tp_strdiff (message, "foo")); + g_assert_cmpstr (parts[0], ==, "tp-glib"); + g_assert_cmpstr (parts[1], ==, i.domain); + g_assert_cmpstr (message, ==, "foo"); g_strfreev (parts); } diff --git a/tests/gnio-util.c b/tests/gnio-util.c index 0657b7065..27eac785e 100644 --- a/tests/gnio-util.c +++ b/tests/gnio-util.c @@ -291,7 +291,7 @@ test_sockaddr_to_variant_abstract_unix (void) array = g_value_get_boxed (variant); g_assert_cmpuint (array->len, ==, ABST_ADDR_LEN); - g_assert (memcmp (array->data, ABST_ADDR, ABST_ADDR_LEN) == 0); + g_assert_cmpint (memcmp (array->data, ABST_ADDR, ABST_ADDR_LEN), ==, 0); tp_g_value_slice_free (variant); } diff --git a/tests/internal-debug.c b/tests/internal-debug.c index 894924920..40a6255a8 100644 --- a/tests/internal-debug.c +++ b/tests/internal-debug.c @@ -22,9 +22,9 @@ test_debugging (void) #endif #ifdef ENABLE_DEBUG - g_assert (DEBUGGING == 1); + g_assert_cmpint (DEBUGGING, ==, 1); #else - g_assert (DEBUGGING == 0); + g_assert_cmpint (DEBUGGING, ==, 0); #endif } @@ -42,7 +42,7 @@ test_not_debugging (void) #error internal-debug.h should always define DEBUGGING #endif - g_assert (DEBUGGING == 0); + g_assert_cmpint (DEBUGGING, ==, 0); } #undef DEBUG_FLAG @@ -60,9 +60,9 @@ test_debugging_again (void) #endif #ifdef ENABLE_DEBUG - g_assert (DEBUGGING == 1); + g_assert_cmpint (DEBUGGING, ==, 1); #else - g_assert (DEBUGGING == 0); + g_assert_cmpint (DEBUGGING, ==, 0); #endif } -- cgit v1.2.3