diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2020-05-05 20:03:03 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2020-05-05 20:04:00 -0400 |
commit | 1da0537b3b4b323de5d67c90ff2829eb01f10a02 (patch) | |
tree | f67e989194c92d61165b5c802d95e960463e7618 /tests | |
parent | d6317167a169c647ae35a365e268d1716bc9ceb4 (diff) | |
download | libnice-1da0537b3b4b323de5d67c90ff2829eb01f10a02.tar.gz |
Use g_assert_cmp.int() to get better debug logs on crash
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-add-remove-stream.c | 6 | ||||
-rw-r--r-- | tests/test-address.c | 8 | ||||
-rw-r--r-- | tests/test-build-io-stream.c | 8 | ||||
-rw-r--r-- | tests/test-credentials.c | 10 | ||||
-rw-r--r-- | tests/test-different-number-streams.c | 8 | ||||
-rw-r--r-- | tests/test-drop-invalid.c | 54 | ||||
-rw-r--r-- | tests/test-fallback.c | 36 | ||||
-rw-r--r-- | tests/test-fullmode.c | 136 | ||||
-rw-r--r-- | tests/test-icetcp.c | 42 | ||||
-rw-r--r-- | tests/test-io-stream-cancelling.c | 2 | ||||
-rw-r--r-- | tests/test-io-stream-common.c | 2 | ||||
-rw-r--r-- | tests/test-io-stream-thread.c | 4 | ||||
-rw-r--r-- | tests/test-new-trickle.c | 30 | ||||
-rw-r--r-- | tests/test-nomination.c | 8 | ||||
-rw-r--r-- | tests/test-priority.c | 6 | ||||
-rw-r--r-- | tests/test-pseudotcp-fuzzy.c | 2 | ||||
-rw-r--r-- | tests/test-pseudotcp.c | 2 | ||||
-rw-r--r-- | tests/test-restart.c | 24 | ||||
-rw-r--r-- | tests/test-tcp.c | 8 | ||||
-rw-r--r-- | tests/test-thread.c | 10 | ||||
-rw-r--r-- | tests/test-trickle.c | 32 | ||||
-rw-r--r-- | tests/test-turn.c | 10 | ||||
-rw-r--r-- | tests/test-udp-turn-fragmentation.c | 2 | ||||
-rw-r--r-- | tests/test.c | 4 |
24 files changed, 227 insertions, 227 deletions
diff --git a/tests/test-add-remove-stream.c b/tests/test-add-remove-stream.c index c97bc7b..6df9dce 100644 --- a/tests/test-add-remove-stream.c +++ b/tests/test-add-remove-stream.c @@ -61,9 +61,9 @@ main (void) agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); nice_agent_add_local_address (agent, &addr); - g_assert (nice_agent_add_stream (agent, 1) == 1); - g_assert (nice_agent_add_stream (agent, 10) == 2); - g_assert (nice_agent_add_stream (agent, 2) == 3); + g_assert_cmpuint (nice_agent_add_stream (agent, 1), ==, 1); + g_assert_cmpuint (nice_agent_add_stream (agent, 10), ==, 2); + g_assert_cmpuint (nice_agent_add_stream (agent, 2), ==, 3); g_assert (NULL != agent->streams); diff --git a/tests/test-address.c b/tests/test-address.c index c95cdde..8e05050 100644 --- a/tests/test-address.c +++ b/tests/test-address.c @@ -52,10 +52,10 @@ test_ipv4 (void) nice_address_init (&addr); nice_address_init (&other); nice_address_set_ipv4 (&addr, 0x01020304); - g_assert (addr.s.ip4.sin_family == AF_INET); + g_assert_cmpint (addr.s.ip4.sin_family, ==, AF_INET); nice_address_to_string (&addr, str); - g_assert (0 == strcmp (str, "1.2.3.4")); + g_assert_cmpstr (str, ==, "1.2.3.4"); nice_address_to_string (&addr, str); @@ -115,10 +115,10 @@ test_ipv6 (void) "\x44\x55\x66\x77" "\x88\x99\xaa\xbb" "\xcc\xdd\xee\xff"); - g_assert (addr.s.ip6.sin6_family == AF_INET6); + g_assert_cmpint (addr.s.ip6.sin6_family, ==, AF_INET6); nice_address_to_string (&addr, str); - g_assert (0 == strcmp (str, "11:2233:4455:6677:8899:aabb:ccdd:eeff")); + g_assert_cmpstr (str, ==, "11:2233:4455:6677:8899:aabb:ccdd:eeff"); nice_address_set_port (&addr, 9876); /* in native byte order */ nice_address_set_from_string (&other, "11:2233:4455:6677:8899:aabb:ccdd:eeff"); diff --git a/tests/test-build-io-stream.c b/tests/test-build-io-stream.c index 0ebea2f..195a8a9 100644 --- a/tests/test-build-io-stream.c +++ b/tests/test-build-io-stream.c @@ -396,10 +396,10 @@ test_zero_length_reads_writes (NiceAddress *addr) pollable_output_stream = G_POLLABLE_OUTPUT_STREAM (output_stream); /* Check zero-length reads and writes complete immediately without error. */ - g_assert (g_input_stream_read (input_stream, buf, 0, NULL, &error) == 0); + g_assert_cmpint (g_input_stream_read (input_stream, buf, 0, NULL, &error), ==, 0); g_assert_no_error (error); - g_assert (g_output_stream_write (output_stream, buf, 0, NULL, &error) == 0); + g_assert_cmpint (g_output_stream_write (output_stream, buf, 0, NULL, &error), ==, 0); g_assert_no_error (error); g_assert ( @@ -417,10 +417,10 @@ test_zero_length_reads_writes (NiceAddress *addr) nice_agent_remove_stream (agent, stream_id); g_assert (g_io_stream_is_closed (G_IO_STREAM (io_stream))); - g_assert (g_input_stream_read (input_stream, buf, 0, NULL, &error) == 0); + g_assert_cmpint (g_input_stream_read (input_stream, buf, 0, NULL, &error), ==, 0); g_assert_no_error (error); - g_assert (g_output_stream_write (output_stream, buf, 0, NULL, &error) == 0); + g_assert_cmpint (g_output_stream_write (output_stream, buf, 0, NULL, &error), ==, 0); g_assert_no_error (error); g_assert ( diff --git a/tests/test-credentials.c b/tests/test-credentials.c index f1ea89d..d11da6d 100644 --- a/tests/test-credentials.c +++ b/tests/test-credentials.c @@ -78,7 +78,7 @@ static void swap_candidates(NiceAgent *local, guint local_id, NiceAgent *remote, g_debug ("test-credentials:%s", G_STRFUNC); cands = nice_agent_get_local_candidates(local, local_id, NICE_COMPONENT_TYPE_RTP); - g_assert(nice_agent_set_remote_candidates(remote, remote_id, + g_assert (nice_agent_set_remote_candidates(remote, remote_id, NICE_COMPONENT_TYPE_RTP, cands)); g_slist_free_full (cands, (GDestroyNotify) nice_candidate_free); @@ -119,8 +119,8 @@ static void setup(NiceAgent *lagent, NiceAgent *ragent) { NiceAddress addr; - g_assert (nice_agent_add_stream (lagent, 1) == 1); - g_assert (nice_agent_add_stream (ragent, 1) == 1); + g_assert_cmpuint (nice_agent_add_stream (lagent, 1), ==, 1); + g_assert_cmpuint (nice_agent_add_stream (ragent, 1), ==, 1); g_assert (NULL != lagent->streams); g_assert (NULL != ragent->streams); @@ -182,8 +182,8 @@ int main (void) nice_agent_set_local_credentials (lagent, 1, "unicorns", "awesome"); nice_agent_get_local_credentials (lagent, 1, &ufrag, &password); - g_assert (g_strcmp0("unicorns", ufrag) == 0); - g_assert (g_strcmp0("awesome", password) == 0); + g_assert_cmpstr ("unicorns", ==, ufrag); + g_assert_cmpstr ("awesome", ==, password); g_free (ufrag); g_free (password); diff --git a/tests/test-different-number-streams.c b/tests/test-different-number-streams.c index 4957ae6..81be822 100644 --- a/tests/test-different-number-streams.c +++ b/tests/test-different-number-streams.c @@ -121,7 +121,7 @@ int main (void) timer_id = g_timeout_add (30000, timer_cb, NULL); ls_id = nice_agent_add_stream (lagent, 2); - g_assert (ls_id > 0); + g_assert_cmpuint (ls_id, >, 0); nice_agent_get_local_credentials(lagent, ls_id, &lufrag, &lpassword); /* step: attach to mainloop (needed to register the fds) */ @@ -134,11 +134,11 @@ int main (void) if (ADD_2_STREAMS) { rs_id_1 = nice_agent_add_stream (ragent, 2); - g_assert (rs_id_1 > 0); + g_assert_cmpuint (rs_id_1, >, 0); nice_agent_get_local_credentials(ragent, rs_id_1, &rufrag1, &rpassword1); rs_id_2 = nice_agent_add_stream (ragent, 2); - g_assert (rs_id_2 > 0); + g_assert_cmpuint (rs_id_2, >, 0); nice_agent_get_local_credentials(ragent, rs_id_2, &rufrag2, &rpassword2); nice_agent_set_remote_credentials (ragent, rs_id_2, lufrag, lpassword); @@ -171,7 +171,7 @@ int main (void) g_main_loop_get_context (global_mainloop), cb_nice_recv, NULL); } else { rs_id_1 = nice_agent_add_stream (ragent, 2); - g_assert (rs_id_1 > 0); + g_assert_cmpuint (rs_id_1, >, 0); nice_agent_get_local_credentials(ragent, rs_id_1, &rufrag1, &rpassword1); nice_agent_set_remote_credentials (ragent, rs_id_1, lufrag, lpassword); diff --git a/tests/test-drop-invalid.c b/tests/test-drop-invalid.c index 585ce28..88907ac 100644 --- a/tests/test-drop-invalid.c +++ b/tests/test-drop-invalid.c @@ -307,8 +307,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); /* Gather candidates and test nice_agent_set_port_range */ nice_agent_set_port_range (lagent, ls_id, 1, 10000, 11000); @@ -329,41 +329,41 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas NiceCandidate *cand = NULL; cands = nice_agent_get_local_candidates (lagent, ls_id, 1); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); - g_assert (nice_address_get_port (&cand->addr) >= 10000); - g_assert (nice_address_get_port (&cand->addr) <= 11000); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpuint (nice_address_get_port (&cand->addr), >=, 10000); + g_assert_cmpuint (nice_address_get_port (&cand->addr), <=, 11000); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); cands = nice_agent_get_local_candidates (lagent, ls_id, 2); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); - g_assert (nice_address_get_port (&cand->addr) >= 11000); - g_assert (nice_address_get_port (&cand->addr) <= 12000); + g_assert_cmpuint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpuint (nice_address_get_port (&cand->addr), >=, 11000); + g_assert_cmpuint (nice_address_get_port (&cand->addr), <=, 12000); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); cands = nice_agent_get_local_candidates (ragent, rs_id, 1); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); - g_assert (nice_address_get_port (&cand->addr) >= 12000); - g_assert (nice_address_get_port (&cand->addr) <= 13000); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpuint (nice_address_get_port (&cand->addr), >=, 12000); + g_assert_cmpuint (nice_address_get_port (&cand->addr), <=, 13000); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); cands = nice_agent_get_local_candidates (ragent, rs_id, 2); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); - g_assert (nice_address_get_port (&cand->addr) >= 13000); - g_assert (nice_address_get_port (&cand->addr) <= 14000); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpuint (nice_address_get_port (&cand->addr), >=, 13000); + g_assert_cmpuint (nice_address_get_port (&cand->addr), <=, 14000); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); @@ -435,10 +435,10 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ret = nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678"); g_assert (ret != -1); g_debug ("Sent %d bytes", ret); - g_assert (ret == 16); + g_assert_cmpint (ret, ==, 16); while (global_ragent_read != 16) g_main_context_iteration (NULL, TRUE); - g_assert (global_ragent_read == 16); + g_assert_cmpint (global_ragent_read, ==, 16); g_debug ("test-drop-invalid: Ran mainloop, removing streams..."); @@ -520,19 +520,19 @@ int main (void) g_debug ("test-drop-invalid: TEST STARTS / running test for the 1st time"); result = run_full_test (lagent, ragent, &baseaddr, 4 ,0); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); /* When using TURN, we get peer reflexive candidates for the host cands that we removed so we can get another new_selected_pair signal later depending on timing/racing, we could double (or not) the amount we expected */ /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 2); - g_assert (global_ragent_cands == 2); + g_assert_cmpint (global_lagent_cands, ==, 2); + g_assert_cmpint (global_ragent_cands, ==, 2); g_object_unref (lagent); g_object_unref (ragent); diff --git a/tests/test-fallback.c b/tests/test-fallback.c index 3a75b99..02aa22e 100644 --- a/tests/test-fallback.c +++ b/tests/test-fallback.c @@ -245,8 +245,8 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress /* step: add one stream, with RTP+RTCP components, to each agent */ ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); nice_agent_gather_candidates (lagent, ls_id); nice_agent_gather_candidates (ragent, rs_id); @@ -317,8 +317,8 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress g_main_loop_run (global_mainloop); /* note: verify that agents are in correct state */ - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, ==, NICE_COMPONENT_STATE_READY); /* step: next send a packet -> should work even if no ICE processing * has been done */ @@ -327,12 +327,12 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress /* step: send a new test packet from L ot R */ global_ragent_read = 0; - g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16); + g_assert_cmpint (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678"), ==, 16); global_ragent_read_exit = 16; g_main_loop_run (global_mainloop); /* note: verify that payload was succesfully received */ - g_assert (global_ragent_read == 16); + g_assert_cmpint (global_ragent_read, ==, 16); g_debug ("test-fallback: Ran mainloop, removing streams..."); @@ -381,8 +381,8 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd /* step: add one stream, with RTP+RTCP components, to each agent */ ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); nice_agent_gather_candidates (lagent, ls_id); nice_agent_gather_candidates (ragent, rs_id); @@ -449,8 +449,8 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd g_main_loop_run (global_mainloop); /* note: verify that agents are in correct state */ - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, ==, NICE_COMPONENT_STATE_READY); /* step: next send a packet -> should work even if no ICE processing * has been done */ @@ -459,12 +459,12 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd /* step: send a new test packet from L ot R */ global_ragent_read = 0; - g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16); + g_assert_cmpint (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678"), ==, 16); global_ragent_read_exit = 16; g_main_loop_run (global_mainloop); /* note: verify that payload was succesfully received */ - g_assert (global_ragent_read == 16); + g_assert_cmpint (global_ragent_read, ==, 16); g_debug ("test-fallback: Ran mainloop, removing streams..."); @@ -549,17 +549,17 @@ int main (void) g_debug ("test-fallback: TEST STARTS / fallback test"); result = run_fallback_test (lagent, ragent, &baseaddr); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, ==, NICE_COMPONENT_STATE_READY); /* step: run the safe test without sending any stnu */ g_debug ("test-fallback: TEST STARTS / safe fallback test"); result = run_safe_fallback_test (lagent, ragent, &baseaddr); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, ==, NICE_COMPONENT_STATE_READY); g_object_unref (lagent); g_object_unref (ragent); diff --git a/tests/test-fullmode.c b/tests/test-fullmode.c index 7c38330..4bcec49 100644 --- a/tests/test-fullmode.c +++ b/tests/test-fullmode.c @@ -394,8 +394,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); #if USE_TURN nice_agent_set_relay_info(lagent, ls_id, 1, TURN_IP, TURN_PORT, TURN_USER, TURN_PASS, TURN_TYPE); @@ -415,7 +415,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas break; } - g_assert (port == get_port (lagent, ls_id, 1)); + g_assert_cmpuint (port, ==, get_port (lagent, ls_id, 1)); nice_agent_set_port_range (ragent, rs_id, 2, port, port); @@ -432,33 +432,33 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas NiceCandidate *cand = NULL; cands = nice_agent_get_local_candidates (lagent, ls_id, 1); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); cands = nice_agent_get_local_candidates (lagent, ls_id, 2); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); cands = nice_agent_get_local_candidates (ragent, rs_id, 1); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); cands = nice_agent_get_local_candidates (ragent, rs_id, 2); - g_assert (g_slist_length (cands) == 1); + g_assert_cmpuint (g_slist_length (cands), ==, 1); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); for (i = cands; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); @@ -531,10 +531,10 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas } } g_debug ("Sent %d bytes", ret); - g_assert (ret == 16); + g_assert_cmpint (ret, ==, 16); while (global_ragent_read != 16) g_main_context_iteration (NULL, TRUE); - g_assert (global_ragent_read == 16); + g_assert_cmpint (global_ragent_read, ==, 16); g_debug ("test-fullmode: Ran mainloop, removing streams..."); @@ -579,8 +579,8 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); /* We don't try this with TURN because as long as both agents don't have the remote candidates, they won't be able to create the @@ -640,7 +640,7 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N g_main_loop_run (global_mainloop); g_assert (global_ragent_ibr_received == TRUE); - g_assert (global_components_failed == 0); + g_assert_cmpuint (global_components_failed, ==, 0); /* note: test payload send and receive */ global_ragent_read = 0; @@ -663,9 +663,9 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N } } global_ragent_read = 0; - g_assert (ret == 16); + g_assert_cmpint (ret, ==, 16); g_main_loop_run (global_mainloop); - g_assert (global_ragent_read == 16); + g_assert_cmpint (global_ragent_read, ==, 16); g_debug ("test-fullmode: Ran mainloop, removing streams..."); @@ -703,8 +703,8 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N ls_id = nice_agent_add_stream (lagent, 1); rs_id = nice_agent_add_stream (ragent, 1); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); #if USE_TURN nice_agent_set_relay_info(lagent, ls_id, 1, @@ -752,8 +752,8 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N g_main_loop_run (global_mainloop); /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 0); - g_assert (global_ragent_cands == 0); + g_assert_cmpint (global_lagent_cands, ==, 0); + g_assert_cmpint (global_ragent_cands, ==, 0); g_debug ("test-fullmode: Ran mainloop, removing streams..."); @@ -790,8 +790,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, ls_id = nice_agent_add_stream (lagent, 1); rs_id = nice_agent_add_stream (ragent, 1); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); #if USE_TURN nice_agent_set_relay_info(lagent, ls_id, 1, @@ -841,8 +841,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, */ #if !(USE_TURN) /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 1); - g_assert (global_ragent_cands == 1); + g_assert_cmpint (global_lagent_cands, ==, 1); + g_assert_cmpint (global_ragent_cands, ==, 1); #endif g_debug ("test-fullmode: Ran mainloop, removing streams..."); @@ -970,34 +970,34 @@ int main (void) g_object_get (G_OBJECT (lagent), "stun-server-port", &port, NULL); g_assert (stun_server_port == NULL || port == (guint)atoi (stun_server_port)); g_object_get (G_OBJECT (lagent), "proxy-ip", &string, NULL); - g_assert (strcmp (string, PROXY_IP) == 0); + g_assert_cmpstr (string, ==, PROXY_IP); g_free (string); g_object_get (G_OBJECT (lagent), "proxy-port", &port, NULL); - g_assert (port == PROXY_PORT); + g_assert_cmpuint (port, ==, PROXY_PORT); g_object_get (G_OBJECT (lagent), "controlling-mode", &mode, NULL); g_assert (mode == TRUE); g_object_set (G_OBJECT (lagent), "max-connectivity-checks", 300, NULL); g_object_get (G_OBJECT (lagent), "max-connectivity-checks", &max_checks, NULL); - g_assert (max_checks == 300); + g_assert_cmpuint (max_checks, ==, 300); } /* step: run test the first time */ g_debug ("test-fullmode: TEST STARTS / running test for the 1st time"); result = run_full_test (lagent, ragent, &baseaddr, 4 ,0); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); /* When using TURN, we get peer reflexive candidates for the host cands that we removed so we can get another new_selected_pair signal later depending on timing/racing, we could double (or not) the amount we expected */ #if !(USE_TURN) /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 2); - g_assert (global_ragent_cands == 2); + g_assert_cmpint (global_lagent_cands, ==, 2); + g_assert_cmpint (global_ragent_cands, ==, 2); #endif @@ -1005,19 +1005,19 @@ int main (void) g_debug ("test-fullmode: TEST STARTS / running test for the 2nd time"); result = run_full_test (lagent, ragent, &baseaddr, 4, 0); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); /* When using TURN, we get peer reflexive candidates for the host cands that we removed so we can get another new_selected_pair signal later depending on timing/racing, we could double (or not) the amount we expected */ #if !(USE_TURN) /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 2); - g_assert (global_ragent_cands == 2); + g_assert_cmpint (global_lagent_cands, ==, 2); + g_assert_cmpint (global_ragent_cands, ==, 2); #endif @@ -1025,19 +1025,19 @@ int main (void) g_debug ("test-fullmode: TEST STARTS / delayed SDP answer"); result = run_full_test_delayed_answer (lagent, ragent, &baseaddr, 4, 0); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); /* note: verify that correct number of local candidates were reported */ /* When using TURN, we get peer reflexive candidates for the host cands that we removed so we can get another new_selected_pair signal later depending on timing/racing, we could double (or not) the amount we expected */ #if !(USE_TURN) - g_assert (global_lagent_cands == 2); - g_assert (global_ragent_cands == 2); + g_assert_cmpint (global_lagent_cands, ==, 2); + g_assert_cmpint (global_ragent_cands, ==, 2); #endif #if TEST_GOOGLE @@ -1048,11 +1048,11 @@ int main (void) g_debug ("test-fullmode: TEST STARTS / incorrect credentials"); result = run_full_test_wrong_password (lagent, ragent, &baseaddr); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_FAILED); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_LAST); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_FAILED); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_LAST); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_FAILED); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_LAST); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_FAILED); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_LAST); /* The max connectivity checks test can't be run with TURN because we'll have 3 local candidates instead of 1 and the checks will @@ -1065,7 +1065,7 @@ int main (void) g_object_set (G_OBJECT (ragent), "max-connectivity-checks", 1, NULL); result = run_full_test (lagent, ragent, &baseaddr, 2, 2); priv_print_global_status (); - g_assert (result == 0); + g_assert_cmpint (result, ==, 0); /* should FAIL as agent L can't send any checks: */ g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_FAILED || global_lagent_state[1] == NICE_COMPONENT_STATE_FAILED); @@ -1078,14 +1078,14 @@ int main (void) result = run_full_test (lagent, ragent, &baseaddr, 4, 0); priv_print_global_status (); /* should SUCCEED as agent L can send the checks: */ - g_assert (result == 0); + g_assert_cmpint (result, ==, 0); g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_CONNECTED || global_lagent_state[0] == NICE_COMPONENT_STATE_READY); g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_CONNECTED || global_lagent_state[1] == NICE_COMPONENT_STATE_READY); g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_CONNECTED || global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_CONNECTED || + g_assert(global_ragent_state[1] == NICE_COMPONENT_STATE_CONNECTED || global_ragent_state[1] == NICE_COMPONENT_STATE_READY); g_object_set (G_OBJECT (lagent), "max-connectivity-checks", 100, NULL); @@ -1093,22 +1093,22 @@ int main (void) g_debug ("test-fullmode: TEST STARTS / controlling mode conflict case-1"); result = run_full_test_control_conflict (lagent, ragent, &baseaddr, TRUE); priv_print_global_status (); - g_assert (result == 0); + g_assert_cmpint (result, ==, 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); /* run test with a conflict in controlling mode: controlled-controlled */ g_debug ("test-fullmode: TEST STARTS / controlling mode conflict case-2"); result = run_full_test_control_conflict (lagent, ragent, &baseaddr, FALSE); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); nice_agent_close_async (lagent, cb_closed, &lagent_closed); nice_agent_close_async (ragent, cb_closed, &ragent_closed); diff --git a/tests/test-icetcp.c b/tests/test-icetcp.c index 22cd98a..25f4043 100644 --- a/tests/test-icetcp.c +++ b/tests/test-icetcp.c @@ -293,8 +293,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); /* Gather candidates */ g_assert (nice_agent_gather_candidates (lagent, ls_id) == TRUE); @@ -305,13 +305,13 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas NiceCandidate *cand = NULL; cands = nice_agent_get_local_candidates (lagent, ls_id, 1); - g_assert (g_slist_length (cands) == 2); + g_assert_cmpuint (g_slist_length (cands), ==, 2); cand = cands->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); g_assert (cand->transport == NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE || cand->transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE); cand = cands->next->data; - g_assert (cand->type == NICE_CANDIDATE_TYPE_HOST); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_HOST); g_assert (cand->transport == NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE || cand->transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE); for (i = cands; i; i = i->next) @@ -381,9 +381,9 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas } } g_debug ("Sent %d bytes", ret); - g_assert (ret == 16); + g_assert_cmpint (ret, ==, 16); g_main_loop_run (global_mainloop); - g_assert (global_ragent_read == 16); + g_assert_cmpint (global_ragent_read, ==, 16); g_debug ("test-icetcp: Ran mainloop, removing streams..."); @@ -459,28 +459,28 @@ int main (void) g_debug ("test-icetcp: TEST STARTS / running test for the 1st time"); result = run_full_test (lagent, ragent, &baseaddr, 4 ,0); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands >= 2); - g_assert (global_ragent_cands >= 2); + g_assert_cmpint (global_lagent_cands, >=, 2); + g_assert_cmpint (global_ragent_cands, >=, 2); /* step: run test again without unref'ing agents */ g_debug ("test-icetcp: TEST STARTS / running test for the 2nd time"); result = run_full_test (lagent, ragent, &baseaddr, 4, 0); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[1], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[1], ==, NICE_COMPONENT_STATE_READY); /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands >= 2); - g_assert (global_ragent_cands >= 2); + g_assert_cmpint (global_lagent_cands, >=, 2); + g_assert_cmpint (global_ragent_cands, >=, 2); g_object_unref (lagent); g_object_unref (ragent); diff --git a/tests/test-io-stream-cancelling.c b/tests/test-io-stream-cancelling.c index d1b9a89..809fd98 100644 --- a/tests/test-io-stream-cancelling.c +++ b/tests/test-io-stream-cancelling.c @@ -91,7 +91,7 @@ read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data) user_data->cancellable, &error); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); g_error_free (error); - g_assert (len == -1); + g_assert_cmpint (len, ==, -1); g_main_loop_quit (data->error_loop); } diff --git a/tests/test-io-stream-common.c b/tests/test-io-stream-common.c index d5e78e2..35f0849 100644 --- a/tests/test-io-stream-common.c +++ b/tests/test-io-stream-common.c @@ -304,7 +304,7 @@ add_stream (NiceAgent *agent) guint stream_id; stream_id = nice_agent_add_stream (agent, 2); - g_assert (stream_id > 0); + g_assert_cmpuint (stream_id, >, 0); g_object_set_data (G_OBJECT (agent), "stream-id", GUINT_TO_POINTER (stream_id)); diff --git a/tests/test-io-stream-thread.c b/tests/test-io-stream-thread.c index 1d84256..49386eb 100644 --- a/tests/test-io-stream-thread.c +++ b/tests/test-io-stream-thread.c @@ -146,8 +146,8 @@ int main (void) run_io_stream_test (30, TRUE, &callbacks, l_data, NULL, r_data, NULL); /* Verify that correct number of local candidates were reported. */ - g_assert (l_data->cand_count == 1); - g_assert (r_data->cand_count == 1); + g_assert_cmpuint (l_data->cand_count, ==, 1); + g_assert_cmpuint (r_data->cand_count, ==, 1); g_free (r_data); g_free (l_data); diff --git a/tests/test-new-trickle.c b/tests/test-new-trickle.c index 97e9666..03044e2 100644 --- a/tests/test-new-trickle.c +++ b/tests/test-new-trickle.c @@ -129,7 +129,7 @@ static int listen_socket (unsigned int *port) if (getsockname (fd, &addr.addr, &socklen) < 0) g_error ("getsockname failed: %s", strerror (errno)); - g_assert (socklen == sizeof(struct sockaddr_in)); + g_assert_cmpint (socklen, ==, sizeof(struct sockaddr_in)); *port = ntohs (addr.in.sin_port); g_assert (*port != 0); } @@ -304,7 +304,7 @@ static void cb_nice_recv (NiceAgent *agent, guint stream_id, guint component_id, ret = strncmp ("0000", buf, 4); if (ret == 0) { ret = strncmp ("00001234567812345678", buf, 16); - g_assert (ret == 0); + g_assert_cmpint (ret, ==, 0); g_debug ("test-tricklemode:%s: ragent recieved %d bytes : quit mainloop", G_STRFUNC, len); @@ -341,7 +341,7 @@ static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint ret = nice_agent_send (agent, stream_id, component_id, 20, "00001234567812345678"); g_debug ("Sent %d bytes", ret); - g_assert (ret == 20); + g_assert_cmpint (ret, ==, 20); } } @@ -352,8 +352,8 @@ static void swap_candidates(NiceAgent *local, guint local_id, NiceAgent *remote, g_debug ("test-tricklemode:%s", G_STRFUNC); cands = nice_agent_get_local_candidates(local, local_id, NICE_COMPONENT_TYPE_RTP); - g_assert(nice_agent_set_remote_candidates(remote, remote_id, - NICE_COMPONENT_TYPE_RTP, cands)); + g_assert (nice_agent_set_remote_candidates(remote, remote_id, + NICE_COMPONENT_TYPE_RTP, cands)); if (signal_stun_reply) { g_mutex_lock (stun_mutex_ptr); @@ -433,8 +433,8 @@ static void init_test(NiceAgent *lagent, NiceAgent *ragent, gboolean connect_new global_ls_id = nice_agent_add_stream (lagent, 1); global_rs_id = nice_agent_add_stream (ragent, 1); - g_assert (global_ls_id > 0); - g_assert (global_rs_id > 0); + g_assert_cmpuint (global_ls_id, >, 0); + g_assert_cmpuint (global_rs_id, >, 0); g_debug ("lagent stream is : %d and ragent stream is %d", global_ls_id, @@ -521,8 +521,8 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent) g_main_context_iteration (NULL, TRUE); g_cancellable_reset (global_cancellable); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, >=, NICE_COMPONENT_STATE_CONNECTED); cleanup (lagent, ragent); } @@ -573,8 +573,8 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent) g_cancellable_reset (global_cancellable); g_assert (data_received); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, >=, NICE_COMPONENT_STATE_CONNECTED); // Wait for lagent to finish gathering candidates while (!lagent_candidate_gathering_done) @@ -641,8 +641,8 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent) g_assert (lagent_candidate_gathering_done); - g_assert (global_lagent_state >= NICE_COMPONENT_STATE_CONNECTED); - g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED); + g_assert_cmpint (global_lagent_state, >=, NICE_COMPONENT_STATE_CONNECTED); + g_assert_cmpint (global_ragent_state, >=, NICE_COMPONENT_STATE_CONNECTED); cleanup (lagent, ragent); } @@ -689,8 +689,8 @@ static void new_candidate_test(NiceAgent *lagent, NiceAgent *ragent) g_assert (lagent_candidate_gathering_done); g_assert (ragent_candidate_gathering_done); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, >=, NICE_COMPONENT_STATE_CONNECTED); cleanup (lagent, ragent); } diff --git a/tests/test-nomination.c b/tests/test-nomination.c index 0d19d06..44764e3 100644 --- a/tests/test-nomination.c +++ b/tests/test-nomination.c @@ -182,8 +182,8 @@ run_test(NiceNominationMode l_nomination_mode, ls_id = nice_agent_add_stream (lagent, 1); rs_id = nice_agent_add_stream (ragent, 1); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); /* Gather candidates and test nice_agent_set_port_range */ g_assert (nice_agent_gather_candidates (lagent, ls_id) == TRUE); @@ -210,8 +210,8 @@ run_test(NiceNominationMode l_nomination_mode, while (global_lagent_state[0] != NICE_COMPONENT_STATE_READY || global_ragent_state[0] != NICE_COMPONENT_STATE_READY) g_main_context_iteration (NULL, TRUE); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); nice_agent_remove_stream (lagent, ls_id); nice_agent_remove_stream (ragent, rs_id); diff --git a/tests/test-priority.c b/tests/test-priority.c index d38351d..822370a 100644 --- a/tests/test-priority.c +++ b/tests/test-priority.c @@ -64,16 +64,16 @@ main (void) g_list_free_full (ips, g_free); /* test 0 */ - g_assert (ip_local_preference < NICE_CANDIDATE_MAX_LOCAL_ADDRESSES); + g_assert_cmpuint (ip_local_preference, <, NICE_CANDIDATE_MAX_LOCAL_ADDRESSES); /* test 1 */ g_assert_cmpuint (nice_candidate_jingle_priority (candidate), ==, 1000); /* Host UDP */ candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP; candidate->component_id = 1; - g_assert_cmpuint (nice_candidate_ice_priority (candidate, FALSE, FALSE) , ==, 0x782000FF + 0x100 * ip_local_preference ); + g_assert_cmpuint (nice_candidate_ice_priority (candidate, FALSE, FALSE), ==, 0x782000FF + 0x100 * ip_local_preference ); /* Host UDP reliable */ - g_assert_cmpuint (nice_candidate_ice_priority (candidate, TRUE, FALSE) , ==, 0x3C2000FF + 0x100 * ip_local_preference ); + g_assert_cmpuint (nice_candidate_ice_priority (candidate, TRUE, FALSE), ==, 0x3C2000FF + 0x100 * ip_local_preference ); /* Host tcp-active unreliable */ candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE; g_assert_cmpuint (nice_candidate_ice_priority (candidate, FALSE, FALSE) & 0xFFE000FF, ==, 0x3C8000FF); diff --git a/tests/test-pseudotcp-fuzzy.c b/tests/test-pseudotcp-fuzzy.c index a9bf62f..3c41a9b 100644 --- a/tests/test-pseudotcp-fuzzy.c +++ b/tests/test-pseudotcp-fuzzy.c @@ -173,7 +173,7 @@ readable (PseudoTcpSocket *sock, gpointer data) else { total_wrote += len; - g_assert (total_wrote <= total_read); + g_assert_cmpint (total_wrote, <=, total_read); g_debug ("Written %d bytes, need %d bytes", total_wrote, total_read); if (total_wrote == total_read && feof (in)) { g_assert (reading_done); diff --git a/tests/test-pseudotcp.c b/tests/test-pseudotcp.c index e35138a..e975dd9 100644 --- a/tests/test-pseudotcp.c +++ b/tests/test-pseudotcp.c @@ -124,7 +124,7 @@ static void readable (PseudoTcpSocket *sock, gpointer data) else { total_wrote += len; - g_assert (total_wrote <= total_read); + g_assert_cmpint (total_wrote, <=, total_read); g_debug ("Written %d bytes, need %d bytes", total_wrote, total_read); if (total_wrote == total_read && feof (in)) { g_assert (reading_done); diff --git a/tests/test-restart.c b/tests/test-restart.c index f350313..064cd69 100644 --- a/tests/test-restart.c +++ b/tests/test-restart.c @@ -232,8 +232,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * /* step: add one stream, with RTP+RTCP components, to each agent */ ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); nice_agent_gather_candidates (lagent, ls_id); nice_agent_gather_candidates (ragent, rs_id); @@ -317,11 +317,11 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * g_assert (global_lagent_ibr_received == TRUE); g_assert (global_ragent_ibr_received == TRUE); /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 2); - g_assert (global_ragent_cands == 2); + g_assert_cmpint (global_lagent_cands, ==, 2); + g_assert_cmpint (global_ragent_cands, ==, 2); /* note: verify that agents are in correct state */ - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, ==, NICE_COMPONENT_STATE_READY); /* step: next send a packet (should work during restart) and * then request an ICE restart by resetting the remote @@ -332,7 +332,7 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * /* step: send a new test packet from L ot R */ global_ragent_read = 0; - g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16); + g_assert_cmpint (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678"), ==, 16); /* Both agent have a distinct role at the end of the conncheck */ g_assert (lagent->controlling_mode == TRUE); @@ -362,7 +362,7 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * } /* send another packet after restart */ - g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16); + g_assert_cmpint (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678"), ==, 16); /* step: reset state variables */ global_lagent_ibr_received = FALSE; @@ -384,7 +384,7 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * g_main_loop_run (global_mainloop); /* note: verify that payload was succesfully received */ - g_assert (global_ragent_read == 32); + g_assert_cmpint (global_ragent_read, ==, 32); /* note: verify binding requests were resent after restart */ g_assert (global_lagent_ibr_received == TRUE); g_assert (global_ragent_ibr_received == TRUE); @@ -476,9 +476,9 @@ int main (void) g_debug ("test-restart: TEST STARTS / restart test"); result = run_restart_test (lagent, ragent, &baseaddr); priv_print_global_status (); - g_assert (result == 0); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (result, ==, 0); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, ==, NICE_COMPONENT_STATE_READY); g_object_unref (lagent); g_object_unref (ragent); diff --git a/tests/test-tcp.c b/tests/test-tcp.c index 85a638f..243203c 100644 --- a/tests/test-tcp.c +++ b/tests/test-tcp.c @@ -62,7 +62,7 @@ on_server_connection_available (gpointer user_data) static gboolean on_server_input_available (gpointer user_data) { - g_assert (5 == nice_socket_recv (server, &tmp, 5, buf)); + g_assert_cmpint (5, ==, nice_socket_recv (server, &tmp, 5, buf)); g_assert (nice_address_equal (&tmp, &client->addr)); g_main_loop_quit (mainloop); @@ -73,7 +73,7 @@ on_server_input_available (gpointer user_data) static gboolean on_client_input_available (gpointer user_data) { - g_assert (5 == nice_socket_recv (client, &tmp, 5, buf)); + g_assert_cmpint (5, ==, nice_socket_recv (client, &tmp, 5, buf)); g_assert (nice_address_equal (&tmp, &server->addr)); g_main_loop_quit (mainloop); @@ -139,11 +139,11 @@ main (void) g_assert (nice_address_get_port (&tmp) != 0); - g_assert (5 == nice_socket_send (client, &tmp, 5, "hello")); + g_assert_cmpint (5, ==, nice_socket_send (client, &tmp, 5, "hello")); g_main_loop_run (mainloop); /* -> on_server_input_available */ g_assert (0 == strncmp (buf, "hello", 5)); - g_assert (5 == nice_socket_send (server, &tmp, 5, "uryyb")); + g_assert_cmpint (5, ==, nice_socket_send (server, &tmp, 5, "uryyb")); g_main_loop_run (mainloop); /* -> on_client_input_available */ g_assert (0 == strncmp (buf, "uryyb", 5)); diff --git a/tests/test-thread.c b/tests/test-thread.c index 514a8da..fe5f0f1 100644 --- a/tests/test-thread.c +++ b/tests/test-thread.c @@ -271,7 +271,7 @@ int main (void) g_assert (mode == TRUE); g_object_set (G_OBJECT (lagent), "max-connectivity-checks", 300, NULL); g_object_get (G_OBJECT (lagent), "max-connectivity-checks", &max_checks, NULL); - g_assert (max_checks == 300); + g_assert_cmpuint (max_checks, ==, 300); } /* step: run test the first time */ @@ -285,8 +285,8 @@ int main (void) ls_id = nice_agent_add_stream (lagent, 2); rs_id = nice_agent_add_stream (ragent, 2); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); g_object_set_data (G_OBJECT (lagent), "id", GUINT_TO_POINTER (ls_id)); g_object_set_data (G_OBJECT (ragent), "id", GUINT_TO_POINTER (rs_id)); @@ -336,8 +336,8 @@ int main (void) g_thread_join (rthread); /* note: verify that correct number of local candidates were reported */ - g_assert (g_atomic_int_get (&global_lagent_cands) == 1); - g_assert (g_atomic_int_get (&global_ragent_cands) == 1); + g_assert_cmpint (g_atomic_int_get (&global_lagent_cands), ==, 1); + g_assert_cmpint (g_atomic_int_get (&global_ragent_cands), ==, 1); g_object_add_weak_pointer (G_OBJECT (lagent), (gpointer *) &lagent); g_object_add_weak_pointer (G_OBJECT (ragent), (gpointer *) &ragent); diff --git a/tests/test-trickle.c b/tests/test-trickle.c index cb88555..cb386ac 100644 --- a/tests/test-trickle.c +++ b/tests/test-trickle.c @@ -290,8 +290,8 @@ int main (void) ls_id = nice_agent_add_stream (lagent, 1); rs_id = nice_agent_add_stream (ragent, 1); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); nice_agent_gather_candidates (lagent, ls_id); @@ -350,13 +350,13 @@ int main (void) /* note: verify that STUN binding requests were sent */ g_assert (global_lagent_ibr_received == TRUE); - g_assert (global_ragent_ibr_received == TRUE); + g_assert_cmpint (global_ragent_ibr_received, ==, TRUE); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, ==, NICE_COMPONENT_STATE_READY); /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 1); - g_assert (global_ragent_cands == 1); + g_assert_cmpint (global_lagent_cands, ==, 1); + g_assert_cmpint (global_ragent_cands, ==, 1); g_debug ("test-trickle: agents are ready.. now adding new buggy candidate"); @@ -372,9 +372,9 @@ int main (void) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_CONNECTED); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_CONNECTED); g_main_loop_run (global_mainloop); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); /* g_debug ("test-trickle: buggy candidate worked, testing lower priority cand"); @@ -387,13 +387,13 @@ int main (void) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (cands); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY);*/ + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY);*/ /* note: test payload send and receive */ global_ragent_read = 0; - g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16); + g_assert_cmpint (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678"), ==, 16); g_main_loop_run (global_mainloop); - g_assert (global_ragent_read == 16); + g_assert_cmpint (global_ragent_read, ==, 16); g_debug ("test-trickle: Ran mainloop, removing streams..."); @@ -402,11 +402,11 @@ int main (void) nice_agent_remove_stream (lagent, ls_id); nice_agent_remove_stream (ragent, rs_id); priv_print_global_status (); - g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED); + g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state, >=, NICE_COMPONENT_STATE_CONNECTED); /* note: verify that correct number of local candidates were reported */ - g_assert (global_lagent_cands == 1); - g_assert (global_ragent_cands == 1); + g_assert_cmpint (global_lagent_cands, ==, 1); + g_assert_cmpint (global_ragent_cands, ==, 1); g_object_unref (lagent); diff --git a/tests/test-turn.c b/tests/test-turn.c index 24783d0..e373790 100644 --- a/tests/test-turn.c +++ b/tests/test-turn.c @@ -121,7 +121,7 @@ static void set_candidates (NiceAgent *from, guint from_stream, for (i = cands; i; i = i->next) { NiceCandidate *cand = i->data; if (force_relay) - g_assert (cand->type == NICE_CANDIDATE_TYPE_RELAYED); + g_assert_cmpint (cand->type, ==, NICE_CANDIDATE_TYPE_RELAYED); if (cand->type != NICE_CANDIDATE_TYPE_RELAYED) { cands = g_slist_remove (cands, cand); nice_candidate_free (cand); @@ -215,8 +215,8 @@ run_test(guint turn_port, gboolean is_ipv6, ls_id = nice_agent_add_stream (lagent, 1); rs_id = nice_agent_add_stream (ragent, 1); - g_assert (ls_id > 0); - g_assert (rs_id > 0); + g_assert_cmpuint (ls_id, >, 0); + g_assert_cmpuint (rs_id, >, 0); nice_agent_set_relay_info(lagent, ls_id, 1, localhost, turn_port, TURN_USER, TURN_PASS, turn_type); nice_agent_set_relay_info(ragent, rs_id, 1, @@ -252,8 +252,8 @@ run_test(guint turn_port, gboolean is_ipv6, while (global_lagent_state[0] != NICE_COMPONENT_STATE_READY || global_ragent_state[0] != NICE_COMPONENT_STATE_READY) g_main_context_iteration (NULL, TRUE); - g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY); - g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_lagent_state[0], ==, NICE_COMPONENT_STATE_READY); + g_assert_cmpint (global_ragent_state[0], ==, NICE_COMPONENT_STATE_READY); nice_agent_remove_stream (lagent, ls_id); nice_agent_remove_stream (ragent, rs_id); diff --git a/tests/test-udp-turn-fragmentation.c b/tests/test-udp-turn-fragmentation.c index d482007..99337a2 100644 --- a/tests/test-udp-turn-fragmentation.c +++ b/tests/test-udp-turn-fragmentation.c @@ -185,7 +185,7 @@ tcp_turn_fragmentation (void) if (message->length == 0) { continue; } - g_assert (message->length == vec->size); + g_assert_cmpint (message->length, ==, vec->size); g_assert_cmpmem (message->buffers->buffer, message->length, vec->buffer, message->length); diff --git a/tests/test.c b/tests/test.c index a92b33c..b937c79 100644 --- a/tests/test.c +++ b/tests/test.c @@ -89,7 +89,7 @@ main (void) nice_agent_add_local_address (agent, &addr_local); g_assert (agent->local_addresses != NULL); - g_assert (g_slist_length (agent->local_addresses) == 1); + g_assert_cmpuint (g_slist_length (agent->local_addresses), ==, 1); g_assert (nice_address_equal (agent->local_addresses->data, &addr_local)); /* add a stream */ @@ -98,7 +98,7 @@ main (void) /* adding a stream should cause host candidates to be generated */ candidates = nice_agent_get_local_candidates (agent, stream_id, 1); - g_assert (g_slist_length (candidates) == 1); + g_assert_cmpuint (g_slist_length (candidates), ==, 1); candidate = candidates->data; /* socket manager uses random port number */ nice_address_set_port (&addr_local, 1); |