Add stream id and component id and set the agent properly to avoid a segfault
[sipe-libnice.git] / tests / test-fullmode.c
blobd0aecd49b6b6d6fe91a5d634894383a5ff1037d9
1 /*
2 * This file is part of the Nice GLib ICE library.
4 * Unit test for ICE full-mode related features.
6 * (C) 2007 Nokia Corporation. All rights reserved.
7 * Contact: Kai Vehmanen
9 * The contents of this file are subject to the Mozilla Public License Version
10 * 1.1 (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS" basis,
15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
16 * for the specific language governing rights and limitations under the
17 * License.
19 * The Original Code is the Nice GLib ICE library.
21 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
22 * Corporation. All Rights Reserved.
24 * Contributors:
25 * Kai Vehmanen, Nokia
27 * Alternatively, the contents of this file may be used under the terms of the
28 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
29 * case the provisions of LGPL are applicable instead of those above. If you
30 * wish to allow use of your version of this file only under the terms of the
31 * LGPL and not to allow others to use your version of this file under the
32 * MPL, indicate your decision by deleting the provisions above and replace
33 * them with the notice and other provisions required by the LGPL. If you do
34 * not delete the provisions above, a recipient may use your version of this
35 * file under either the MPL or the LGPL.
37 #ifdef HAVE_CONFIG_H
38 # include <config.h>
39 #endif
41 #include "agent.h"
43 #include <stdlib.h>
44 #include <string.h>
47 #define USE_TURN 0
48 #define USE_LOOPBACK 1
49 #define TEST_GOOGLE 0
51 #define PROXY_IP "127.0.0.1"
52 #define PROXY_PORT 1080
53 #define PROXY_TYPE NICE_PROXY_TYPE_SOCKS5
54 #define PROXY_USERNAME NULL
55 #define PROXY_PASSWORD NULL
58 #if TEST_GOOGLE
59 #define NICE_COMPATIBILITY NICE_COMPATIBILITY_GOOGLE
61 #if USE_TURN
62 #undef USE_LOOPBACK
63 #define USE_LOOPBACK 0
65 #define TURN_IP "209.85.163.126"
66 #define TURN_PORT 443
67 #define TURN_USER "ih9ppiM0P6vN34DB"
68 #define TURN_PASS ""
69 #define TURN_USER2 TURN_USER
70 #define TURN_PASS2 TURN_PASS
71 #define TURN_TYPE NICE_RELAY_TYPE_TURN_TLS
73 #endif
75 #else
76 #define NICE_COMPATIBILITY NICE_COMPATIBILITY_DRAFT19
77 #if USE_LOOPBACK
78 #define USE_TURN_SERVER_ORG 1
79 #else
80 #define USE_TURN_SERVER_ORG 0
81 #endif
83 #define NUMB_IP "64.251.22.149"
84 #define NUMB_PORT 3478
85 #define NUMB_USER "youness.alaoui@collabora.co.uk"
86 #define NUMB_PASS "badger"
88 #define TSORG_IP "127.0.0.1"
89 #define TSORG_PORT 3478
90 #define TSORG_USER "toto"
91 #define TSORG_PASS "password"
94 #if USE_TURN_SERVER_ORG
95 #define TURN_IP TSORG_IP
96 #define TURN_PORT TSORG_PORT
97 #define TURN_USER TSORG_USER
98 #define TURN_PASS TSORG_PASS
99 #define TURN_USER2 TSORG_USER
100 #define TURN_PASS2 TSORG_PASS
101 #define TURN_TYPE NICE_RELAY_TYPE_TURN_TCP
102 #else
103 #define TURN_IP NUMB_IP
104 #define TURN_PORT NUMB_PORT
105 #define TURN_USER NUMB_USER
106 #define TURN_PASS NUMB_PASS
107 #define TURN_USER2 NUMB_USER
108 #define TURN_PASS2 NUMB_PASS
109 #define TURN_TYPE NICE_RELAY_TYPE_TURN_UDP
110 #endif
112 #endif
115 static NiceComponentState global_lagent_state[2] = { NICE_COMPONENT_STATE_LAST, NICE_COMPONENT_STATE_LAST };
116 static NiceComponentState global_ragent_state[2] = { NICE_COMPONENT_STATE_LAST, NICE_COMPONENT_STATE_LAST };
117 static guint global_components_ready = 0;
118 static guint global_components_ready_exit = 0;
119 static guint global_components_failed = 0;
120 static guint global_components_failed_exit = 0;
121 static GMainLoop *global_mainloop = NULL;
122 static gboolean global_lagent_gathering_done = FALSE;
123 static gboolean global_ragent_gathering_done = FALSE;
124 static gboolean global_lagent_ibr_received = FALSE;
125 static gboolean global_ragent_ibr_received = FALSE;
126 static int global_lagent_cands = 0;
127 static int global_ragent_cands = 0;
128 static gint global_ragent_read = 0;
129 static guint global_exit_when_ibr_received = 0;
131 static void priv_print_global_status (void)
133 g_debug ("\tgathering_done=%d", global_lagent_gathering_done && global_ragent_gathering_done);
134 g_debug ("\tlstate[rtp]=%d [rtcp]=%d", global_lagent_state[0], global_lagent_state[1]);
135 g_debug ("\trstate[rtp]=%d [rtcp]=%d", global_ragent_state[0], global_ragent_state[1]);
136 g_debug ("\tL cands=%d R cands=%d", global_lagent_cands, global_ragent_cands);
139 static gboolean timer_cb (gpointer pointer)
141 g_debug ("test-fullmode:%s: %p", G_STRFUNC, pointer);
143 /* signal status via a global variable */
145 /* note: should not be reached, abort */
146 g_error ("ERROR: test has got stuck, aborting...");
149 static void cb_nice_recv (NiceAgent *agent, guint stream_id, guint component_id, guint len, gchar *buf, gpointer user_data)
151 g_debug ("test-fullmode:%s: %p", G_STRFUNC, user_data);
153 /* XXX: dear compiler, these are for you: */
154 (void)agent; (void)stream_id; (void)component_id; (void)buf;
157 * Lets ignore stun packets that got through
159 if (len < 8)
160 return;
161 if (strncmp ("12345678", buf, 8))
162 return;
164 if (GPOINTER_TO_UINT (user_data) == 2) {
165 global_ragent_read = len;
166 g_main_loop_quit (global_mainloop);
170 static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpointer data)
172 g_debug ("test-fullmode:%s: %p", G_STRFUNC, data);
174 if (GPOINTER_TO_UINT (data) == 1)
175 global_lagent_gathering_done = TRUE;
176 else if (GPOINTER_TO_UINT (data) == 2)
177 global_ragent_gathering_done = TRUE;
179 if (global_lagent_gathering_done &&
180 global_ragent_gathering_done)
181 g_main_loop_quit (global_mainloop);
183 /* XXX: dear compiler, these are for you: */
184 (void)agent;
187 static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint component_id, guint state, gpointer data)
189 g_debug ("test-fullmode:%s: %p", __func__, data);
191 if (GPOINTER_TO_UINT (data) == 1)
192 global_lagent_state[component_id - 1] = state;
193 else if (GPOINTER_TO_UINT (data) == 2)
194 global_ragent_state[component_id - 1] = state;
196 if (state == NICE_COMPONENT_STATE_READY)
197 global_components_ready++;
198 if (state == NICE_COMPONENT_STATE_FAILED)
199 global_components_failed++;
201 g_debug ("test-fullmode: checks READY/EXIT-AT %u/%u.", global_components_ready, global_components_ready_exit);
202 g_debug ("test-fullmode: checks FAILED/EXIT-AT %u/%u.", global_components_failed, global_components_failed_exit);
204 /* signal status via a global variable */
205 if (global_components_ready == global_components_ready_exit &&
206 global_components_failed == global_components_failed_exit) {
207 g_main_loop_quit (global_mainloop);
208 return;
211 #if 0
212 /* signal status via a global variable */
213 if (global_components_failed == global_components_failed_exit) {
214 g_main_loop_quit (global_mainloop);
215 return;
217 #endif
219 /* XXX: dear compiler, these are for you: */
220 (void)agent; (void)stream_id; (void)data; (void)component_id;
223 static void cb_new_selected_pair(NiceAgent *agent, guint stream_id, guint component_id,
224 gchar *lfoundation, gchar* rfoundation, gpointer data)
226 g_debug ("test-fullmode:%s: %p", __func__, data);
228 if (GPOINTER_TO_UINT (data) == 1)
229 ++global_lagent_cands;
230 else if (GPOINTER_TO_UINT (data) == 2)
231 ++global_ragent_cands;
233 /* XXX: dear compiler, these are for you: */
234 (void)agent; (void)stream_id; (void)component_id; (void)lfoundation; (void)rfoundation;
237 static void cb_new_candidate(NiceAgent *agent, guint stream_id, guint component_id,
238 gchar *foundation, gpointer data)
240 g_debug ("test-fullmode:%s: %p", __func__, data);
242 /* XXX: dear compiler, these are for you: */
243 (void)agent; (void)stream_id; (void)data; (void)component_id; (void)foundation;
246 static void cb_initial_binding_request_received(NiceAgent *agent, guint stream_id, gpointer data)
248 g_debug ("test-fullmode:%s: %p", __func__, data);
250 if (GPOINTER_TO_UINT (data) == 1)
251 global_lagent_ibr_received = TRUE;
252 else if (GPOINTER_TO_UINT (data) == 2)
253 global_ragent_ibr_received = TRUE;
255 if (global_exit_when_ibr_received)
256 g_main_loop_quit (global_mainloop);
258 /* XXX: dear compiler, these are for you: */
259 (void)agent; (void)stream_id; (void)data;
262 static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint component_id, NiceAddress *dstaddr)
264 GSList *cands, *i;
265 cands = nice_agent_get_local_candidates(agent, stream_id, component_id);
266 for (i = cands; i; i = i->next) {
267 NiceCandidate *cand = i->data;
268 if (cand) {
269 g_assert (dstaddr);
270 *dstaddr = cand->addr;
273 for (i = cands; i; i = i->next)
274 nice_candidate_free ((NiceCandidate *) i->data);
275 g_slist_free (cands);
279 static GSList *priv_get_local_candidate (NiceAgent *agent, guint stream_id, guint component_id)
281 GSList *cands, *i;
282 GSList *result = NULL;
283 NiceCandidate *out_cand = NULL;
284 cands = nice_agent_get_local_candidates(agent, stream_id, component_id);
285 for (i = cands; i; i = i->next) {
286 NiceCandidate *cand = i->data;
287 if (cand) {
288 out_cand = cand;
291 result = g_slist_append (result, nice_candidate_copy (out_cand));
293 for (i = cands; i; i = i->next)
294 nice_candidate_free ((NiceCandidate *) i->data);
295 g_slist_free (cands);
296 return result;
301 static void init_candidate (NiceCandidate *cand)
303 memset (cand, 0, sizeof(NiceCandidate));
305 cand->priority = 10000;
306 strcpy (cand->foundation, "1");
307 cand->type = NICE_CANDIDATE_TYPE_HOST;
308 cand->transport = NICE_CANDIDATE_TRANSPORT_UDP;
311 static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr, guint ready, guint failed)
313 // NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp;
314 NiceCandidate cdes;
315 GSList *cands, *i;
316 guint ls_id, rs_id;
318 init_candidate (&cdes);
320 /* XXX: dear compiler, this is for you */
321 (void)baseaddr;
323 /* step: initialize variables modified by the callbacks */
324 global_components_ready = 0;
325 global_components_ready_exit = ready;
326 global_components_failed = 0;
327 global_components_failed_exit = failed;
328 global_lagent_gathering_done = FALSE;
329 global_ragent_gathering_done = FALSE;
330 global_lagent_ibr_received =
331 global_ragent_ibr_received = FALSE;
332 global_lagent_cands =
333 global_ragent_cands = 0;
335 g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL);
336 g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL);
338 /* step: add one stream, with RTP+RTCP components, to each agent */
339 ls_id = nice_agent_add_stream (lagent, 2);
341 rs_id = nice_agent_add_stream (ragent, 2);
342 g_assert (ls_id > 0);
343 g_assert (rs_id > 0);
344 #if USE_TURN
345 nice_agent_set_relay_info(lagent, ls_id, 1,
346 TURN_IP, TURN_PORT, TURN_USER, TURN_PASS, TURN_TYPE);
347 nice_agent_set_relay_info(lagent, ls_id, 2,
348 TURN_IP, TURN_PORT, TURN_USER, TURN_PASS, TURN_TYPE);
349 nice_agent_set_relay_info(ragent, rs_id, 1,
350 TURN_IP, TURN_PORT, TURN_USER2, TURN_PASS2, TURN_TYPE);
351 nice_agent_set_relay_info(ragent, rs_id, 2,
352 TURN_IP, TURN_PORT, TURN_USER2, TURN_PASS2, TURN_TYPE);
353 #endif
356 nice_agent_gather_candidates (lagent, ls_id);
357 nice_agent_gather_candidates (ragent, rs_id);
359 /* step: attach to mainloop (needed to register the fds) */
360 nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
361 g_main_loop_get_context (global_mainloop), cb_nice_recv,
362 GUINT_TO_POINTER (1));
363 nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP,
364 g_main_loop_get_context (global_mainloop), cb_nice_recv,
365 GUINT_TO_POINTER (1));
366 nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
367 g_main_loop_get_context (global_mainloop), cb_nice_recv,
368 GUINT_TO_POINTER (2));
369 nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP,
370 g_main_loop_get_context (global_mainloop), cb_nice_recv,
371 GUINT_TO_POINTER (2));
373 /* step: run mainloop until local candidates are ready
374 * (see timer_cb() above) */
375 if (global_lagent_gathering_done != TRUE ||
376 global_ragent_gathering_done != TRUE) {
377 g_debug ("test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'...");
378 g_main_loop_run (global_mainloop);
379 g_assert (global_lagent_gathering_done == TRUE);
380 g_assert (global_ragent_gathering_done == TRUE);
383 /* step: find out the local candidates of each agent */
385 /* priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, &raddr);
386 g_debug ("test-fullmode: local RTP port R %u",
387 nice_address_get_port (&raddr));
389 priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, &laddr);
390 g_debug ("test-fullmode: local RTP port L %u",
391 nice_address_get_port (&laddr));
393 priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, &raddr_rtcp);
394 g_debug ("test-fullmode: local RTCP port R %u",
395 nice_address_get_port (&raddr_rtcp));
397 priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, &laddr_rtcp);
398 g_debug ("test-fullmode: local RTCP port L %u",
399 nice_address_get_port (&laddr_rtcp));*/
401 /* step: pass the remote candidates to agents */
402 //cands = g_slist_append (NULL, &cdes);
404 gchar *ufrag = NULL, *password = NULL;
405 nice_agent_get_local_credentials(lagent, ls_id, &ufrag, &password);
406 nice_agent_set_remote_credentials (ragent,
407 rs_id, ufrag, password);
408 g_free (ufrag);
409 g_free (password);
410 nice_agent_get_local_credentials(ragent, rs_id, &ufrag, &password);
411 nice_agent_set_remote_credentials (lagent,
412 ls_id, ufrag, password);
413 g_free (ufrag);
414 g_free (password);
416 /* cdes.component_id = NICE_COMPONENT_TYPE_RTP;
417 cdes.addr = raddr;
418 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
419 cdes.addr = laddr;
420 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
421 cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
422 cdes.addr = raddr_rtcp;
423 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
424 cdes.addr = laddr_rtcp;
425 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
427 g_slist_free (cands);*/
428 cands = priv_get_local_candidate (ragent, rs_id, NICE_COMPONENT_TYPE_RTP);
429 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
430 for (i = cands; i; i = i->next)
431 nice_candidate_free ((NiceCandidate *) i->data);
432 g_slist_free (cands);
433 cands = priv_get_local_candidate (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP);
434 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
435 for (i = cands; i; i = i->next)
436 nice_candidate_free ((NiceCandidate *) i->data);
437 g_slist_free (cands);
438 cands = priv_get_local_candidate (lagent, ls_id, NICE_COMPONENT_TYPE_RTP);
439 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
440 for (i = cands; i; i = i->next)
441 nice_candidate_free ((NiceCandidate *) i->data);
442 g_slist_free (cands);
443 cands = priv_get_local_candidate (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP);
444 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
445 for (i = cands; i; i = i->next)
446 nice_candidate_free ((NiceCandidate *) i->data);
447 g_slist_free (cands);
449 g_debug ("test-fullmode: Set properties, next running mainloop until connectivity checks succeed...");
451 /* step: run the mainloop until connectivity checks succeed
452 * (see timer_cb() above) */
453 g_main_loop_run (global_mainloop);
455 /* note: verify that STUN binding requests were sent */
456 g_assert (global_lagent_ibr_received == TRUE);
457 g_assert (global_ragent_ibr_received == TRUE);
459 /* note: test payload send and receive */
460 global_ragent_read = 0;
461 g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16);
462 g_main_loop_run (global_mainloop);
463 g_assert (global_ragent_read == 16);
465 g_debug ("test-fullmode: Ran mainloop, removing streams...");
467 /* step: clean up resources and exit */
469 nice_agent_remove_stream (lagent, ls_id);
470 nice_agent_remove_stream (ragent, rs_id);
472 return 0;
476 * Simulate the case where answer to the offer is delayed and
477 * some STUN connectivity checks reach the offering party
478 * before it gets the remote SDP information.
480 static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr, guint ready, guint failed)
482 NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp;
483 NiceCandidate cdes;
484 GSList *cands;
485 guint ls_id, rs_id;
487 init_candidate (&cdes);
489 /* XXX: dear compiler, this is for you */
490 (void)baseaddr;
492 /* step: initialize variables modified by the callbacks */
493 global_components_ready = 0;
494 global_components_ready_exit = ready;
495 global_components_failed = 0;
496 global_components_failed_exit = failed;
497 global_lagent_gathering_done = FALSE;
498 global_ragent_gathering_done = FALSE;
499 global_lagent_ibr_received =
500 global_ragent_ibr_received = FALSE;
501 global_exit_when_ibr_received = 1;
502 global_lagent_cands =
503 global_ragent_cands = 0;
505 g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL);
506 g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL);
508 /* step: add one stream, with RTP+RTCP components, to each agent */
509 ls_id = nice_agent_add_stream (lagent, 2);
511 rs_id = nice_agent_add_stream (ragent, 2);
512 g_assert (ls_id > 0);
513 g_assert (rs_id > 0);
515 /* We don't try this with TURN because as long as both agents don't
516 have the remote candidates, they won't be able to create the
517 permission on the TURN server, so the connchecks will never go through */
519 nice_agent_gather_candidates (lagent, ls_id);
520 nice_agent_gather_candidates (ragent, rs_id);
522 /* step: attach to mainloop (needed to register the fds) */
523 nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
524 g_main_loop_get_context (global_mainloop), cb_nice_recv,
525 GUINT_TO_POINTER (1));
526 nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP,
527 g_main_loop_get_context (global_mainloop), cb_nice_recv,
528 GUINT_TO_POINTER (1));
529 nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
530 g_main_loop_get_context (global_mainloop), cb_nice_recv,
531 GUINT_TO_POINTER (2));
532 nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP,
533 g_main_loop_get_context (global_mainloop), cb_nice_recv,
534 GUINT_TO_POINTER (2));
536 /* step: run mainloop until local candidates are ready
537 * (see timer_cb() above) */
538 if (global_lagent_gathering_done != TRUE ||
539 global_ragent_gathering_done != TRUE) {
540 g_debug ("test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'...");
541 g_main_loop_run (global_mainloop);
542 g_assert (global_lagent_gathering_done == TRUE);
543 g_assert (global_ragent_gathering_done == TRUE);
546 /* step: find out the local candidates of each agent */
548 priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, &raddr);
549 g_debug ("test-fullmode: local RTP port R %u",
550 nice_address_get_port (&raddr));
552 priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, &laddr);
553 g_debug ("test-fullmode: local RTP port L %u",
554 nice_address_get_port (&laddr));
556 priv_get_local_addr (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, &raddr_rtcp);
557 g_debug ("test-fullmode: local RTCP port R %u",
558 nice_address_get_port (&raddr_rtcp));
560 priv_get_local_addr (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, &laddr_rtcp);
561 g_debug ("test-fullmode: local RTCP port L %u",
562 nice_address_get_port (&laddr_rtcp));
564 /* step: pass the remote candidates to agent R (answering party) */
566 gchar *ufrag = NULL, *password = NULL;
567 nice_agent_get_local_credentials(lagent, ls_id, &ufrag, &password);
568 nice_agent_set_remote_credentials (ragent,
569 rs_id, ufrag, password);
570 g_free (ufrag);
571 g_free (password);
572 nice_agent_get_local_credentials(ragent, rs_id, &ufrag, &password);
573 nice_agent_set_remote_credentials (lagent,
574 ls_id, ufrag, password);
575 g_free (ufrag);
576 g_free (password);
578 /* step: set remote candidates for agent R (answering party) */
579 cands = g_slist_append (NULL, &cdes);
580 cdes.component_id = NICE_COMPONENT_TYPE_RTP;
581 cdes.addr = laddr;
582 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
583 cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
584 cdes.addr = laddr_rtcp;
585 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
587 g_debug ("test-fullmode: Set properties, next running mainloop until first check is received...");
589 /* step: run the mainloop until first connectivity check receveid */
590 g_main_loop_run (global_mainloop);
591 global_exit_when_ibr_received = 0;
593 /* note: verify that STUN binding requests were sent */
594 g_assert (global_lagent_ibr_received == TRUE);
596 g_debug ("test-fullmode: Delayed answer received, continuing processing..");
598 /* step: pass the remote candidates to agent L (offering party) */
600 gchar *ufrag = NULL, *password = NULL;
601 nice_agent_get_local_credentials(ragent, rs_id, &ufrag, &password);
602 nice_agent_set_remote_credentials (lagent,
603 ls_id, ufrag, password);
604 g_free (ufrag);
605 g_free (password);
606 nice_agent_get_local_credentials(ragent, rs_id, &ufrag, &password);
607 nice_agent_set_remote_credentials (lagent,
608 ls_id, ufrag, password);
609 g_free (ufrag);
610 g_free (password);
613 /* step: pass remove candidates to agent L (offering party) */
614 cdes.component_id = NICE_COMPONENT_TYPE_RTP;
615 cdes.addr = raddr;
616 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
617 cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
618 cdes.addr = raddr_rtcp;
619 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
621 g_debug ("test-fullmode: Running mainloop until connectivity checks succeeed.");
623 g_main_loop_run (global_mainloop);
624 g_assert (global_ragent_ibr_received == TRUE);
625 g_assert (global_components_failed == 0);
627 /* note: test payload send and receive */
628 global_ragent_read = 0;
629 g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16);
630 g_main_loop_run (global_mainloop);
631 g_assert (global_ragent_read == 16);
633 g_debug ("test-fullmode: Ran mainloop, removing streams...");
635 /* step: clean up resources and exit */
637 nice_agent_remove_stream (lagent, ls_id);
638 nice_agent_remove_stream (ragent, rs_id);
640 g_slist_free (cands);
642 return 0;
645 static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr)
647 NiceAddress laddr, raddr;
648 NiceCandidate cdes;
649 GSList *cands, *i;
650 guint ls_id, rs_id;
652 init_candidate (&cdes);
654 /* XXX: dear compiler, this is for you */
655 (void)baseaddr;
657 global_components_ready = 0;
658 global_components_ready_exit = 0;
659 global_components_failed = 0;
660 global_components_failed_exit = 2;
661 global_lagent_state[0] = global_lagent_state[1] =
662 global_ragent_state[0] = global_ragent_state[1]
663 = NICE_COMPONENT_STATE_LAST;
664 global_lagent_gathering_done =
665 global_ragent_gathering_done = FALSE;
666 global_lagent_cands =
667 global_ragent_cands = 0;
669 g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL);
670 g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL);
672 /* step: add one stream, with one component, to each agent */
673 ls_id = nice_agent_add_stream (lagent, 1);
675 rs_id = nice_agent_add_stream (ragent, 1);
676 g_assert (ls_id > 0);
677 g_assert (rs_id > 0);
678 #if USE_TURN
679 nice_agent_set_relay_info(lagent, ls_id, 1,
680 TURN_IP, TURN_PORT, TURN_USER, TURN_PASS, TURN_TYPE);
681 nice_agent_set_relay_info(ragent, rs_id, 1,
682 TURN_IP, TURN_PORT, TURN_USER, TURN_PASS, TURN_TYPE);
683 #endif
685 nice_agent_gather_candidates (lagent, ls_id);
686 nice_agent_gather_candidates (ragent, rs_id);
688 /* step: attach to mainloop (needed to register the fds) */
689 nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
690 g_main_loop_get_context (global_mainloop), cb_nice_recv,
691 GUINT_TO_POINTER (1));
692 nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
693 g_main_loop_get_context (global_mainloop), cb_nice_recv,
694 GUINT_TO_POINTER (2));
696 /* step: run mainloop until local candidates are ready
697 * (see timer_cb() above) */
698 if (global_lagent_gathering_done != TRUE ||
699 global_ragent_gathering_done != TRUE) {
700 g_debug ("test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'...");
701 g_main_loop_run (global_mainloop);
702 g_assert (global_lagent_gathering_done == TRUE);
703 g_assert (global_ragent_gathering_done == TRUE);
706 /* step: find out the local candidates of each agent */
707 cands = nice_agent_get_local_candidates(lagent, ls_id, NICE_COMPONENT_TYPE_RTP);
709 for (i = cands; i; i = i->next) {
710 NiceCandidate *cand = i->data;
711 if (cand) {
712 g_debug ("test-fullmode: local port L %u",
713 nice_address_get_port (&cand->addr));
714 laddr = cand->addr;
717 for (i = cands; i; i = i->next)
718 nice_candidate_free ((NiceCandidate *) i->data);
719 g_slist_free (cands);
721 cands = nice_agent_get_local_candidates(ragent, rs_id, NICE_COMPONENT_TYPE_RTP);
722 for (i = cands; i; i = i->next) {
723 NiceCandidate *cand = i->data;
724 if (cand) {
725 g_debug ("test-fullmode: local port R %u",
726 nice_address_get_port (&cand->addr));
727 raddr = cand->addr;
730 for (i = cands; i; i = i->next)
731 nice_candidate_free ((NiceCandidate *) i->data);
732 g_slist_free (cands);
733 g_debug ("test-fullmode: Got local candidates...");
735 /* step: pass the remote candidates to agents */
736 cands = g_slist_append (NULL, &cdes);
738 gchar *ufrag = NULL, *password = NULL;
739 nice_agent_get_local_credentials(lagent, ls_id, &ufrag, &password);
740 nice_agent_set_remote_credentials (ragent,
741 rs_id, "wrong", password);
742 g_free (ufrag);
743 g_free (password);
744 nice_agent_get_local_credentials(ragent, rs_id, &ufrag, &password);
745 nice_agent_set_remote_credentials (lagent,
746 ls_id, ufrag, "wrong2");
747 g_free (ufrag);
748 g_free (password);
750 cdes.addr = raddr;
751 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
752 cdes.addr = laddr;
753 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
754 g_slist_free (cands);
756 g_debug ("test-fullmode: Set properties, next running mainloop until connectivity checks succeed...");
758 /* step: run the mainloop until connectivity checks succeed
759 * (see timer_cb() above) */
760 g_main_loop_run (global_mainloop);
762 /* note: verify that correct number of local candidates were reported */
763 g_assert (global_lagent_cands == 0);
764 g_assert (global_ragent_cands == 0);
766 g_debug ("test-fullmode: Ran mainloop, removing streams...");
768 /* step: clean up resources and exit */
770 nice_agent_remove_stream (lagent, ls_id);
771 nice_agent_remove_stream (ragent, rs_id);
773 return 0;
776 static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr, gboolean role)
778 NiceAddress laddr, raddr;
779 NiceCandidate cdes;
780 GSList *cands, *i;
781 guint ls_id, rs_id;
783 init_candidate (&cdes);
785 /* XXX: dear compiler, this is for you */
786 (void)baseaddr;
788 global_components_ready = 0;
789 global_components_ready_exit = 2;
790 global_components_failed = 0;
791 global_components_failed_exit = 0;
792 global_lagent_gathering_done =
793 global_ragent_gathering_done = FALSE;
794 global_lagent_cands =
795 global_ragent_cands = 0;
796 global_lagent_ibr_received =
797 global_ragent_ibr_received = FALSE;
799 g_object_set (G_OBJECT (lagent), "controlling-mode", role, NULL);
800 g_object_set (G_OBJECT (ragent), "controlling-mode", role, NULL);
802 /* step: add one stream, with one component, to each agent */
803 ls_id = nice_agent_add_stream (lagent, 1);
805 rs_id = nice_agent_add_stream (ragent, 1);
806 g_assert (ls_id > 0);
807 g_assert (rs_id > 0);
808 #if USE_TURN
809 nice_agent_set_relay_info(lagent, ls_id, 1,
810 TURN_IP, TURN_PORT, TURN_USER, TURN_PASS, TURN_TYPE);
811 nice_agent_set_relay_info(ragent, rs_id, 1,
812 TURN_IP, TURN_PORT, TURN_USER, TURN_PASS, TURN_TYPE);
813 #endif
815 nice_agent_gather_candidates (lagent, ls_id);
816 nice_agent_gather_candidates (ragent, rs_id);
818 /* step: attach to mainloop (needed to register the fds) */
819 nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
820 g_main_loop_get_context (global_mainloop), cb_nice_recv,
821 GUINT_TO_POINTER (1));
822 nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
823 g_main_loop_get_context (global_mainloop), cb_nice_recv,
824 GUINT_TO_POINTER (2));
826 /* step: run mainloop until local candidates are ready
827 * (see timer_cb() above) */
828 if (global_lagent_gathering_done != TRUE ||
829 global_ragent_gathering_done != TRUE) {
830 g_debug ("test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'...");
831 g_main_loop_run (global_mainloop);
832 g_assert (global_lagent_gathering_done == TRUE);
833 g_assert (global_ragent_gathering_done == TRUE);
836 /* step: find out the local candidates of each agent */
837 cands = nice_agent_get_local_candidates(lagent, ls_id, NICE_COMPONENT_TYPE_RTP);
838 for (i = cands; i; i = i->next) {
839 NiceCandidate *cand = i->data;
840 if (cand) {
841 g_debug ("test-fullmode: local port L %u",
842 nice_address_get_port (&cand->addr));
843 laddr = cand->addr;
846 for (i = cands; i; i = i->next)
847 nice_candidate_free ((NiceCandidate *) i->data);
848 g_slist_free (cands);
850 cands = nice_agent_get_local_candidates(ragent, rs_id, NICE_COMPONENT_TYPE_RTP);
851 for (i = cands; i; i = i->next) {
852 NiceCandidate *cand = i->data;
853 if (cand) {
854 g_debug ("test-fullmode: local port R %u",
855 nice_address_get_port (&cand->addr));
856 raddr = cand->addr;
859 for (i = cands; i; i = i->next)
860 nice_candidate_free ((NiceCandidate *) i->data);
861 g_slist_free (cands);
862 g_debug ("test-fullmode: Got local candidates...");
864 /* step: pass the remote candidates to agents */
865 cands = g_slist_append (NULL, &cdes);
867 gchar *ufrag = NULL, *password = NULL;
868 nice_agent_get_local_credentials(lagent, ls_id, &ufrag, &password);
869 nice_agent_set_remote_credentials (ragent,
870 rs_id, ufrag, password);
871 g_free (ufrag);
872 g_free (password);
873 nice_agent_get_local_credentials(ragent, rs_id, &ufrag, &password);
874 nice_agent_set_remote_credentials (lagent,
875 ls_id, ufrag, password);
876 g_free (ufrag);
877 g_free (password);
879 cdes.addr = raddr;
880 nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
881 cdes.addr = laddr;
882 nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
883 g_slist_free (cands);
885 g_debug ("test-fullmode: Set properties, next running mainloop until connectivity checks succeed...");
887 /* step: run the mainloop until connectivity checks succeed
888 * (see timer_cb() above) */
889 g_main_loop_run (global_mainloop);
891 /* note: verify that correct number of local candidates were reported */
892 g_assert (global_lagent_cands == 1);
893 g_assert (global_ragent_cands == 1);
895 g_debug ("test-fullmode: Ran mainloop, removing streams...");
897 /* step: clean up resources and exit */
899 nice_agent_remove_stream (lagent, ls_id);
900 nice_agent_remove_stream (ragent, rs_id);
902 return 0;
905 int main (void)
907 NiceAgent *lagent, *ragent; /* agent's L and R */
908 NiceAddress baseaddr;
909 int result;
910 guint timer_id;
911 const char *stun_server = NULL, *stun_server_port = NULL;
913 g_type_init ();
914 g_thread_init (NULL);
915 global_mainloop = g_main_loop_new (NULL, FALSE);
917 /* Note: impl limits ...
918 * - no multi-stream support
919 * - no IPv6 support
922 /* step: create the agents L and R */
923 lagent = nice_agent_new (g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY);
924 ragent = nice_agent_new (g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY);
926 /* step: add a timer to catch state changes triggered by signals */
927 #if USE_TURN
928 timer_id = g_timeout_add (300000, timer_cb, NULL);
929 #else
930 timer_id = g_timeout_add (30000, timer_cb, NULL);
931 #endif
933 /* step: specify which local interface to use */
934 #if USE_LOOPBACK
935 if (!nice_address_set_from_string (&baseaddr, "127.0.0.1"))
936 g_assert_not_reached ();
937 nice_agent_add_local_address (lagent, &baseaddr);
938 nice_agent_add_local_address (ragent, &baseaddr);
939 #else
940 if (!nice_address_set_from_string (&baseaddr, "192.168.1.110"))
941 g_assert_not_reached ();
942 nice_agent_add_local_address (lagent, &baseaddr);
943 nice_agent_add_local_address (ragent, &baseaddr);
944 #endif
946 g_signal_connect (G_OBJECT (lagent), "candidate-gathering-done",
947 G_CALLBACK (cb_candidate_gathering_done), GUINT_TO_POINTER(1));
948 g_signal_connect (G_OBJECT (ragent), "candidate-gathering-done",
949 G_CALLBACK (cb_candidate_gathering_done), GUINT_TO_POINTER (2));
950 g_signal_connect (G_OBJECT (lagent), "component-state-changed",
951 G_CALLBACK (cb_component_state_changed), GUINT_TO_POINTER (1));
952 g_signal_connect (G_OBJECT (ragent), "component-state-changed",
953 G_CALLBACK (cb_component_state_changed), GUINT_TO_POINTER (2));
954 g_signal_connect (G_OBJECT (lagent), "new-selected-pair",
955 G_CALLBACK (cb_new_selected_pair), GUINT_TO_POINTER(1));
956 g_signal_connect (G_OBJECT (ragent), "new-selected-pair",
957 G_CALLBACK (cb_new_selected_pair), GUINT_TO_POINTER (2));
958 g_signal_connect (G_OBJECT (lagent), "new-candidate",
959 G_CALLBACK (cb_new_candidate), GUINT_TO_POINTER (1));
960 g_signal_connect (G_OBJECT (ragent), "new-candidate",
961 G_CALLBACK (cb_new_candidate), GUINT_TO_POINTER (2));
962 g_signal_connect (G_OBJECT (lagent), "initial-binding-request-received",
963 G_CALLBACK (cb_initial_binding_request_received),
964 GUINT_TO_POINTER (1));
965 g_signal_connect (G_OBJECT (ragent), "initial-binding-request-received",
966 G_CALLBACK (cb_initial_binding_request_received),
967 GUINT_TO_POINTER (2));
969 stun_server = getenv ("NICE_STUN_SERVER");
970 stun_server_port = getenv ("NICE_STUN_SERVER_PORT");
971 if (stun_server) {
972 g_object_set (G_OBJECT (lagent), "stun-server", stun_server, NULL);
973 g_object_set (G_OBJECT (lagent), "stun-server-port", atoi (stun_server_port), NULL);
974 g_object_set (G_OBJECT (ragent), "stun-server", stun_server, NULL);
975 g_object_set (G_OBJECT (ragent), "stun-server-port", atoi (stun_server_port), NULL);
978 g_object_set (G_OBJECT (lagent), "proxy-ip", PROXY_IP, NULL);
979 g_object_set (G_OBJECT (lagent), "proxy-port", PROXY_PORT, NULL);
980 g_object_set (G_OBJECT (lagent), "proxy-type", PROXY_TYPE, NULL);
981 g_object_set (G_OBJECT (lagent), "proxy-username", PROXY_USERNAME, NULL);
982 g_object_set (G_OBJECT (lagent), "proxy-password", PROXY_PASSWORD, NULL);
983 g_object_set (G_OBJECT (ragent), "proxy-ip", PROXY_IP, NULL);
984 g_object_set (G_OBJECT (ragent), "proxy-port", PROXY_PORT, NULL);
985 g_object_set (G_OBJECT (ragent), "proxy-type", PROXY_TYPE, NULL);
986 g_object_set (G_OBJECT (ragent), "proxy-username", PROXY_USERNAME, NULL);
987 g_object_set (G_OBJECT (ragent), "proxy-password", PROXY_PASSWORD, NULL);
989 /* step: test setter/getter functions for properties */
991 guint max_checks = 0;
992 gchar *string = NULL;
993 guint port = 0;
994 gboolean mode = FALSE;
995 g_object_get (G_OBJECT (lagent), "stun-server", &string, NULL);
996 g_assert (stun_server == NULL || strcmp (string, stun_server) == 0);
997 g_free (string);
998 g_object_get (G_OBJECT (lagent), "stun-server-port", &port, NULL);
999 g_assert (stun_server_port == NULL || port == (guint)atoi (stun_server_port));
1000 g_object_get (G_OBJECT (lagent), "proxy-ip", &string, NULL);
1001 g_assert (strcmp (string, PROXY_IP) == 0);
1002 g_free (string);
1003 g_object_get (G_OBJECT (lagent), "proxy-port", &port, NULL);
1004 g_assert (port == PROXY_PORT);
1005 g_object_get (G_OBJECT (lagent), "controlling-mode", &mode, NULL);
1006 g_assert (mode == TRUE);
1007 g_object_set (G_OBJECT (lagent), "max-connectivity-checks", 300, NULL);
1008 g_object_get (G_OBJECT (lagent), "max-connectivity-checks", &max_checks, NULL);
1009 g_assert (max_checks == 300);
1012 /* step: run test the first time */
1013 g_debug ("test-fullmode: TEST STARTS / running test for the 1st time");
1014 result = run_full_test (lagent, ragent, &baseaddr, 4 ,0);
1015 priv_print_global_status ();
1016 g_assert (result == 0);
1017 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY);
1018 g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY);
1019 g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
1020 g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
1021 /* note: verify that correct number of local candidates were reported */
1022 g_assert (global_lagent_cands == 2);
1023 g_assert (global_ragent_cands == 2);
1026 /* step: run test again without unref'ing agents */
1027 g_debug ("test-fullmode: TEST STARTS / running test for the 2nd time");
1028 result = run_full_test (lagent, ragent, &baseaddr, 4, 0);
1029 priv_print_global_status ();
1030 g_assert (result == 0);
1031 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY);
1032 g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY);
1033 g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
1034 g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
1035 /* note: verify that correct number of local candidates were reported */
1036 g_assert (global_lagent_cands == 2);
1037 g_assert (global_ragent_cands == 2);
1039 #if TEST_GOOGLE
1040 return result;
1041 #endif
1043 /* step: run test simulating delayed SDP answer */
1044 g_debug ("test-fullmode: TEST STARTS / delayed SDP answer");
1045 result = run_full_test_delayed_answer (lagent, ragent, &baseaddr, 4, 0);
1046 priv_print_global_status ();
1047 g_assert (result == 0);
1048 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY);
1049 g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY);
1050 g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
1051 g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
1052 /* note: verify that correct number of local candidates were reported */
1053 g_assert (global_lagent_cands == 2);
1054 g_assert (global_ragent_cands == 2);
1057 /* run test with incorrect credentials (make sure process fails) */
1058 g_debug ("test-fullmode: TEST STARTS / incorrect credentials");
1059 result = run_full_test_wrong_password (lagent, ragent, &baseaddr);
1060 priv_print_global_status ();
1061 g_assert (result == 0);
1062 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_FAILED);
1063 g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_LAST);
1064 g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_FAILED);
1065 g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_LAST);
1067 /* The max connectivity checks test can't be run with TURN because
1068 we'll have 3 local candidates instead of 1 and the checks will
1069 be random, so we can't predict how many will fail/succeed */
1070 #if USE_TURN == 0
1072 /* step: run test with a hard limit for connecitivity checks */
1073 g_debug ("test-fullmode: TEST STARTS / max connectivity checks");
1074 g_object_set (G_OBJECT (lagent), "max-connectivity-checks", 1, NULL);
1075 g_object_set (G_OBJECT (ragent), "max-connectivity-checks", 1, NULL);
1076 result = run_full_test (lagent, ragent, &baseaddr, 2, 2);
1077 priv_print_global_status ();
1078 g_assert (result == 0);
1079 /* should FAIL as agent L can't send any checks: */
1080 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_FAILED ||
1081 global_lagent_state[1] == NICE_COMPONENT_STATE_FAILED);
1082 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_FAILED ||
1083 global_lagent_state[1] == NICE_COMPONENT_STATE_FAILED);
1084 #endif
1086 g_object_set (G_OBJECT (lagent), "max-connectivity-checks", 100, NULL);
1087 g_object_set (G_OBJECT (ragent), "max-connectivity-checks", 100, NULL);
1088 result = run_full_test (lagent, ragent, &baseaddr, 4, 0);
1089 priv_print_global_status ();
1090 /* should SUCCEED as agent L can send the checks: */
1091 g_assert (result == 0);
1092 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY);
1093 g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY);
1094 g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
1095 g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
1096 g_object_set (G_OBJECT (lagent), "max-connectivity-checks", 100, NULL);
1098 /* run test with a conflict in controlling mode: controlling-controlling */
1099 g_debug ("test-fullmode: TEST STARTS / controlling mode conflict case-1");
1100 result = run_full_test_control_conflict (lagent, ragent, &baseaddr, TRUE);
1101 priv_print_global_status ();
1102 g_assert (result == 0);
1104 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY);
1105 g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY);
1106 g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
1107 g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
1109 /* run test with a conflict in controlling mode: controlled-controlled */
1110 g_debug ("test-fullmode: TEST STARTS / controlling mode conflict case-2");
1111 result = run_full_test_control_conflict (lagent, ragent, &baseaddr, FALSE);
1112 priv_print_global_status ();
1113 g_assert (result == 0);
1114 g_assert (global_lagent_state[0] == NICE_COMPONENT_STATE_READY);
1115 g_assert (global_lagent_state[1] == NICE_COMPONENT_STATE_READY);
1116 g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
1117 g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
1119 g_object_unref (lagent);
1120 g_object_unref (ragent);
1122 g_main_loop_unref (global_mainloop);
1123 global_mainloop = NULL;
1125 g_source_remove (timer_id);
1127 return result;