Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
8e257029
Commit
8e257029
authored
Nov 01, 2021
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Use g_assert_true() instead of g_assert() everywhere
parent
69c2015c
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
350 additions
and
350 deletions
+350
-350
tests/test-add-remove-stream.c
tests/test-add-remove-stream.c
+2
-2
tests/test-address.c
tests/test-address.c
+53
-53
tests/test-bsd.c
tests/test-bsd.c
+14
-14
tests/test-build-io-stream.c
tests/test-build-io-stream.c
+50
-50
tests/test-consent.c
tests/test-consent.c
+11
-11
tests/test-credentials.c
tests/test-credentials.c
+4
-4
tests/test-different-number-streams.c
tests/test-different-number-streams.c
+5
-5
tests/test-drop-invalid.c
tests/test-drop-invalid.c
+17
-17
tests/test-fallback.c
tests/test-fallback.c
+13
-13
tests/test-fullmode.c
tests/test-fullmode.c
+28
-28
tests/test-icetcp.c
tests/test-icetcp.c
+8
-8
tests/test-interfaces.c
tests/test-interfaces.c
+7
-7
tests/test-io-stream-common.c
tests/test-io-stream-common.c
+6
-6
tests/test-new-trickle.c
tests/test-new-trickle.c
+32
-32
tests/test-nomination.c
tests/test-nomination.c
+5
-5
tests/test-pseudotcp-fin.c
tests/test-pseudotcp-fin.c
+17
-17
tests/test-pseudotcp-fuzzy.c
tests/test-pseudotcp-fuzzy.c
+3
-3
tests/test-pseudotcp.c
tests/test-pseudotcp.c
+3
-3
tests/test-restart.c
tests/test-restart.c
+11
-11
tests/test-send-recv.c
tests/test-send-recv.c
+1
-1
tests/test-set-port-range.c
tests/test-set-port-range.c
+3
-3
tests/test-socket-is-based-on.c
tests/test-socket-is-based-on.c
+16
-16
tests/test-tcp.c
tests/test-tcp.c
+14
-14
tests/test-thread.c
tests/test-thread.c
+9
-9
tests/test-trickle.c
tests/test-trickle.c
+3
-3
tests/test-turn.c
tests/test-turn.c
+7
-7
tests/test.c
tests/test.c
+8
-8
No files found.
tests/test-add-remove-stream.c
View file @
8e257029
...
@@ -65,13 +65,13 @@ main (void)
...
@@ -65,13 +65,13 @@ main (void)
g_assert_cmpuint
(
nice_agent_add_stream
(
agent
,
10
),
==
,
2
);
g_assert_cmpuint
(
nice_agent_add_stream
(
agent
,
10
),
==
,
2
);
g_assert_cmpuint
(
nice_agent_add_stream
(
agent
,
2
),
==
,
3
);
g_assert_cmpuint
(
nice_agent_add_stream
(
agent
,
2
),
==
,
3
);
g_assert
(
NULL
!=
agent
->
streams
);
g_assert
_true
(
NULL
!=
agent
->
streams
);
nice_agent_remove_stream
(
agent
,
1
);
nice_agent_remove_stream
(
agent
,
1
);
nice_agent_remove_stream
(
agent
,
2
);
nice_agent_remove_stream
(
agent
,
2
);
nice_agent_remove_stream
(
agent
,
3
);
nice_agent_remove_stream
(
agent
,
3
);
g_assert
(
NULL
==
agent
->
streams
);
g_assert
_true
(
NULL
==
agent
->
streams
);
g_object_unref
(
agent
);
g_object_unref
(
agent
);
#ifdef G_OS_WIN32
#ifdef G_OS_WIN32
...
...
tests/test-address.c
View file @
8e257029
...
@@ -61,7 +61,7 @@ test_ipv4 (void)
...
@@ -61,7 +61,7 @@ test_ipv4 (void)
/* same address */
/* same address */
nice_address_set_ipv4
(
&
other
,
0x01020304
);
nice_address_set_ipv4
(
&
other
,
0x01020304
);
g_assert
(
TRUE
==
nice_address_equal
(
&
addr
,
&
other
));
g_assert
_true
(
TRUE
==
nice_address_equal
(
&
addr
,
&
other
));
/* from sockaddr_in */
/* from sockaddr_in */
nice_address_set_port
(
&
other
,
9876
);
/* in native byte order */
nice_address_set_port
(
&
other
,
9876
);
/* in native byte order */
...
@@ -70,84 +70,84 @@ test_ipv4 (void)
...
@@ -70,84 +70,84 @@ test_ipv4 (void)
nice_address_set_port
(
&
addr
,
9876
);
/* in native byte order */
nice_address_set_port
(
&
addr
,
9876
);
/* in native byte order */
nice_address_to_string
(
&
addr
,
str
);
nice_address_to_string
(
&
addr
,
str
);
nice_address_to_string
(
&
other
,
str
);
nice_address_to_string
(
&
other
,
str
);
g_assert
(
TRUE
==
nice_address_equal
(
&
addr
,
&
other
));
g_assert
_true
(
TRUE
==
nice_address_equal
(
&
addr
,
&
other
));
/* different IP */
/* different IP */
nice_address_set_ipv4
(
&
other
,
0x01020305
);
nice_address_set_ipv4
(
&
other
,
0x01020305
);
g_assert
(
FALSE
==
nice_address_equal
(
&
addr
,
&
other
));
g_assert
_true
(
FALSE
==
nice_address_equal
(
&
addr
,
&
other
));
/* different port */
/* different port */
nice_address_set_ipv4
(
&
other
,
0x01020304
);
nice_address_set_ipv4
(
&
other
,
0x01020304
);
nice_address_set_port
(
&
addr
,
1
);
nice_address_set_port
(
&
addr
,
1
);
g_assert
(
FALSE
==
nice_address_equal
(
&
addr
,
&
other
));
g_assert
_true
(
FALSE
==
nice_address_equal
(
&
addr
,
&
other
));
/* test private address check */
/* test private address check */
{
{
NiceAddress
*
heap_addr
=
nice_address_new
();
NiceAddress
*
heap_addr
=
nice_address_new
();
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"127.0.0.1.1"
)
!=
TRUE
);
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"127.0.0.1.1"
)
!=
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"127.0.0.1"
)
==
TRUE
);
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"127.0.0.1"
)
==
TRUE
);
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"127.1.1.1"
)
==
TRUE
);
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"127.1.1.1"
)
==
TRUE
);
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"192.168.2.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"192.168.2.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"192.168.15.69"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"192.168.15.69"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"192.169.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"192.169.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"192.167.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"192.167.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"10.2.1.2"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"10.2.1.2"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"11.0.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"11.0.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"9.255.255.255"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"9.255.255.255"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"172.15.255.255"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"172.15.255.255"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"172.16.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"172.16.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"172.31.255.255"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"172.31.255.255"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"172.32.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"172.32.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"172.63.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"172.63.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"169.253.255.255"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"169.253.255.255"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"169.254.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"169.254.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"169.254.255.255"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"169.254.255.255"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"169.255.0.0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"169.255.0.0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"fe70::0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"fe70::0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
FALSE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"fe80::0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"fe80::0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
(
nice_address_set_from_string
(
heap_addr
,
"fe81::0"
));
g_assert
_true
(
nice_address_set_from_string
(
heap_addr
,
"fe81::0"
));
g_assert
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
heap_addr
)
==
TRUE
);
nice_address_free
(
heap_addr
);
nice_address_free
(
heap_addr
);
}
}
...
@@ -163,7 +163,7 @@ test_ipv6 (void)
...
@@ -163,7 +163,7 @@ test_ipv6 (void)
struct
sockaddr
addr
;
struct
sockaddr
addr
;
}
sin
,
sin2
;
}
sin
,
sin2
;
g_assert
(
nice_address_set_from_string
(
&
v4addr
,
"172.1.0.1"
)
==
TRUE
);
g_assert
_true
(
nice_address_set_from_string
(
&
v4addr
,
"172.1.0.1"
)
==
TRUE
);
memset
(
&
sin
,
0
,
sizeof
(
sin
));
memset
(
&
sin
,
0
,
sizeof
(
sin
));
memset
(
&
sin2
,
0
,
sizeof
(
sin2
));
memset
(
&
sin2
,
0
,
sizeof
(
sin2
));
...
@@ -188,7 +188,7 @@ test_ipv6 (void)
...
@@ -188,7 +188,7 @@ test_ipv6 (void)
nice_address_copy_to_sockaddr
(
&
other
,
&
sin2
.
addr
);
nice_address_copy_to_sockaddr
(
&
other
,
&
sin2
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_address_equal
(
&
addr
,
&
other
)
==
TRUE
);
g_assert
_true
(
nice_address_equal
(
&
addr
,
&
other
)
==
TRUE
);
nice_address_to_string
(
&
addr
,
str
);
nice_address_to_string
(
&
addr
,
str
);
nice_address_to_string
(
&
other
,
str
);
nice_address_to_string
(
&
other
,
str
);
...
@@ -200,20 +200,20 @@ test_ipv6 (void)
...
@@ -200,20 +200,20 @@ test_ipv6 (void)
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x01
"
);
"
\x00\x00\x00\x01
"
);
g_assert
(
nice_address_is_private
(
&
addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
&
addr
)
==
TRUE
);
nice_address_set_ipv6
(
&
addr
,
(
guchar
*
)
nice_address_set_ipv6
(
&
addr
,
(
guchar
*
)
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x00
"
"
\x00\x00\x00\x01
"
);
"
\x00\x00\x00\x01
"
);
g_assert
(
nice_address_is_private
(
&
addr
)
==
TRUE
);
g_assert
_true
(
nice_address_is_private
(
&
addr
)
==
TRUE
);
/* mismatching address families */
/* mismatching address families */
g_assert
(
nice_address_equal
(
&
addr
,
&
v4addr
)
!=
TRUE
);
g_assert
_true
(
nice_address_equal
(
&
addr
,
&
v4addr
)
!=
TRUE
);
/* mismatched type */
/* mismatched type */
addr
.
s
.
addr
.
sa_family
=
AF_UNSPEC
;
addr
.
s
.
addr
.
sa_family
=
AF_UNSPEC
;
/*g_assert (nice_address_equal (&addr, &v4addr) != TRUE);*/
/*g_assert
_true
(nice_address_equal (&addr, &v4addr) != TRUE);*/
}
}
int
int
...
...
tests/test-bsd.c
View file @
8e257029
...
@@ -65,7 +65,7 @@ test_socket_initial_properties (void)
...
@@ -65,7 +65,7 @@ test_socket_initial_properties (void)
sock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
sock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
sock
!=
NULL
);
g_assert
_true
(
sock
!=
NULL
);
// not bound to a particular interface
// not bound to a particular interface
g_assert_cmpint
(
sock
->
addr
.
s
.
ip4
.
sin_addr
.
s_addr
,
==
,
0
);
g_assert_cmpint
(
sock
->
addr
.
s
.
ip4
.
sin_addr
.
s_addr
,
==
,
0
);
...
@@ -84,9 +84,9 @@ test_socket_address_properties (void)
...
@@ -84,9 +84,9 @@ test_socket_address_properties (void)
sock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
sock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
sock
!=
NULL
);
g_assert
_true
(
sock
!=
NULL
);
g_assert
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert_cmpuint
(
nice_address_get_port
(
&
sock
->
addr
),
!=
,
0
);
g_assert_cmpuint
(
nice_address_get_port
(
&
sock
->
addr
),
!=
,
0
);
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
sock
->
addr
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
sock
->
addr
));
g_assert_cmpuint
(
nice_address_get_port
(
&
tmp
),
!=
,
0
);
g_assert_cmpuint
(
nice_address_get_port
(
&
tmp
),
!=
,
0
);
...
@@ -105,13 +105,13 @@ test_simple_send_recv (void)
...
@@ -105,13 +105,13 @@ test_simple_send_recv (void)
server
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
server
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
server
!=
NULL
);
g_assert
_true
(
server
!=
NULL
);
client
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
client
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
client
!=
NULL
);
g_assert
_true
(
client
!=
NULL
);
g_assert
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
/* Send and receive stuff. */
/* Send and receive stuff. */
...
@@ -143,9 +143,9 @@ test_zero_send_recv (void)
...
@@ -143,9 +143,9 @@ test_zero_send_recv (void)
sock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
sock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
sock
!=
NULL
);
g_assert
_true
(
sock
!=
NULL
);
g_assert
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert_cmpuint
(
nice_address_get_port
(
&
sock
->
addr
),
!=
,
0
);
g_assert_cmpuint
(
nice_address_get_port
(
&
sock
->
addr
),
!=
,
0
);
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
sock
->
addr
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
sock
->
addr
));
g_assert_cmpuint
(
nice_address_get_port
(
&
tmp
),
!=
,
0
);
g_assert_cmpuint
(
nice_address_get_port
(
&
tmp
),
!=
,
0
);
...
@@ -181,13 +181,13 @@ test_multi_buffer_recv (void)
...
@@ -181,13 +181,13 @@ test_multi_buffer_recv (void)
server
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
server
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
server
!=
NULL
);
g_assert
_true
(
server
!=
NULL
);
client
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
client
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
client
!=
NULL
);
g_assert
_true
(
client
!=
NULL
);
g_assert
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
/* Send and receive stuff. */
/* Send and receive stuff. */
...
@@ -255,13 +255,13 @@ test_multi_message_recv (guint n_sends, guint n_receives,
...
@@ -255,13 +255,13 @@ test_multi_message_recv (guint n_sends, guint n_receives,
server
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
server
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
server
!=
NULL
);
g_assert
_true
(
server
!=
NULL
);
client
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
client
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
client
!=
NULL
);
g_assert
_true
(
client
!=
NULL
);
g_assert
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
/* Send and receive stuff. */
/* Send and receive stuff. */
...
...
tests/test-build-io-stream.c
View file @
8e257029
...
@@ -57,7 +57,7 @@ test_invalid_stream (NiceAddress *addr)
...
@@ -57,7 +57,7 @@ test_invalid_stream (NiceAddress *addr)
/* Try building an I/O stream for an invalid stream. All its operations should
/* Try building an I/O stream for an invalid stream. All its operations should
* return G_IO_ERROR_BROKEN_PIPE. */
* return G_IO_ERROR_BROKEN_PIPE. */
io_stream
=
nice_agent_get_io_stream
(
agent
,
5
,
5
);
io_stream
=
nice_agent_get_io_stream
(
agent
,
5
,
5
);
g_assert
(
io_stream
==
NULL
);
g_assert
_true
(
io_stream
==
NULL
);
g_object_unref
(
agent
);
g_object_unref
(
agent
);
}
}
...
@@ -79,36 +79,36 @@ test_io_stream_properties (NiceAddress *addr)
...
@@ -79,36 +79,36 @@ test_io_stream_properties (NiceAddress *addr)
/* Try building an I/O stream around it. */
/* Try building an I/O stream around it. */
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
g_assert
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
(
NICE_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
NICE_IS_IO_STREAM
(
io_stream
));
/* Check various initial properties. */
/* Check various initial properties. */
g_assert
(
!
g_io_stream_is_closed
(
G_IO_STREAM
(
io_stream
)));
g_assert
_true
(
!
g_io_stream_is_closed
(
G_IO_STREAM
(
io_stream
)));
g_assert
(
!
g_io_stream_has_pending
(
G_IO_STREAM
(
io_stream
)));
g_assert
_true
(
!
g_io_stream_has_pending
(
G_IO_STREAM
(
io_stream
)));
/* Check the input stream’s properties. */
/* Check the input stream’s properties. */
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
g_assert
(
G_IS_INPUT_STREAM
(
input_stream
));
g_assert
_true
(
G_IS_INPUT_STREAM
(
input_stream
));
g_assert
(
NICE_IS_INPUT_STREAM
(
input_stream
));
g_assert
_true
(
NICE_IS_INPUT_STREAM
(
input_stream
));
g_assert
(
!
g_input_stream_is_closed
(
input_stream
));
g_assert
_true
(
!
g_input_stream_is_closed
(
input_stream
));
g_assert
(
!
g_input_stream_has_pending
(
input_stream
));
g_assert
_true
(
!
g_input_stream_has_pending
(
input_stream
));
/* Check the output stream’s properties. */
/* Check the output stream’s properties. */
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
g_assert
(
G_IS_OUTPUT_STREAM
(
output_stream
));
g_assert
_true
(
G_IS_OUTPUT_STREAM
(
output_stream
));
g_assert
(
NICE_IS_OUTPUT_STREAM
(
output_stream
));
g_assert
_true
(
NICE_IS_OUTPUT_STREAM
(
output_stream
));
g_assert
(
!
g_output_stream_is_closing
(
output_stream
));
g_assert
_true
(
!
g_output_stream_is_closing
(
output_stream
));
g_assert
(
!
g_output_stream_is_closed
(
output_stream
));
g_assert
_true
(
!
g_output_stream_is_closed
(
output_stream
));
g_assert
(
!
g_output_stream_has_pending
(
output_stream
));
g_assert
_true
(
!
g_output_stream_has_pending
(
output_stream
));
/* Remove the component and check that the I/O streams close. */
/* Remove the component and check that the I/O streams close. */
nice_agent_remove_stream
(
agent
,
stream_id
);
nice_agent_remove_stream
(
agent
,
stream_id
);
g_assert
(
g_io_stream_is_closed
(
G_IO_STREAM
(
io_stream
)));
g_assert
_true
(
g_io_stream_is_closed
(
G_IO_STREAM
(
io_stream
)));
g_assert
(
g_input_stream_is_closed
(
input_stream
));
g_assert
_true
(
g_input_stream_is_closed
(
input_stream
));
g_assert
(
g_output_stream_is_closed
(
output_stream
));
g_assert
_true
(
g_output_stream_is_closed
(
output_stream
));
g_object_unref
(
io_stream
);
g_object_unref
(
io_stream
);
g_object_unref
(
agent
);
g_object_unref
(
agent
);
...
@@ -137,18 +137,18 @@ test_pollable_properties (NiceAddress *addr)
...
@@ -137,18 +137,18 @@ test_pollable_properties (NiceAddress *addr)
/* Try building an I/O stream around it. */
/* Try building an I/O stream around it. */
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
g_assert
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
(
NICE_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
NICE_IS_IO_STREAM
(
io_stream
));
/* Check the input stream’s properties. */
/* Check the input stream’s properties. */
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
g_assert
(
G_IS_POLLABLE_INPUT_STREAM
(
input_stream
));
g_assert
_true
(
G_IS_POLLABLE_INPUT_STREAM
(
input_stream
));
pollable_input_stream
=
G_POLLABLE_INPUT_STREAM
(
input_stream
);
pollable_input_stream
=
G_POLLABLE_INPUT_STREAM
(
input_stream
);
g_assert
(
g_pollable_input_stream_can_poll
(
pollable_input_stream
));
g_assert
_true
(
g_pollable_input_stream_can_poll
(
pollable_input_stream
));
g_assert
(
!
g_pollable_input_stream_is_readable
(
pollable_input_stream
));
g_assert
_true
(
!
g_pollable_input_stream_is_readable
(
pollable_input_stream
));
g_assert
(
g_assert
_true
(
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
-
1
);
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
-
1
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_WOULD_BLOCK
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_WOULD_BLOCK
);
...
@@ -156,18 +156,18 @@ test_pollable_properties (NiceAddress *addr)
...
@@ -156,18 +156,18 @@ test_pollable_properties (NiceAddress *addr)
stream_source
=
stream_source
=
g_pollable_input_stream_create_source
(
pollable_input_stream
,
NULL
);
g_pollable_input_stream_create_source
(
pollable_input_stream
,
NULL
);
g_assert
(
stream_source
!=
NULL
);
g_assert
_true
(
stream_source
!=
NULL
);
g_source_unref
(
stream_source
);
g_source_unref
(
stream_source
);
/* Check the output stream’s properties. */
/* Check the output stream’s properties. */
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
g_assert
(
G_IS_POLLABLE_OUTPUT_STREAM
(
output_stream
));
g_assert
_true
(
G_IS_POLLABLE_OUTPUT_STREAM
(
output_stream
));
pollable_output_stream
=
G_POLLABLE_OUTPUT_STREAM
(
output_stream
);
pollable_output_stream
=
G_POLLABLE_OUTPUT_STREAM
(
output_stream
);
g_assert
(
g_pollable_output_stream_can_poll
(
pollable_output_stream
));
g_assert
_true
(
g_pollable_output_stream_can_poll
(
pollable_output_stream
));
g_assert
(
!
g_pollable_output_stream_is_writable
(
pollable_output_stream
));
g_assert
_true
(
!
g_pollable_output_stream_is_writable
(
pollable_output_stream
));
g_assert
(
g_assert
_true
(
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
-
1
);
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
-
1
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_WOULD_BLOCK
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_WOULD_BLOCK
);
...
@@ -175,21 +175,21 @@ test_pollable_properties (NiceAddress *addr)
...
@@ -175,21 +175,21 @@ test_pollable_properties (NiceAddress *addr)
stream_source
=
stream_source
=
g_pollable_output_stream_create_source
(
pollable_output_stream
,
NULL
);
g_pollable_output_stream_create_source
(
pollable_output_stream
,
NULL
);
g_assert
(
stream_source
!=
NULL
);
g_assert
_true
(
stream_source
!=
NULL
);
g_source_unref
(
stream_source
);
g_source_unref
(
stream_source
);
/* Remove the component and check that the I/O streams close. */
/* Remove the component and check that the I/O streams close. */
nice_agent_remove_stream
(
agent
,
stream_id
);
nice_agent_remove_stream
(
agent
,
stream_id
);
g_assert
(
!
g_pollable_input_stream_is_readable
(
pollable_input_stream
));
g_assert
_true
(
!
g_pollable_input_stream_is_readable
(
pollable_input_stream
));
g_assert
(
!
g_pollable_output_stream_is_writable
(
pollable_output_stream
));
g_assert
_true
(
!
g_pollable_output_stream_is_writable
(
pollable_output_stream
));
g_assert
(
g_assert
_true
(
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
0
);
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
0
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
g_assert
_true
(
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
-
1
);
buf
,
sizeof
(
buf
),
NULL
,
&
error
)
==
-
1
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_CLOSED
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_CLOSED
);
...
@@ -217,11 +217,11 @@ source_cancelled_cb (GObject *pollable_stream, gpointer user_data)
...
@@ -217,11 +217,11 @@ source_cancelled_cb (GObject *pollable_stream, gpointer user_data)
/* Try and check that the callback was invoked due to cancellation rather than
/* Try and check that the callback was invoked due to cancellation rather than
* a poll() event on the socket itself. */
* a poll() event on the socket itself. */
if
(
G_IS_POLLABLE_INPUT_STREAM
(
pollable_stream
))
{
if
(
G_IS_POLLABLE_INPUT_STREAM
(
pollable_stream
))
{
g_assert
(
g_assert
_true
(
!
g_pollable_input_stream_is_readable
(
!
g_pollable_input_stream_is_readable
(
G_POLLABLE_INPUT_STREAM
(
pollable_stream
)));
G_POLLABLE_INPUT_STREAM
(
pollable_stream
)));
}
else
{
}
else
{
g_assert
(
g_assert
_true
(
!
g_pollable_output_stream_is_writable
(
!
g_pollable_output_stream_is_writable
(
G_POLLABLE_OUTPUT_STREAM
(
pollable_stream
)));
G_POLLABLE_OUTPUT_STREAM
(
pollable_stream
)));
}
}
...
@@ -278,7 +278,7 @@ check_pollable_source_cancellation (GSource *pollable_source,
...
@@ -278,7 +278,7 @@ check_pollable_source_cancellation (GSource *pollable_source,
* is cancelled. */
* is cancelled. */
g_main_loop_run
(
main_loop
);
g_main_loop_run
(
main_loop
);
g_assert
(
g_cancellable_is_cancelled
(
cancellable
));
g_assert
_true
(
g_cancellable_is_cancelled
(
cancellable
));
g_main_loop_unref
(
main_loop
);
g_main_loop_unref
(
main_loop
);
g_main_context_unref
(
main_context
);
g_main_context_unref
(
main_context
);
...
@@ -308,16 +308,16 @@ test_pollable_cancellation (NiceAddress *addr)
...
@@ -308,16 +308,16 @@ test_pollable_cancellation (NiceAddress *addr)
/* Try building an I/O stream around it. */
/* Try building an I/O stream around it. */
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
g_assert
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
(
NICE_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
NICE_IS_IO_STREAM
(
io_stream
));
/* Grab the input and output streams. */
/* Grab the input and output streams. */
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
g_assert
(
G_IS_POLLABLE_INPUT_STREAM
(
input_stream
));
g_assert
_true
(
G_IS_POLLABLE_INPUT_STREAM
(
input_stream
));
pollable_input_stream
=
G_POLLABLE_INPUT_STREAM
(
input_stream
);
pollable_input_stream
=
G_POLLABLE_INPUT_STREAM
(
input_stream
);
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
g_assert
(
G_IS_POLLABLE_OUTPUT_STREAM
(
output_stream
));
g_assert
_true
(
G_IS_POLLABLE_OUTPUT_STREAM
(
output_stream
));
pollable_output_stream
=
G_POLLABLE_OUTPUT_STREAM
(
output_stream
);
pollable_output_stream
=
G_POLLABLE_OUTPUT_STREAM
(
output_stream
);
/* Check the non-blocking read() and write() return immediately if called with
/* Check the non-blocking read() and write() return immediately if called with
...
@@ -325,13 +325,13 @@ test_pollable_cancellation (NiceAddress *addr)
...
@@ -325,13 +325,13 @@ test_pollable_cancellation (NiceAddress *addr)
cancellable
=
g_cancellable_new
();
cancellable
=
g_cancellable_new
();
g_cancellable_cancel
(
cancellable
);
g_cancellable_cancel
(
cancellable
);
g_assert
(
g_assert
_true
(
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
buf
,
sizeof
(
buf
),
cancellable
,
&
error
)
==
-
1
);
buf
,
sizeof
(
buf
),
cancellable
,
&
error
)
==
-
1
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_CANCELLED
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_CANCELLED
);
g_clear_error
(
&
error
);
g_clear_error
(
&
error
);
g_assert
(
g_assert
_true
(
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
buf
,
sizeof
(
buf
),
cancellable
,
&
error
)
==
-
1
);
buf
,
sizeof
(
buf
),
cancellable
,
&
error
)
==
-
1
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_CANCELLED
);
g_assert_error
(
error
,
G_IO_ERROR
,
G_IO_ERROR_CANCELLED
);
...
@@ -387,8 +387,8 @@ test_zero_length_reads_writes (NiceAddress *addr)
...
@@ -387,8 +387,8 @@ test_zero_length_reads_writes (NiceAddress *addr)
/* Try building an I/O stream around it. */
/* Try building an I/O stream around it. */
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
io_stream
=
nice_agent_get_io_stream
(
agent
,
stream_id
,
1
);
g_assert
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
G_IS_IO_STREAM
(
io_stream
));
g_assert
(
NICE_IS_IO_STREAM
(
io_stream
));
g_assert
_true
(
NICE_IS_IO_STREAM
(
io_stream
));
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
input_stream
=
g_io_stream_get_input_stream
(
G_IO_STREAM
(
io_stream
));
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
output_stream
=
g_io_stream_get_output_stream
(
G_IO_STREAM
(
io_stream
));
...
@@ -402,12 +402,12 @@ test_zero_length_reads_writes (NiceAddress *addr)
...
@@ -402,12 +402,12 @@ test_zero_length_reads_writes (NiceAddress *addr)
g_assert_cmpint
(
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_no_error
(
error
);
g_assert
(
g_assert
_true
(
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
buf
,
0
,
NULL
,
&
error
)
==
0
);
buf
,
0
,
NULL
,
&
error
)
==
0
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
g_assert
_true
(
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
buf
,
0
,
NULL
,
&
error
)
==
0
);
buf
,
0
,
NULL
,
&
error
)
==
0
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
...
@@ -415,7 +415,7 @@ test_zero_length_reads_writes (NiceAddress *addr)
...
@@ -415,7 +415,7 @@ test_zero_length_reads_writes (NiceAddress *addr)
/* Remove the component and check that zero-length reads and writes still
/* Remove the component and check that zero-length reads and writes still
* result in a 0 response, rather than any error. */
* result in a 0 response, rather than any error. */
nice_agent_remove_stream
(
agent
,
stream_id
);
nice_agent_remove_stream
(
agent
,
stream_id
);
g_assert
(
g_io_stream_is_closed
(
G_IO_STREAM
(
io_stream
)));
g_assert
_true
(
g_io_stream_is_closed
(
G_IO_STREAM
(
io_stream
)));
g_assert_cmpint
(
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_no_error
(
error
);
...
@@ -423,12 +423,12 @@ test_zero_length_reads_writes (NiceAddress *addr)
...
@@ -423,12 +423,12 @@ test_zero_length_reads_writes (NiceAddress *addr)
g_assert_cmpint
(
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_no_error
(
error
);
g_assert
(
g_assert
_true
(
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
g_pollable_input_stream_read_nonblocking
(
pollable_input_stream
,
buf
,
0
,
NULL
,
&
error
)
==
0
);
buf
,
0
,
NULL
,
&
error
)
==
0
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
g_assert
_true
(
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
g_pollable_output_stream_write_nonblocking
(
pollable_output_stream
,
buf
,
0
,
NULL
,
&
error
)
==
0
);
buf
,
0
,
NULL
,
&
error
)
==
0
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
...
@@ -448,7 +448,7 @@ main (void)
...
@@ -448,7 +448,7 @@ main (void)
#endif
#endif
nice_address_init
(
&
addr
);
nice_address_init
(
&
addr
);
g_assert
(
nice_address_set_from_string
(
&
addr
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
addr
,
"127.0.0.1"
));
test_invalid_stream
(
&
addr
);
test_invalid_stream
(
&
addr
);
test_io_stream_properties
(
&
addr
);
test_io_stream_properties
(
&
addr
);
...
...
tests/test-consent.c
View file @
8e257029
...
@@ -197,7 +197,7 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
...
@@ -197,7 +197,7 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
{
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
{
NiceCandidate
*
cand
=
i
->
data
;
NiceCandidate
*
cand
=
i
->
data
;
if
(
cand
)
{
if
(
cand
)
{
g_assert
(
dstaddr
);
g_assert
_true
(
dstaddr
);
*
dstaddr
=
cand
->
addr
;
*
dstaddr
=
cand
->
addr
;
}
}
}
}
...
@@ -264,8 +264,8 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -264,8 +264,8 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-consent: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-consent: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
/* step: find out the local candidates of each agent */
/* step: find out the local candidates of each agent */
...
@@ -319,8 +319,8 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -319,8 +319,8 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
/* note: verify that STUN binding requests were sent */
/* note: verify that STUN binding requests were sent */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
/* note: verify that correct number of local candidates were reported */
/* note: verify that correct number of local candidates were reported */
g_assert_cmpint
(
global_lagent_cands
,
==
,
2
);
g_assert_cmpint
(
global_lagent_cands
,
==
,
2
);
g_assert_cmpint
(
global_ragent_cands
,
==
,
2
);
g_assert_cmpint
(
global_ragent_cands
,
==
,
2
);
...
@@ -336,12 +336,12 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -336,12 +336,12 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
global_components_failed
=
0
;
global_components_failed
=
0
;
/* step: synthesize marking the components as consent failed */
/* step: synthesize marking the components as consent failed */
g_assert
(
nice_agent_consent_lost
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
));
g_assert
_true
(
nice_agent_consent_lost
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
));
g_assert
(
nice_agent_consent_lost
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
));
g_assert
_true
(
nice_agent_consent_lost
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
));
/* step: synthesize marking the components as consent failed */
/* step: synthesize marking the components as consent failed */
g_assert
(
nice_agent_consent_lost
(
lagent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
));
g_assert
_true
(
nice_agent_consent_lost
(
lagent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
));
g_assert
(
nice_agent_consent_lost
(
lagent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
));
g_assert
_true
(
nice_agent_consent_lost
(
lagent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
));
/* transition to failed will take roughly 4-6 seconds as that's the pacing
/* transition to failed will take roughly 4-6 seconds as that's the pacing
* of the consent connection checks */
* of the consent connection checks */
...
@@ -401,8 +401,8 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -401,8 +401,8 @@ static int run_consent_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
/* note: verify binding requests were resent after restart */
/* note: verify binding requests were resent after restart */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
/* send another packet after consent lost and after ice restart that will succeed */
/* send another packet after consent lost and after ice restart that will succeed */
g_assert_cmpint
(
nice_agent_send
(
lagent
,
ls_id
,
1
,
16
,
"1234567812345678"
),
==
,
16
);
g_assert_cmpint
(
nice_agent_send
(
lagent
,
ls_id
,
1
,
16
,
"1234567812345678"
),
==
,
16
);
...
...
tests/test-credentials.c
View file @
8e257029
...
@@ -78,7 +78,7 @@ static void swap_candidates(NiceAgent *local, guint local_id, NiceAgent *remote,
...
@@ -78,7 +78,7 @@ static void swap_candidates(NiceAgent *local, guint local_id, NiceAgent *remote,
g_debug
(
"test-credentials:%s"
,
G_STRFUNC
);
g_debug
(
"test-credentials:%s"
,
G_STRFUNC
);
cands
=
nice_agent_get_local_candidates
(
local
,
local_id
,
cands
=
nice_agent_get_local_candidates
(
local
,
local_id
,
NICE_COMPONENT_TYPE_RTP
);
NICE_COMPONENT_TYPE_RTP
);
g_assert
(
nice_agent_set_remote_candidates
(
remote
,
remote_id
,
g_assert
_true
(
nice_agent_set_remote_candidates
(
remote
,
remote_id
,
NICE_COMPONENT_TYPE_RTP
,
cands
));
NICE_COMPONENT_TYPE_RTP
,
cands
));
g_slist_free_full
(
cands
,
(
GDestroyNotify
)
nice_candidate_free
);
g_slist_free_full
(
cands
,
(
GDestroyNotify
)
nice_candidate_free
);
...
@@ -121,11 +121,11 @@ static void setup(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -121,11 +121,11 @@ static void setup(NiceAgent *lagent, NiceAgent *ragent)
g_assert_cmpuint
(
nice_agent_add_stream
(
lagent
,
1
),
==
,
1
);
g_assert_cmpuint
(
nice_agent_add_stream
(
lagent
,
1
),
==
,
1
);
g_assert_cmpuint
(
nice_agent_add_stream
(
ragent
,
1
),
==
,
1
);
g_assert_cmpuint
(
nice_agent_add_stream
(
ragent
,
1
),
==
,
1
);
g_assert
(
NULL
!=
lagent
->
streams
);
g_assert
_true
(
NULL
!=
lagent
->
streams
);
g_assert
(
NULL
!=
ragent
->
streams
);
g_assert
_true
(
NULL
!=
ragent
->
streams
);
nice_address_init
(
&
addr
);
nice_address_init
(
&
addr
);
g_assert
(
nice_address_set_from_string
(
&
addr
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
addr
,
"127.0.0.1"
));
nice_agent_add_local_address
(
lagent
,
&
addr
);
nice_agent_add_local_address
(
lagent
,
&
addr
);
nice_agent_add_local_address
(
ragent
,
&
addr
);
nice_agent_add_local_address
(
ragent
,
&
addr
);
...
...
tests/test-different-number-streams.c
View file @
8e257029
...
@@ -144,9 +144,9 @@ int main (void)
...
@@ -144,9 +144,9 @@ int main (void)
nice_agent_set_remote_credentials
(
ragent
,
rs_id_2
,
lufrag
,
lpassword
);
nice_agent_set_remote_credentials
(
ragent
,
rs_id_2
,
lufrag
,
lpassword
);
nice_agent_set_remote_credentials
(
lagent
,
ls_id
,
rufrag2
,
rpassword2
);
nice_agent_set_remote_credentials
(
lagent
,
ls_id
,
rufrag2
,
rpassword2
);
g_assert
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id_2
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id_2
)
==
TRUE
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id_1
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id_1
)
==
TRUE
);
if
(
USE_SECOND_STREAM
)
{
if
(
USE_SECOND_STREAM
)
{
set_candidates
(
ragent
,
rs_id_2
,
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
);
set_candidates
(
ragent
,
rs_id_2
,
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
);
...
@@ -177,8 +177,8 @@ int main (void)
...
@@ -177,8 +177,8 @@ int main (void)
nice_agent_set_remote_credentials
(
ragent
,
rs_id_1
,
lufrag
,
lpassword
);
nice_agent_set_remote_credentials
(
ragent
,
rs_id_1
,
lufrag
,
lpassword
);
nice_agent_set_remote_credentials
(
lagent
,
ls_id
,
rufrag1
,
rpassword1
);
nice_agent_set_remote_credentials
(
lagent
,
ls_id
,
rufrag1
,
rpassword1
);
g_assert
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id_1
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id_1
)
==
TRUE
);
/* step: attach to mainloop (needed to register the fds) */
/* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv
(
ragent
,
rs_id_1
,
NICE_COMPONENT_TYPE_RTP
,
nice_agent_attach_recv
(
ragent
,
rs_id_1
,
NICE_COMPONENT_TYPE_RTP
,
...
...
tests/test-drop-invalid.c
View file @
8e257029
...
@@ -98,7 +98,7 @@ static void cb_nice_recv (NiceAgent *agent, guint stream_id, guint component_id,
...
@@ -98,7 +98,7 @@ static void cb_nice_recv (NiceAgent *agent, guint stream_id, guint component_id,
* send before the negotiation is over.
* send before the negotiation is over.
*/
*/
g_assert_cmpuint
(
len
,
==
,
16
);
g_assert_cmpuint
(
len
,
==
,
16
);
g_assert
(
strncmp
(
"1234567812345678"
,
buf
,
16
)
==
0
);
g_assert
_true
(
strncmp
(
"1234567812345678"
,
buf
,
16
)
==
0
);
if
(
component_id
==
2
)
if
(
component_id
==
2
)
return
;
return
;
...
@@ -227,7 +227,7 @@ static void set_candidates (NiceAgent *from, guint from_stream,
...
@@ -227,7 +227,7 @@ static void set_candidates (NiceAgent *from, guint from_stream,
NiceCandidateImpl
*
cand
=
item1
->
data
;
NiceCandidateImpl
*
cand
=
item1
->
data
;
NiceSocket
*
nicesock
=
cand
->
sockptr
;
NiceSocket
*
nicesock
=
cand
->
sockptr
;
g_assert
(
nicesock
);
g_assert
_true
(
nicesock
);
for
(
item2
=
peer_cands
;
item2
;
item2
=
item2
->
next
)
{
for
(
item2
=
peer_cands
;
item2
;
item2
=
item2
->
next
)
{
NiceCandidate
*
target_cand
=
item2
->
data
;
NiceCandidate
*
target_cand
=
item2
->
data
;
...
@@ -266,14 +266,14 @@ get_port (NiceAgent *agent, guint stream_id, guint component_id)
...
@@ -266,14 +266,14 @@ get_port (NiceAgent *agent, guint stream_id, guint component_id)
GSList
*
item
;
GSList
*
item
;
guint16
port
=
0
;
guint16
port
=
0
;
g_assert
(
cands
!=
NULL
);
g_assert
_true
(
cands
!=
NULL
);
for
(
item
=
cands
;
item
;
item
=
item
->
next
)
{
for
(
item
=
cands
;
item
;
item
=
item
->
next
)
{
NiceCandidate
*
cand
=
item
->
data
;
NiceCandidate
*
cand
=
item
->
data
;
port
=
nice_address_get_port
(
&
cand
->
addr
);
port
=
nice_address_get_port
(
&
cand
->
addr
);
break
;
break
;
}
}
g_assert
(
port
!=
0
);
g_assert
_true
(
port
!=
0
);
g_slist_free_full
(
cands
,
(
GDestroyNotify
)
nice_candidate_free
);
g_slist_free_full
(
cands
,
(
GDestroyNotify
)
nice_candidate_free
);
...
@@ -314,16 +314,16 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -314,16 +314,16 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
/* Gather candidates and test nice_agent_set_port_range */
/* Gather candidates and test nice_agent_set_port_range */
nice_agent_set_port_range
(
lagent
,
ls_id
,
1
,
10000
,
11000
);
nice_agent_set_port_range
(
lagent
,
ls_id
,
1
,
10000
,
11000
);
nice_agent_set_port_range
(
lagent
,
ls_id
,
2
,
11000
,
12000
);
nice_agent_set_port_range
(
lagent
,
ls_id
,
2
,
11000
,
12000
);
g_assert
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
port
=
get_port
(
lagent
,
ls_id
,
1
);
port
=
get_port
(
lagent
,
ls_id
,
1
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
1
,
12000
,
13000
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
1
,
12000
,
13000
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
port
,
port
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
port
,
port
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
FALSE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
FALSE
);
g_assert
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
1
)
==
NULL
);
g_assert
_true
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
1
)
==
NULL
);
g_assert
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
2
)
==
NULL
);
g_assert
_true
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
2
)
==
NULL
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
13000
,
14000
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
13000
,
14000
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
{
{
GSList
*
cands
=
NULL
,
*
i
;
GSList
*
cands
=
NULL
,
*
i
;
...
@@ -391,8 +391,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -391,8 +391,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-drop-invalid: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-drop-invalid: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
...
@@ -410,8 +410,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -410,8 +410,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
/* note: verify that STUN binding requests were sent */
/* note: verify that STUN binding requests were sent */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
/* note: Send a packet from another address */
/* note: Send a packet from another address */
/* These should also be ignored */
/* These should also be ignored */
...
@@ -421,10 +421,10 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -421,10 +421,10 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
NiceSocket
*
tmpsock
;
NiceSocket
*
tmpsock
;
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
g_assert
(
nice_agent_get_selected_pair
(
lagent
,
ls_id
,
1
,
&
local_cand
,
g_assert
_true
(
nice_agent_get_selected_pair
(
lagent
,
ls_id
,
1
,
&
local_cand
,
&
remote_cand
));
&
remote_cand
));
g_assert
(
local_cand
);
g_assert
_true
(
local_cand
);
g_assert
(
remote_cand
);
g_assert
_true
(
remote_cand
);
tmpsock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
tmpsock
=
nice_udp_bsd_socket_new
(
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
...
@@ -436,7 +436,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -436,7 +436,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
/* note: test payload send and receive */
/* note: test payload send and receive */
global_ragent_read
=
0
;
global_ragent_read
=
0
;
ret
=
nice_agent_send
(
lagent
,
ls_id
,
1
,
16
,
"1234567812345678"
);
ret
=
nice_agent_send
(
lagent
,
ls_id
,
1
,
16
,
"1234567812345678"
);
g_assert
(
ret
!=
-
1
);
g_assert
_true
(
ret
!=
-
1
);
g_debug
(
"Sent %d bytes"
,
ret
);
g_debug
(
"Sent %d bytes"
,
ret
);
g_assert_cmpint
(
ret
,
==
,
16
);
g_assert_cmpint
(
ret
,
==
,
16
);
while
(
global_ragent_read
!=
16
)
while
(
global_ragent_read
!=
16
)
...
...
tests/test-fallback.c
View file @
8e257029
...
@@ -202,7 +202,7 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
...
@@ -202,7 +202,7 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
{
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
{
NiceCandidate
*
cand
=
i
->
data
;
NiceCandidate
*
cand
=
i
->
data
;
if
(
cand
)
{
if
(
cand
)
{
g_assert
(
dstaddr
);
g_assert
_true
(
dstaddr
);
*
dstaddr
=
cand
->
addr
;
*
dstaddr
=
cand
->
addr
;
break
;
break
;
}
}
...
@@ -266,8 +266,8 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
...
@@ -266,8 +266,8 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-fallback: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-fallback: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
/* step: find out the local candidates of each agent */
/* step: find out the local candidates of each agent */
...
@@ -303,10 +303,10 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
...
@@ -303,10 +303,10 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
nice_agent_set_remote_candidates
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
cands
);
nice_agent_set_remote_candidates
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
cands
);
/* step: fall back to non-ICE mode on both sides */
/* step: fall back to non-ICE mode on both sides */
g_assert
(
nice_agent_set_selected_pair
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
"1"
,
"1"
)
==
TRUE
);
g_assert
_true
(
nice_agent_set_selected_pair
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
"1"
,
"1"
)
==
TRUE
);
g_assert
(
nice_agent_set_selected_pair
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTCP
,
"1"
,
"1"
)
==
TRUE
);
g_assert
_true
(
nice_agent_set_selected_pair
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTCP
,
"1"
,
"1"
)
==
TRUE
);
g_assert
(
nice_agent_set_selected_pair
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
,
"1"
,
"1"
)
==
TRUE
);
g_assert
_true
(
nice_agent_set_selected_pair
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
,
"1"
,
"1"
)
==
TRUE
);
g_assert
(
nice_agent_set_selected_pair
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
"1"
,
"1"
)
==
TRUE
);
g_assert
_true
(
nice_agent_set_selected_pair
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
"1"
,
"1"
)
==
TRUE
);
g_debug
(
"test-fallback: Requested for fallback, running mainloop until component state change is completed..."
);
g_debug
(
"test-fallback: Requested for fallback, running mainloop until component state change is completed..."
);
...
@@ -402,8 +402,8 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd
...
@@ -402,8 +402,8 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-fallback: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-fallback: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
/* step: find out the local candidates of each agent */
/* step: find out the local candidates of each agent */
...
@@ -428,17 +428,17 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd
...
@@ -428,17 +428,17 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd
cdes
->
component_id
=
NICE_COMPONENT_TYPE_RTP
;
cdes
->
component_id
=
NICE_COMPONENT_TYPE_RTP
;
cdes
->
addr
=
raddr
;
cdes
->
addr
=
raddr
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
cdes
));
g_assert
_true
(
nice_agent_set_selected_remote_candidate
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
cdes
));
cdes
->
addr
=
laddr
;
cdes
->
addr
=
laddr
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
,
cdes
));
g_assert
_true
(
nice_agent_set_selected_remote_candidate
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
,
cdes
));
cdes
->
component_id
=
NICE_COMPONENT_TYPE_RTCP
;
cdes
->
component_id
=
NICE_COMPONENT_TYPE_RTCP
;
cdes
->
addr
=
raddr_rtcp
;
cdes
->
addr
=
raddr_rtcp
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTCP
,
cdes
));
g_assert
_true
(
nice_agent_set_selected_remote_candidate
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTCP
,
cdes
));
cdes
->
addr
=
laddr_rtcp
;
cdes
->
addr
=
laddr_rtcp
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
cdes
));
g_assert
_true
(
nice_agent_set_selected_remote_candidate
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
cdes
));
g_debug
(
"test-fallback: Requested for fallback, running mainloop until component state change is completed..."
);
g_debug
(
"test-fallback: Requested for fallback, running mainloop until component state change is completed..."
);
...
...
tests/test-fullmode.c
View file @
8e257029
...
@@ -352,14 +352,14 @@ get_port (NiceAgent *agent, guint stream_id, guint component_id)
...
@@ -352,14 +352,14 @@ get_port (NiceAgent *agent, guint stream_id, guint component_id)
GSList
*
item
;
GSList
*
item
;
guint16
port
=
0
;
guint16
port
=
0
;
g_assert
(
cands
!=
NULL
);
g_assert
_true
(
cands
!=
NULL
);
for
(
item
=
cands
;
item
;
item
=
item
->
next
)
{
for
(
item
=
cands
;
item
;
item
=
item
->
next
)
{
NiceCandidate
*
cand
=
item
->
data
;
NiceCandidate
*
cand
=
item
->
data
;
port
=
nice_address_get_port
(
&
cand
->
addr
);
port
=
nice_address_get_port
(
&
cand
->
addr
);
break
;
break
;
}
}
g_assert
(
port
!=
0
);
g_assert
_true
(
port
!=
0
);
g_slist_free_full
(
cands
,
(
GDestroyNotify
)
nice_candidate_free
);
g_slist_free_full
(
cands
,
(
GDestroyNotify
)
nice_candidate_free
);
...
@@ -419,12 +419,12 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -419,12 +419,12 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
port
,
port
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
port
,
port
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
FALSE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
FALSE
);
g_assert
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
1
)
==
NULL
);
g_assert
_true
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
1
)
==
NULL
);
g_assert
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
2
)
==
NULL
);
g_assert
_true
(
nice_agent_get_local_candidates
(
ragent
,
rs_id
,
2
)
==
NULL
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
0
,
0
);
nice_agent_set_port_range
(
ragent
,
rs_id
,
2
,
0
,
0
);
g_assert
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
#if USE_LOOPBACK
#if USE_LOOPBACK
{
{
...
@@ -486,8 +486,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -486,8 +486,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
...
@@ -505,8 +505,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -505,8 +505,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
/* note: verify that STUN binding requests were sent */
/* note: verify that STUN binding requests were sent */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
/* note: test payload send and receive */
/* note: test payload send and receive */
global_ragent_read
=
0
;
global_ragent_read
=
0
;
...
@@ -609,8 +609,8 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
...
@@ -609,8 +609,8 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
...
@@ -628,7 +628,7 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
...
@@ -628,7 +628,7 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
global_exit_when_ibr_received
=
0
;
global_exit_when_ibr_received
=
0
;
/* note: verify that STUN binding requests were sent */
/* note: verify that STUN binding requests were sent */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_debug
(
"test-fullmode: Delayed answer received, continuing processing.."
);
g_debug
(
"test-fullmode: Delayed answer received, continuing processing.."
);
...
@@ -639,7 +639,7 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
...
@@ -639,7 +639,7 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
g_debug
(
"test-fullmode: Running mainloop until connectivity checks succeeed."
);
g_debug
(
"test-fullmode: Running mainloop until connectivity checks succeeed."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
g_assert_cmpuint
(
global_components_failed
,
==
,
0
);
g_assert_cmpuint
(
global_components_failed
,
==
,
0
);
/* note: test payload send and receive */
/* note: test payload send and receive */
...
@@ -730,8 +730,8 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N
...
@@ -730,8 +730,8 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
g_debug
(
"test-fullmode: Got local candidates..."
);
g_debug
(
"test-fullmode: Got local candidates..."
);
...
@@ -817,8 +817,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
...
@@ -817,8 +817,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-fullmode: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
g_debug
(
"test-fullmode: Got local candidates..."
);
g_debug
(
"test-fullmode: Got local candidates..."
);
...
@@ -965,17 +965,17 @@ int main (void)
...
@@ -965,17 +965,17 @@ int main (void)
guint
port
=
0
;
guint
port
=
0
;
gboolean
mode
=
FALSE
;
gboolean
mode
=
FALSE
;
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server"
,
&
string
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server"
,
&
string
,
NULL
);
g_assert
(
stun_server
==
NULL
||
strcmp
(
string
,
stun_server
)
==
0
);
g_assert
_true
(
stun_server
==
NULL
||
strcmp
(
string
,
stun_server
)
==
0
);
g_free
(
string
);
g_free
(
string
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server-port"
,
&
port
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server-port"
,
&
port
,
NULL
);
g_assert
(
stun_server_port
==
NULL
||
port
==
(
guint
)
atoi
(
stun_server_port
));
g_assert
_true
(
stun_server_port
==
NULL
||
port
==
(
guint
)
atoi
(
stun_server_port
));
g_object_get
(
G_OBJECT
(
lagent
),
"proxy-ip"
,
&
string
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"proxy-ip"
,
&
string
,
NULL
);
g_assert_cmpstr
(
string
,
==
,
PROXY_IP
);
g_assert_cmpstr
(
string
,
==
,
PROXY_IP
);
g_free
(
string
);
g_free
(
string
);
g_object_get
(
G_OBJECT
(
lagent
),
"proxy-port"
,
&
port
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"proxy-port"
,
&
port
,
NULL
);
g_assert_cmpuint
(
port
,
==
,
PROXY_PORT
);
g_assert_cmpuint
(
port
,
==
,
PROXY_PORT
);
g_object_get
(
G_OBJECT
(
lagent
),
"controlling-mode"
,
&
mode
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"controlling-mode"
,
&
mode
,
NULL
);
g_assert
(
mode
==
TRUE
);
g_assert
_true
(
mode
==
TRUE
);
g_object_set
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
300
,
NULL
);
g_object_set
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
300
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
&
max_checks
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
&
max_checks
,
NULL
);
g_assert_cmpuint
(
max_checks
,
==
,
300
);
g_assert_cmpuint
(
max_checks
,
==
,
300
);
...
@@ -1067,9 +1067,9 @@ int main (void)
...
@@ -1067,9 +1067,9 @@ int main (void)
priv_print_global_status
();
priv_print_global_status
();
g_assert_cmpint
(
result
,
==
,
0
);
g_assert_cmpint
(
result
,
==
,
0
);
/* should FAIL as agent L can't send any checks: */
/* should FAIL as agent L can't send any checks: */
g_assert
(
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_FAILED
||
g_assert
_true
(
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_FAILED
||
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_FAILED
);
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_FAILED
);
g_assert
(
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_FAILED
||
g_assert
_true
(
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_FAILED
||
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_FAILED
);
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_FAILED
);
#endif
#endif
...
@@ -1079,13 +1079,13 @@ int main (void)
...
@@ -1079,13 +1079,13 @@ int main (void)
priv_print_global_status
();
priv_print_global_status
();
/* should SUCCEED as agent L can send the checks: */
/* should SUCCEED as agent L can send the checks: */
g_assert_cmpint
(
result
,
==
,
0
);
g_assert_cmpint
(
result
,
==
,
0
);
g_assert
(
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_CONNECTED
||
g_assert
_true
(
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_CONNECTED
||
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_READY
);
global_lagent_state
[
0
]
==
NICE_COMPONENT_STATE_READY
);
g_assert
(
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_CONNECTED
||
g_assert
_true
(
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_CONNECTED
||
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_READY
);
global_lagent_state
[
1
]
==
NICE_COMPONENT_STATE_READY
);
g_assert
(
global_ragent_state
[
0
]
==
NICE_COMPONENT_STATE_CONNECTED
||
g_assert
_true
(
global_ragent_state
[
0
]
==
NICE_COMPONENT_STATE_CONNECTED
||
global_ragent_state
[
0
]
==
NICE_COMPONENT_STATE_READY
);
global_ragent_state
[
0
]
==
NICE_COMPONENT_STATE_READY
);
g_assert
(
global_ragent_state
[
1
]
==
NICE_COMPONENT_STATE_CONNECTED
||
g_assert
_true
(
global_ragent_state
[
1
]
==
NICE_COMPONENT_STATE_CONNECTED
||
global_ragent_state
[
1
]
==
NICE_COMPONENT_STATE_READY
);
global_ragent_state
[
1
]
==
NICE_COMPONENT_STATE_READY
);
g_object_set
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
100
,
NULL
);
g_object_set
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
100
,
NULL
);
...
...
tests/test-icetcp.c
View file @
8e257029
...
@@ -297,8 +297,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -297,8 +297,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_assert_cmpuint
(
rs_id
,
>
,
0
);
g_assert_cmpuint
(
rs_id
,
>
,
0
);
/* Gather candidates */
/* Gather candidates */
g_assert
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
{
{
GSList
*
cands
=
NULL
,
*
i
;
GSList
*
cands
=
NULL
,
*
i
;
...
@@ -308,11 +308,11 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -308,11 +308,11 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_assert_cmpuint
(
g_slist_length
(
cands
),
==
,
2
);
g_assert_cmpuint
(
g_slist_length
(
cands
),
==
,
2
);
cand
=
cands
->
data
;
cand
=
cands
->
data
;
g_assert_cmpint
(
cand
->
type
,
==
,
NICE_CANDIDATE_TYPE_HOST
);
g_assert_cmpint
(
cand
->
type
,
==
,
NICE_CANDIDATE_TYPE_HOST
);
g_assert
(
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE
||
g_assert
_true
(
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE
||
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE
);
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE
);
cand
=
cands
->
next
->
data
;
cand
=
cands
->
next
->
data
;
g_assert_cmpint
(
cand
->
type
,
==
,
NICE_CANDIDATE_TYPE_HOST
);
g_assert_cmpint
(
cand
->
type
,
==
,
NICE_CANDIDATE_TYPE_HOST
);
g_assert
(
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE
||
g_assert
_true
(
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE
||
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE
);
cand
->
transport
==
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE
);
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
nice_candidate_free
((
NiceCandidate
*
)
i
->
data
);
nice_candidate_free
((
NiceCandidate
*
)
i
->
data
);
...
@@ -339,8 +339,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -339,8 +339,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-icetcp: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-icetcp: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
...
@@ -358,8 +358,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
...
@@ -358,8 +358,8 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
/* note: verify that STUN binding requests were sent */
/* note: verify that STUN binding requests were sent */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
/* note: test payload send and receive */
/* note: test payload send and receive */
global_ragent_read
=
0
;
global_ragent_read
=
0
;
...
...
tests/test-interfaces.c
View file @
8e257029
...
@@ -50,24 +50,24 @@ test_ipv4 (void)
...
@@ -50,24 +50,24 @@ test_ipv4 (void)
/* test private addresses */
/* test private addresses */
nice_address_set_from_string
(
&
addr
,
"10.1.2.3"
);
nice_address_set_from_string
(
&
addr
,
"10.1.2.3"
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
g_assert
_true
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
nice_address_set_from_string
(
&
addr
,
"172.22.22.22"
);
nice_address_set_from_string
(
&
addr
,
"172.22.22.22"
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
g_assert
_true
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
nice_address_set_from_string
(
&
addr
,
"192.168.122.1"
);
nice_address_set_from_string
(
&
addr
,
"192.168.122.1"
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
g_assert
_true
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
nice_address_set_from_string
(
&
addr
,
"169.254.1.2"
);
nice_address_set_from_string
(
&
addr
,
"169.254.1.2"
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
g_assert
_true
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
/* test public addresses */
/* test public addresses */
nice_address_set_from_string
(
&
addr
,
"1.2.3.4"
);
nice_address_set_from_string
(
&
addr
,
"1.2.3.4"
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
)
==
FALSE
);
g_assert
_true
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
)
==
FALSE
);
}
}
...
@@ -85,13 +85,13 @@ test_ipv6 (void)
...
@@ -85,13 +85,13 @@ test_ipv6 (void)
nice_address_set_from_string
(
&
addr
,
nice_address_set_from_string
(
&
addr
,
"fe8f:2233:4455:6677:8899:aabb:ccdd:eeff"
);
"fe8f:2233:4455:6677:8899:aabb:ccdd:eeff"
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
g_assert
_true
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
));
/* test public addresses */
/* test public addresses */
nice_address_set_from_string
(
&
addr
,
nice_address_set_from_string
(
&
addr
,
"11:2233:4455:6677:8899:aabb:ccdd:eeff"
);
"11:2233:4455:6677:8899:aabb:ccdd:eeff"
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
nice_address_copy_to_sockaddr
(
&
addr
,
&
sin
.
addr
);
g_assert
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
)
==
FALSE
);
g_assert
_true
(
nice_interfaces_is_private_ip
(
&
sin
.
addr
)
==
FALSE
);
}
}
#endif
/* G_OS_UNIX */
#endif
/* G_OS_UNIX */
...
...
tests/test-io-stream-common.c
View file @
8e257029
...
@@ -61,7 +61,7 @@ gboolean started;
...
@@ -61,7 +61,7 @@ gboolean started;
g_main_context_iteration (context, FALSE); \
g_main_context_iteration (context, FALSE); \
} \
} \
\
\
g_assert (!(var)); \
g_assert
_true
(!(var)); \
}
}
static
gboolean
timer_cb
(
gpointer
pointer
)
static
gboolean
timer_cb
(
gpointer
pointer
)
...
@@ -177,7 +177,7 @@ candidate_gathering_done_cb (NiceAgent *agent, guint stream_id,
...
@@ -177,7 +177,7 @@ candidate_gathering_done_cb (NiceAgent *agent, guint stream_id,
g_free
(
password
);
g_free
(
password
);
cands
=
nice_agent_get_local_candidates
(
agent
,
id
,
1
);
cands
=
nice_agent_get_local_candidates
(
agent
,
id
,
1
);
g_assert
(
cands
!=
NULL
);
g_assert
_true
(
cands
!=
NULL
);
nice_agent_set_remote_candidates
(
other
,
other_id
,
1
,
cands
);
nice_agent_set_remote_candidates
(
other
,
other_id
,
1
,
cands
);
...
@@ -192,7 +192,7 @@ reliable_transport_writable_cb (NiceAgent *agent, guint stream_id,
...
@@ -192,7 +192,7 @@ reliable_transport_writable_cb (NiceAgent *agent, guint stream_id,
{
{
TestIOStreamThreadData
*
data
=
user_data
;
TestIOStreamThreadData
*
data
=
user_data
;
g_assert
(
data
->
reliable
);
g_assert
_true
(
data
->
reliable
);
/* Signal writeability. */
/* Signal writeability. */
g_mutex_lock
(
&
data
->
write_mutex
);
g_mutex_lock
(
&
data
->
write_mutex
);
...
@@ -205,7 +205,7 @@ reliable_transport_writable_cb (NiceAgent *agent, guint stream_id,
...
@@ -205,7 +205,7 @@ reliable_transport_writable_cb (NiceAgent *agent, guint stream_id,
GOutputStream
*
output_stream
;
GOutputStream
*
output_stream
;
io_stream
=
g_object_get_data
(
G_OBJECT
(
agent
),
"io-stream"
);
io_stream
=
g_object_get_data
(
G_OBJECT
(
agent
),
"io-stream"
);
g_assert
(
io_stream
!=
NULL
);
g_assert
_true
(
io_stream
!=
NULL
);
output_stream
=
g_io_stream_get_output_stream
(
io_stream
);
output_stream
=
g_io_stream_get_output_stream
(
io_stream
);
data
->
callbacks
->
reliable_transport_writable
(
output_stream
,
agent
,
data
->
callbacks
->
reliable_transport_writable
(
output_stream
,
agent
,
...
@@ -265,7 +265,7 @@ create_agent (gboolean controlling_mode, TestIOStreamThreadData *data,
...
@@ -265,7 +265,7 @@ create_agent (gboolean controlling_mode, TestIOStreamThreadData *data,
NULL
);
NULL
);
/* Specify which local interface to use. */
/* Specify which local interface to use. */
g_assert
(
nice_address_set_from_string
(
&
base_addr
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
base_addr
,
"127.0.0.1"
));
nice_agent_add_local_address
(
agent
,
&
base_addr
);
nice_agent_add_local_address
(
agent
,
&
base_addr
);
/* Hook up signals. */
/* Hook up signals. */
...
@@ -337,7 +337,7 @@ spawn_thread (const gchar *thread_name, GThreadFunc thread_func,
...
@@ -337,7 +337,7 @@ spawn_thread (const gchar *thread_name, GThreadFunc thread_func,
GThread
*
thread
;
GThread
*
thread
;
thread
=
g_thread_new
(
thread_name
,
thread_func
,
user_data
);
thread
=
g_thread_new
(
thread_name
,
thread_func
,
user_data
);
g_assert
(
thread
);
g_assert
_true
(
thread
);
return
thread
;
return
thread
;
}
}
...
...
tests/test-new-trickle.c
View file @
8e257029
...
@@ -94,7 +94,7 @@ static const uint16_t known_attributes[] = {
...
@@ -94,7 +94,7 @@ static const uint16_t known_attributes[] = {
g_main_context_iteration (context, FALSE); \
g_main_context_iteration (context, FALSE); \
} \
} \
\
\
g_assert (!(var)); \
g_assert
_true
(!(var)); \
}
}
/*
/*
...
@@ -131,7 +131,7 @@ static int listen_socket (unsigned int *port)
...
@@ -131,7 +131,7 @@ static int listen_socket (unsigned int *port)
g_assert_cmpint
(
socklen
,
==
,
sizeof
(
struct
sockaddr_in
));
g_assert_cmpint
(
socklen
,
==
,
sizeof
(
struct
sockaddr_in
));
*
port
=
ntohs
(
addr
.
in
.
sin_port
);
*
port
=
ntohs
(
addr
.
in
.
sin_port
);
g_assert
(
*
port
!=
0
);
g_assert
_true
(
*
port
!=
0
);
}
}
return
fd
;
return
fd
;
...
@@ -227,7 +227,7 @@ recv_packet:
...
@@ -227,7 +227,7 @@ recv_packet:
send_buf:
send_buf:
g_cancellable_cancel
(
global_cancellable
);
g_cancellable_cancel
(
global_cancellable
);
g_debug
(
"Ready to send a STUN response"
);
g_debug
(
"Ready to send a STUN response"
);
g_assert
(
g_mutex_trylock
(
stun_mutex_ptr
));
g_assert
_true
(
g_mutex_trylock
(
stun_mutex_ptr
));
got_stun_packet
=
TRUE
;
got_stun_packet
=
TRUE
;
while
(
send_stun
)
{
while
(
send_stun
)
{
g_debug
(
"Waiting for signal. State is %d"
,
global_lagent_state
);
g_debug
(
"Waiting for signal. State is %d"
,
global_lagent_state
);
...
@@ -352,7 +352,7 @@ static void swap_candidates(NiceAgent *local, guint local_id, NiceAgent *remote,
...
@@ -352,7 +352,7 @@ static void swap_candidates(NiceAgent *local, guint local_id, NiceAgent *remote,
g_debug
(
"test-tricklemode:%s"
,
G_STRFUNC
);
g_debug
(
"test-tricklemode:%s"
,
G_STRFUNC
);
cands
=
nice_agent_get_local_candidates
(
local
,
local_id
,
cands
=
nice_agent_get_local_candidates
(
local
,
local_id
,
NICE_COMPONENT_TYPE_RTP
);
NICE_COMPONENT_TYPE_RTP
);
g_assert
(
nice_agent_set_remote_candidates
(
remote
,
remote_id
,
g_assert
_true
(
nice_agent_set_remote_candidates
(
remote
,
remote_id
,
NICE_COMPONENT_TYPE_RTP
,
cands
));
NICE_COMPONENT_TYPE_RTP
,
cands
));
if
(
signal_stun_reply
)
{
if
(
signal_stun_reply
)
{
...
@@ -386,7 +386,7 @@ static void cb_agent_new_candidate(NiceAgent *agent, guint stream_id, guint comp
...
@@ -386,7 +386,7 @@ static void cb_agent_new_candidate(NiceAgent *agent, guint stream_id, guint comp
if
(
g_strcmp0
(
temp
->
foundation
,
foundation
)
==
0
)
{
if
(
g_strcmp0
(
temp
->
foundation
,
foundation
)
==
0
)
{
g_debug
(
"Adding new local candidate to other agent's connchecks"
);
g_debug
(
"Adding new local candidate to other agent's connchecks"
);
remote_cands
=
g_slist_prepend
(
remote_cands
,
nice_candidate_copy
(
temp
));
remote_cands
=
g_slist_prepend
(
remote_cands
,
nice_candidate_copy
(
temp
));
g_assert
(
nice_agent_set_remote_candidates
(
other
,
id
,
g_assert
_true
(
nice_agent_set_remote_candidates
(
other
,
id
,
NICE_COMPONENT_TYPE_RTP
,
NICE_COMPONENT_TYPE_RTP
,
remote_cands
));
remote_cands
));
}
}
...
@@ -402,7 +402,7 @@ static void add_bad_candidate (NiceAgent *agent, guint stream_id, NiceCandidate
...
@@ -402,7 +402,7 @@ static void add_bad_candidate (NiceAgent *agent, guint stream_id, NiceCandidate
NiceAddress
bad_addr
;
NiceAddress
bad_addr
;
GSList
*
cand_list
=
NULL
;
GSList
*
cand_list
=
NULL
;
g_assert
(
nice_address_set_from_string
(
&
bad_addr
,
"172.1.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
bad_addr
,
"172.1.0.1"
));
cand
=
nice_candidate_new
(
NICE_CANDIDATE_TYPE_HOST
);
cand
=
nice_candidate_new
(
NICE_CANDIDATE_TYPE_HOST
);
cand
->
stream_id
=
stream_id
;
cand
->
stream_id
=
stream_id
;
...
@@ -414,7 +414,7 @@ static void add_bad_candidate (NiceAgent *agent, guint stream_id, NiceCandidate
...
@@ -414,7 +414,7 @@ static void add_bad_candidate (NiceAgent *agent, guint stream_id, NiceCandidate
cand_list
=
g_slist_prepend
(
cand_list
,
cand
);
cand_list
=
g_slist_prepend
(
cand_list
,
cand
);
g_debug
(
"Adding buggy candidate to the agent %p"
,
agent
);
g_debug
(
"Adding buggy candidate to the agent %p"
,
agent
);
g_assert
(
nice_agent_set_remote_candidates
(
agent
,
stream_id
,
g_assert
_true
(
nice_agent_set_remote_candidates
(
agent
,
stream_id
,
NICE_COMPONENT_TYPE_RTP
,
NICE_COMPONENT_TYPE_RTP
,
cand_list
));
cand_list
));
...
@@ -485,15 +485,15 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -485,15 +485,15 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
nice_agent_gather_candidates
(
lagent
,
global_ls_id
);
nice_agent_gather_candidates
(
lagent
,
global_ls_id
);
while
(
!
got_stun_packet
)
while
(
!
got_stun_packet
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
g_assert
_true
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
!
lagent_candidate_gathering_done
);
!
lagent_candidate_gathering_done
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
while
(
!
ragent_candidate_gathering_done
)
while
(
!
ragent_candidate_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
ragent_candidate_gathering_done
);
g_assert
_true
(
ragent_candidate_gathering_done
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
g_debug
(
"Setting local candidates of ragent as remote candidates of lagent"
);
g_debug
(
"Setting local candidates of ragent as remote candidates of lagent"
);
...
@@ -503,7 +503,7 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -503,7 +503,7 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
while
(
!
data_received
)
while
(
!
data_received
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
global_lagent_state
>=
NICE_COMPONENT_STATE_CONNECTED
&&
g_assert
_true
(
global_lagent_state
>=
NICE_COMPONENT_STATE_CONNECTED
&&
data_received
);
data_received
);
g_debug
(
"Setting local candidates of lagent as remote candidates of ragent"
);
g_debug
(
"Setting local candidates of lagent as remote candidates of ragent"
);
...
@@ -514,8 +514,8 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -514,8 +514,8 @@ static void standard_test(NiceAgent *lagent, NiceAgent *ragent)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
lagent_candidate_gathering_done
);
g_assert
_true
(
lagent_candidate_gathering_done
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
while
(
global_ragent_state
<
NICE_COMPONENT_STATE_CONNECTED
)
while
(
global_ragent_state
<
NICE_COMPONENT_STATE_CONNECTED
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
...
@@ -542,15 +542,15 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -542,15 +542,15 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
while
(
!
got_stun_packet
)
while
(
!
got_stun_packet
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
g_assert
_true
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
!
lagent_candidate_gathering_done
);
!
lagent_candidate_gathering_done
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
while
(
!
ragent_candidate_gathering_done
)
while
(
!
ragent_candidate_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
ragent_candidate_gathering_done
);
g_assert
_true
(
ragent_candidate_gathering_done
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
g_debug
(
"Setting local candidates of ragent as remote candidates of lagent"
);
g_debug
(
"Setting local candidates of ragent as remote candidates of lagent"
);
swap_candidates
(
ragent
,
global_rs_id
,
lagent
,
global_ls_id
,
FALSE
);
swap_candidates
(
ragent
,
global_rs_id
,
lagent
,
global_ls_id
,
FALSE
);
...
@@ -572,7 +572,7 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -572,7 +572,7 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
data_received
);
g_assert
_true
(
data_received
);
g_assert_cmpint
(
global_lagent_state
,
==
,
NICE_COMPONENT_STATE_READY
);
g_assert_cmpint
(
global_lagent_state
,
==
,
NICE_COMPONENT_STATE_READY
);
g_assert_cmpint
(
global_ragent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTED
);
g_assert_cmpint
(
global_ragent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTED
);
...
@@ -581,8 +581,8 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -581,8 +581,8 @@ static void bad_credentials_test(NiceAgent *lagent, NiceAgent *ragent)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
lagent_candidate_gathering_done
);
g_assert
_true
(
lagent_candidate_gathering_done
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
cleanup
(
lagent
,
ragent
);
cleanup
(
lagent
,
ragent
);
}
}
...
@@ -599,7 +599,7 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
...
@@ -599,7 +599,7 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
while
(
!
got_stun_packet
)
while
(
!
got_stun_packet
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
g_assert
_true
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
!
lagent_candidate_gathering_done
);
!
lagent_candidate_gathering_done
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
...
@@ -607,8 +607,8 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
...
@@ -607,8 +607,8 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
ragent_candidate_gathering_done
);
g_assert
_true
(
ragent_candidate_gathering_done
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
add_bad_candidate
(
lagent
,
global_ls_id
,
cand
);
add_bad_candidate
(
lagent
,
global_ls_id
,
cand
);
...
@@ -617,14 +617,14 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
...
@@ -617,14 +617,14 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
// connchecks will fail causing this mainloop to quit
// connchecks will fail causing this mainloop to quit
while
(
global_lagent_state
!=
NICE_COMPONENT_STATE_FAILED
)
while
(
global_lagent_state
!=
NICE_COMPONENT_STATE_FAILED
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_FAILED
&&
g_assert
_true
(
global_lagent_state
==
NICE_COMPONENT_STATE_FAILED
&&
!
data_received
);
!
data_received
);
g_debug
(
"Setting local candidates of ragent as remote candidates of lagent"
);
g_debug
(
"Setting local candidates of ragent as remote candidates of lagent"
);
...
@@ -639,7 +639,7 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
...
@@ -639,7 +639,7 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent *ragent)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
lagent_candidate_gathering_done
);
g_assert
_true
(
lagent_candidate_gathering_done
);
g_assert_cmpint
(
global_lagent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTED
);
g_assert_cmpint
(
global_lagent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTED
);
g_assert_cmpint
(
global_ragent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTING
);
g_assert_cmpint
(
global_ragent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTING
);
...
@@ -659,20 +659,20 @@ static void new_candidate_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -659,20 +659,20 @@ static void new_candidate_test(NiceAgent *lagent, NiceAgent *ragent)
while
(
!
got_stun_packet
)
while
(
!
got_stun_packet
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
g_assert
_true
(
global_lagent_state
==
NICE_COMPONENT_STATE_GATHERING
&&
!
lagent_candidate_gathering_done
);
!
lagent_candidate_gathering_done
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
nice_agent_gather_candidates
(
ragent
,
global_rs_id
);
while
(
!
ragent_candidate_gathering_done
)
while
(
!
ragent_candidate_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
lagent
,
global_ls_id
));
// Wait for data
// Wait for data
while
(
!
data_received
)
while
(
!
data_received
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
data_received
);
g_assert
_true
(
data_received
);
// Data arrived, signal STUN thread to send STUN response
// Data arrived, signal STUN thread to send STUN response
g_mutex_lock
(
stun_mutex_ptr
);
g_mutex_lock
(
stun_mutex_ptr
);
...
@@ -684,10 +684,10 @@ static void new_candidate_test(NiceAgent *lagent, NiceAgent *ragent)
...
@@ -684,10 +684,10 @@ static void new_candidate_test(NiceAgent *lagent, NiceAgent *ragent)
while
(
!
lagent_candidate_gathering_done
)
while
(
!
lagent_candidate_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_cancellable_reset
(
global_cancellable
);
g_cancellable_reset
(
global_cancellable
);
g_assert
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
g_assert
_true
(
nice_agent_peer_candidate_gathering_done
(
ragent
,
global_rs_id
));
g_assert
(
lagent_candidate_gathering_done
);
g_assert
_true
(
lagent_candidate_gathering_done
);
g_assert
(
ragent_candidate_gathering_done
);
g_assert
_true
(
ragent_candidate_gathering_done
);
g_assert_cmpint
(
global_lagent_state
,
==
,
NICE_COMPONENT_STATE_READY
);
g_assert_cmpint
(
global_lagent_state
,
==
,
NICE_COMPONENT_STATE_READY
);
g_assert_cmpint
(
global_ragent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTED
);
g_assert_cmpint
(
global_ragent_state
,
>=
,
NICE_COMPONENT_STATE_CONNECTED
);
...
@@ -762,7 +762,7 @@ int main(void)
...
@@ -762,7 +762,7 @@ int main(void)
g_object_set_data
(
G_OBJECT
(
lagent
),
"other-agent"
,
ragent
);
g_object_set_data
(
G_OBJECT
(
lagent
),
"other-agent"
,
ragent
);
g_object_set_data
(
G_OBJECT
(
ragent
),
"other-agent"
,
lagent
);
g_object_set_data
(
G_OBJECT
(
ragent
),
"other-agent"
,
lagent
);
g_assert
(
nice_address_set_from_string
(
&
baseaddr
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
baseaddr
,
"127.0.0.1"
));
nice_agent_add_local_address
(
lagent
,
&
baseaddr
);
nice_agent_add_local_address
(
lagent
,
&
baseaddr
);
nice_agent_add_local_address
(
ragent
,
&
baseaddr
);
nice_agent_add_local_address
(
ragent
,
&
baseaddr
);
...
...
tests/test-nomination.c
View file @
8e257029
...
@@ -77,7 +77,7 @@ static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint
...
@@ -77,7 +77,7 @@ static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint
global_components_ready
++
;
global_components_ready
++
;
else
if
(
state
==
NICE_COMPONENT_STATE_CONNECTED
&&
ready_to_connected
)
else
if
(
state
==
NICE_COMPONENT_STATE_CONNECTED
&&
ready_to_connected
)
global_components_ready
--
;
global_components_ready
--
;
g_assert
(
state
!=
NICE_COMPONENT_STATE_FAILED
);
g_assert
_true
(
state
!=
NICE_COMPONENT_STATE_FAILED
);
g_debug
(
"test-nomination: checks READY %u."
,
global_components_ready
);
g_debug
(
"test-nomination: checks READY %u."
,
global_components_ready
);
}
}
...
@@ -186,8 +186,8 @@ run_test(NiceNominationMode l_nomination_mode,
...
@@ -186,8 +186,8 @@ run_test(NiceNominationMode l_nomination_mode,
g_assert_cmpuint
(
rs_id
,
>
,
0
);
g_assert_cmpuint
(
rs_id
,
>
,
0
);
/* Gather candidates and test nice_agent_set_port_range */
/* Gather candidates and test nice_agent_set_port_range */
g_assert
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
nice_agent_attach_recv
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
nice_agent_attach_recv
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
g_main_context_default
(),
cb_nice_recv
,
GUINT_TO_POINTER
(
1
));
g_main_context_default
(),
cb_nice_recv
,
GUINT_TO_POINTER
(
1
));
...
@@ -197,10 +197,10 @@ run_test(NiceNominationMode l_nomination_mode,
...
@@ -197,10 +197,10 @@ run_test(NiceNominationMode l_nomination_mode,
g_debug
(
"test-nomination: Added streams, running context until 'candidate-gathering-done'..."
);
g_debug
(
"test-nomination: Added streams, running context until 'candidate-gathering-done'..."
);
while
(
!
global_lagent_gathering_done
)
while
(
!
global_lagent_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
while
(
!
global_ragent_gathering_done
)
while
(
!
global_ragent_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
...
...
tests/test-pseudotcp-fin.c
View file @
8e257029
...
@@ -245,7 +245,7 @@ expect_segment (PseudoTcpSocket *socket, GQueue/*<owned GBytes>*/ *queue,
...
@@ -245,7 +245,7 @@ expect_segment (PseudoTcpSocket *socket, GQueue/*<owned GBytes>*/ *queue,
/* Grab the segment. */
/* Grab the segment. */
bytes
=
g_queue_peek_head
(
queue
);
bytes
=
g_queue_peek_head
(
queue
);
g_assert
(
bytes
!=
NULL
);
g_assert
_true
(
bytes
!=
NULL
);
b
.
u8
=
g_bytes_get_data
(
bytes
,
&
size
);
b
.
u8
=
g_bytes_get_data
(
bytes
,
&
size
);
g_assert_cmpuint
(
size
,
>=
,
24
);
/* minimum packet size */
g_assert_cmpuint
(
size
,
>=
,
24
);
/* minimum packet size */
...
@@ -286,7 +286,7 @@ forward_segment (GQueue/*<owned GBytes>*/ *from, PseudoTcpSocket *to)
...
@@ -286,7 +286,7 @@ forward_segment (GQueue/*<owned GBytes>*/ *from, PseudoTcpSocket *to)
gboolean
retval
;
gboolean
retval
;
segment
=
g_queue_pop_head
(
from
);
segment
=
g_queue_pop_head
(
from
);
g_assert
(
segment
!=
NULL
);
g_assert
_true
(
segment
!=
NULL
);
b
=
g_bytes_get_data
(
segment
,
&
size
);
b
=
g_bytes_get_data
(
segment
,
&
size
);
retval
=
pseudo_tcp_socket_notify_packet
(
to
,
(
const
gchar
*
)
b
,
size
);
retval
=
pseudo_tcp_socket_notify_packet
(
to
,
(
const
gchar
*
)
b
,
size
);
g_bytes_unref
(
segment
);
g_bytes_unref
(
segment
);
...
@@ -297,13 +297,13 @@ forward_segment (GQueue/*<owned GBytes>*/ *from, PseudoTcpSocket *to)
...
@@ -297,13 +297,13 @@ forward_segment (GQueue/*<owned GBytes>*/ *from, PseudoTcpSocket *to)
static
void
static
void
forward_segment_ltr
(
Data
*
data
)
forward_segment_ltr
(
Data
*
data
)
{
{
g_assert
(
forward_segment
(
data
->
left_sent
,
data
->
right
));
g_assert
_true
(
forward_segment
(
data
->
left_sent
,
data
->
right
));
}
}
static
void
static
void
forward_segment_rtl
(
Data
*
data
)
forward_segment_rtl
(
Data
*
data
)
{
{
g_assert
(
forward_segment
(
data
->
right_sent
,
data
->
left
));
g_assert
_true
(
forward_segment
(
data
->
right_sent
,
data
->
left
));
}
}
static
void
static
void
...
@@ -312,7 +312,7 @@ duplicate_segment (GQueue/*<owned GBytes>*/ *queue)
...
@@ -312,7 +312,7 @@ duplicate_segment (GQueue/*<owned GBytes>*/ *queue)
GBytes
*
segment
;
/* unowned */
GBytes
*
segment
;
/* unowned */
segment
=
g_queue_peek_head
(
queue
);
segment
=
g_queue_peek_head
(
queue
);
g_assert
(
segment
!=
NULL
);
g_assert
_true
(
segment
!=
NULL
);
g_queue_push_head
(
queue
,
g_bytes_ref
(
segment
));
g_queue_push_head
(
queue
,
g_bytes_ref
(
segment
));
}
}
...
@@ -323,7 +323,7 @@ drop_segment (PseudoTcpSocket *socket, GQueue/*<owned GBytes>*/ *queue)
...
@@ -323,7 +323,7 @@ drop_segment (PseudoTcpSocket *socket, GQueue/*<owned GBytes>*/ *queue)
gchar
*
str
;
gchar
*
str
;
segment
=
g_queue_pop_head
(
queue
);
segment
=
g_queue_pop_head
(
queue
);
g_assert
(
segment
!=
NULL
);
g_assert
_true
(
segment
!=
NULL
);
str
=
segment_bytes_to_string
(
g_bytes_get_data
(
segment
,
NULL
));
str
=
segment_bytes_to_string
(
g_bytes_get_data
(
segment
,
NULL
));
g_debug
(
"%p drop: %s"
,
socket
,
str
);
g_debug
(
"%p drop: %s"
,
socket
,
str
);
...
@@ -340,9 +340,9 @@ reorder_segments (PseudoTcpSocket *socket, GQueue/*<owned GBytes>*/ *queue)
...
@@ -340,9 +340,9 @@ reorder_segments (PseudoTcpSocket *socket, GQueue/*<owned GBytes>*/ *queue)
gchar
*
str
;
gchar
*
str
;
segment1
=
g_queue_pop_head
(
queue
);
segment1
=
g_queue_pop_head
(
queue
);
g_assert
(
segment1
!=
NULL
);
g_assert
_true
(
segment1
!=
NULL
);
segment2
=
g_queue_pop_head
(
queue
);
segment2
=
g_queue_pop_head
(
queue
);
g_assert
(
segment2
!=
NULL
);
g_assert
_true
(
segment2
!=
NULL
);
str
=
segment_bytes_to_string
(
g_bytes_get_data
(
segment1
,
NULL
));
str
=
segment_bytes_to_string
(
g_bytes_get_data
(
segment1
,
NULL
));
g_debug
(
"%p reorder: %s"
,
socket
,
str
);
g_debug
(
"%p reorder: %s"
,
socket
,
str
);
...
@@ -969,9 +969,9 @@ pseudotcp_close_duplicate_ack (void)
...
@@ -969,9 +969,9 @@ pseudotcp_close_duplicate_ack (void)
expect_ack
(
data
.
left
,
data
.
left_sent
,
8
,
8
);
expect_ack
(
data
.
left
,
data
.
left_sent
,
8
,
8
);
duplicate_segment
(
data
.
left_sent
);
duplicate_segment
(
data
.
left_sent
);
forward_segment_ltr
(
&
data
);
forward_segment_ltr
(
&
data
);
g_assert
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
g_assert
_true
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
expect_rst
(
data
.
right
,
data
.
right_sent
,
8
,
8
);
expect_rst
(
data
.
right
,
data
.
right_sent
,
8
,
8
);
g_assert
(
!
forward_segment
(
data
.
right_sent
,
data
.
left
));
g_assert
_true
(
!
forward_segment
(
data
.
right_sent
,
data
.
left
));
expect_sockets_closed
(
&
data
);
expect_sockets_closed
(
&
data
);
...
@@ -997,7 +997,7 @@ pseudotcp_close_rst (void)
...
@@ -997,7 +997,7 @@ pseudotcp_close_rst (void)
g_assert_cmpint
(
pseudo_tcp_socket_recv
(
data
.
left
,
(
char
*
)
buf
,
sizeof
(
buf
)),
==
,
0
);
g_assert_cmpint
(
pseudo_tcp_socket_recv
(
data
.
left
,
(
char
*
)
buf
,
sizeof
(
buf
)),
==
,
0
);
expect_rst
(
data
.
left
,
data
.
left_sent
,
7
,
7
);
expect_rst
(
data
.
left
,
data
.
left_sent
,
7
,
7
);
g_assert
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
g_assert
_true
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
/* Check the RHS is closed. */
/* Check the RHS is closed. */
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
-
1
);
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
-
1
);
...
@@ -1031,7 +1031,7 @@ pseudotcp_close_pending_received (void)
...
@@ -1031,7 +1031,7 @@ pseudotcp_close_pending_received (void)
close_socket
(
data
.
left
);
close_socket
(
data
.
left
);
expect_rst
(
data
.
left
,
data
.
left_sent
,
7
,
10
);
expect_rst
(
data
.
left
,
data
.
left_sent
,
7
,
10
);
g_assert
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
g_assert
_true
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
/* Check the RHS is closed. */
/* Check the RHS is closed. */
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
-
1
);
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
-
1
);
...
@@ -1067,10 +1067,10 @@ pseudotcp_close_rst_afterwards (void)
...
@@ -1067,10 +1067,10 @@ pseudotcp_close_rst_afterwards (void)
/* Send some data from RHS to LHS, which should result in an RST. */
/* Send some data from RHS to LHS, which should result in an RST. */
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
3
);
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
3
);
expect_data
(
data
.
right
,
data
.
right_sent
,
7
,
7
,
3
);
expect_data
(
data
.
right
,
data
.
right_sent
,
7
,
7
,
3
);
g_assert
(
!
forward_segment
(
data
.
right_sent
,
data
.
left
));
g_assert
_true
(
!
forward_segment
(
data
.
right_sent
,
data
.
left
));
expect_rst
(
data
.
left
,
data
.
left_sent
,
7
,
7
);
expect_rst
(
data
.
left
,
data
.
left_sent
,
7
,
7
);
g_assert
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
g_assert
_true
(
!
forward_segment
(
data
.
left_sent
,
data
.
right
));
/* Check the RHS is closed. */
/* Check the RHS is closed. */
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
-
1
);
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
right
,
"foo"
,
3
),
==
,
-
1
);
...
@@ -1107,7 +1107,7 @@ pseudotcp_compatibility (void)
...
@@ -1107,7 +1107,7 @@ pseudotcp_compatibility (void)
/* Close it. Sending shouldn’t fail. */
/* Close it. Sending shouldn’t fail. */
pseudo_tcp_socket_close
(
data
.
left
,
FALSE
);
pseudo_tcp_socket_close
(
data
.
left
,
FALSE
);
g_assert
(
!
pseudo_tcp_socket_is_closed
(
data
.
left
));
g_assert
_true
(
!
pseudo_tcp_socket_is_closed
(
data
.
left
));
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
left
,
"foo"
,
3
),
==
,
3
);
g_assert_cmpint
(
pseudo_tcp_socket_send
(
data
.
left
,
"foo"
,
3
),
==
,
3
);
g_assert_cmpint
(
pseudo_tcp_socket_recv
(
data
.
left
,
(
char
*
)
buf
,
sizeof
(
buf
)),
==
,
-
1
);
g_assert_cmpint
(
pseudo_tcp_socket_recv
(
data
.
left
,
(
char
*
)
buf
,
sizeof
(
buf
)),
==
,
-
1
);
...
@@ -1125,7 +1125,7 @@ pseudotcp_compatibility (void)
...
@@ -1125,7 +1125,7 @@ pseudotcp_compatibility (void)
* outstanding data. */
* outstanding data. */
increment_time_both
(
&
data
,
50
);
increment_time_both
(
&
data
,
50
);
g_assert
(
!
pseudo_tcp_socket_get_next_clock
(
data
.
left
,
&
timeout
));
g_assert
_true
(
!
pseudo_tcp_socket_get_next_clock
(
data
.
left
,
&
timeout
));
/* Check the RHS can be closed after receiving the data just sent. */
/* Check the RHS can be closed after receiving the data just sent. */
g_assert_cmpint
(
pseudo_tcp_socket_recv
(
data
.
right
,
(
char
*
)
buf
,
sizeof
(
buf
)),
==
,
3
);
g_assert_cmpint
(
pseudo_tcp_socket_recv
(
data
.
right
,
(
char
*
)
buf
,
sizeof
(
buf
)),
==
,
3
);
...
@@ -1134,7 +1134,7 @@ pseudotcp_compatibility (void)
...
@@ -1134,7 +1134,7 @@ pseudotcp_compatibility (void)
pseudo_tcp_socket_close
(
data
.
right
,
FALSE
);
pseudo_tcp_socket_close
(
data
.
right
,
FALSE
);
g_assert
(
!
pseudo_tcp_socket_get_next_clock
(
data
.
right
,
&
timeout
));
g_assert
_true
(
!
pseudo_tcp_socket_get_next_clock
(
data
.
right
,
&
timeout
));
expect_sockets_closed
(
&
data
);
expect_sockets_closed
(
&
data
);
...
...
tests/test-pseudotcp-fuzzy.c
View file @
8e257029
...
@@ -119,7 +119,7 @@ write_to_sock (PseudoTcpSocket *sock)
...
@@ -119,7 +119,7 @@ write_to_sock (PseudoTcpSocket *sock)
len
=
fread
(
buf
,
1
,
sizeof
(
buf
),
in
);
len
=
fread
(
buf
,
1
,
sizeof
(
buf
),
in
);
if
(
len
==
0
)
{
if
(
len
==
0
)
{
g_debug
(
"Done reading data from file"
);
g_debug
(
"Done reading data from file"
);
g_assert
(
feof
(
in
));
g_assert
_true
(
feof
(
in
));
reading_done
=
TRUE
;
reading_done
=
TRUE
;
pseudo_tcp_socket_close
(
sock
,
FALSE
);
pseudo_tcp_socket_close
(
sock
,
FALSE
);
break
;
break
;
...
@@ -131,7 +131,7 @@ write_to_sock (PseudoTcpSocket *sock)
...
@@ -131,7 +131,7 @@ write_to_sock (PseudoTcpSocket *sock)
if
(
wlen
<
(
gint
)
len
)
{
if
(
wlen
<
(
gint
)
len
)
{
g_debug
(
"seeking %"
G_GSIZE_FORMAT
" from %lu"
,
wlen
-
len
,
ftell
(
in
));
g_debug
(
"seeking %"
G_GSIZE_FORMAT
" from %lu"
,
wlen
-
len
,
ftell
(
in
));
fseek
(
in
,
wlen
-
len
,
SEEK_CUR
);
fseek
(
in
,
wlen
-
len
,
SEEK_CUR
);
g_assert
(
!
feof
(
in
));
g_assert
_true
(
!
feof
(
in
));
g_debug
(
"Socket queue full after %d bytes written"
,
total
);
g_debug
(
"Socket queue full after %d bytes written"
,
total
);
break
;
break
;
}
}
...
@@ -176,7 +176,7 @@ readable (PseudoTcpSocket *sock, gpointer data)
...
@@ -176,7 +176,7 @@ readable (PseudoTcpSocket *sock, gpointer data)
g_assert_cmpint
(
total_wrote
,
<=
,
total_read
);
g_assert_cmpint
(
total_wrote
,
<=
,
total_read
);
g_debug
(
"Written %d bytes, need %d bytes"
,
total_wrote
,
total_read
);
g_debug
(
"Written %d bytes, need %d bytes"
,
total_wrote
,
total_read
);
if
(
total_wrote
==
total_read
&&
feof
(
in
))
{
if
(
total_wrote
==
total_read
&&
feof
(
in
))
{
g_assert
(
reading_done
);
g_assert
_true
(
reading_done
);
pseudo_tcp_socket_close
(
sock
,
FALSE
);
pseudo_tcp_socket_close
(
sock
,
FALSE
);
}
}
}
}
...
...
tests/test-pseudotcp.c
View file @
8e257029
...
@@ -71,7 +71,7 @@ static void write_to_sock (PseudoTcpSocket *sock)
...
@@ -71,7 +71,7 @@ static void write_to_sock (PseudoTcpSocket *sock)
len
=
fread
(
buf
,
1
,
sizeof
(
buf
),
in
);
len
=
fread
(
buf
,
1
,
sizeof
(
buf
),
in
);
if
(
len
==
0
)
{
if
(
len
==
0
)
{
g_debug
(
"Done reading data from file"
);
g_debug
(
"Done reading data from file"
);
g_assert
(
feof
(
in
));
g_assert
_true
(
feof
(
in
));
reading_done
=
TRUE
;
reading_done
=
TRUE
;
pseudo_tcp_socket_close
(
sock
,
FALSE
);
pseudo_tcp_socket_close
(
sock
,
FALSE
);
break
;
break
;
...
@@ -84,7 +84,7 @@ static void write_to_sock (PseudoTcpSocket *sock)
...
@@ -84,7 +84,7 @@ static void write_to_sock (PseudoTcpSocket *sock)
g_debug
(
"seeking %"
G_GSIZE_FORMAT
" from %lu"
,
wlen
-
len
,
g_debug
(
"seeking %"
G_GSIZE_FORMAT
" from %lu"
,
wlen
-
len
,
ftell
(
in
));
ftell
(
in
));
fseek
(
in
,
wlen
-
len
,
SEEK_CUR
);
fseek
(
in
,
wlen
-
len
,
SEEK_CUR
);
g_assert
(
!
feof
(
in
));
g_assert
_true
(
!
feof
(
in
));
g_debug
(
"Socket queue full after %d bytes written"
,
total
);
g_debug
(
"Socket queue full after %d bytes written"
,
total
);
break
;
break
;
}
}
...
@@ -127,7 +127,7 @@ static void readable (PseudoTcpSocket *sock, gpointer data)
...
@@ -127,7 +127,7 @@ static void readable (PseudoTcpSocket *sock, gpointer data)
g_assert_cmpint
(
total_wrote
,
<=
,
total_read
);
g_assert_cmpint
(
total_wrote
,
<=
,
total_read
);
g_debug
(
"Written %d bytes, need %d bytes"
,
total_wrote
,
total_read
);
g_debug
(
"Written %d bytes, need %d bytes"
,
total_wrote
,
total_read
);
if
(
total_wrote
==
total_read
&&
feof
(
in
))
{
if
(
total_wrote
==
total_read
&&
feof
(
in
))
{
g_assert
(
reading_done
);
g_assert
_true
(
reading_done
);
pseudo_tcp_socket_close
(
sock
,
FALSE
);
pseudo_tcp_socket_close
(
sock
,
FALSE
);
}
}
}
}
...
...
tests/test-restart.c
View file @
8e257029
...
@@ -187,7 +187,7 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
...
@@ -187,7 +187,7 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
{
for
(
i
=
cands
;
i
;
i
=
i
->
next
)
{
NiceCandidate
*
cand
=
i
->
data
;
NiceCandidate
*
cand
=
i
->
data
;
if
(
cand
)
{
if
(
cand
)
{
g_assert
(
dstaddr
);
g_assert
_true
(
dstaddr
);
*
dstaddr
=
cand
->
addr
;
*
dstaddr
=
cand
->
addr
;
}
}
}
}
...
@@ -252,8 +252,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -252,8 +252,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-restart: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-restart: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
/* step: find out the local candidates of each agent */
/* step: find out the local candidates of each agent */
...
@@ -303,7 +303,7 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -303,7 +303,7 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
* here that the role cannot be externally modified after conncheck
* here that the role cannot be externally modified after conncheck
* has started. */
* has started. */
g_object_set
(
G_OBJECT
(
ragent
),
"controlling-mode"
,
TRUE
,
NULL
);
g_object_set
(
G_OBJECT
(
ragent
),
"controlling-mode"
,
TRUE
,
NULL
);
g_assert
(
ragent
->
controlling_mode
==
FALSE
);
g_assert
_true
(
ragent
->
controlling_mode
==
FALSE
);
g_debug
(
"test-restart: Set properties, next running mainloop until connectivity checks succeed..."
);
g_debug
(
"test-restart: Set properties, next running mainloop until connectivity checks succeed..."
);
...
@@ -312,8 +312,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -312,8 +312,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
/* note: verify that STUN binding requests were sent */
/* note: verify that STUN binding requests were sent */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
/* note: verify that correct number of local candidates were reported */
/* note: verify that correct number of local candidates were reported */
g_assert_cmpint
(
global_lagent_cands
,
==
,
2
);
g_assert_cmpint
(
global_lagent_cands
,
==
,
2
);
g_assert_cmpint
(
global_ragent_cands
,
==
,
2
);
g_assert_cmpint
(
global_ragent_cands
,
==
,
2
);
...
@@ -333,8 +333,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -333,8 +333,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
g_assert_cmpint
(
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 */
/* Both agent have a distinct role at the end of the conncheck */
g_assert
(
lagent
->
controlling_mode
==
TRUE
);
g_assert
_true
(
lagent
->
controlling_mode
==
TRUE
);
g_assert
(
ragent
->
controlling_mode
==
FALSE
);
g_assert
_true
(
ragent
->
controlling_mode
==
FALSE
);
/* step: restart agents, exchange updated credentials */
/* step: restart agents, exchange updated credentials */
nice_agent_restart
(
ragent
);
nice_agent_restart
(
ragent
);
nice_agent_restart
(
lagent
);
nice_agent_restart
(
lagent
);
...
@@ -377,10 +377,10 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
...
@@ -377,10 +377,10 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
/* note: verify that payload was succesfully received */
/* note: verify that payload was succesfully received */
g_assert_cmpint
(
global_ragent_read
,
==
,
32
);
g_assert_cmpint
(
global_ragent_read
,
==
,
32
);
/* note: verify binding requests were resent after restart */
/* note: verify binding requests were resent after restart */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert
(
global_ragent_ibr_received
==
TRUE
);
g_assert
_true
(
global_ragent_ibr_received
==
TRUE
);
/* note: verify that a role switch occured for one of the agents */
/* note: verify that a role switch occured for one of the agents */
g_assert
(
ragent
->
controlling_mode
!=
lagent
->
controlling_mode
);
g_assert
_true
(
ragent
->
controlling_mode
!=
lagent
->
controlling_mode
);
g_debug
(
"test-restart: Ran mainloop, removing streams..."
);
g_debug
(
"test-restart: Ran mainloop, removing streams..."
);
...
...
tests/test-send-recv.c
View file @
8e257029
...
@@ -501,7 +501,7 @@ validate_received_messages (TestIOStreamThreadData *data, gsize buffer_offset,
...
@@ -501,7 +501,7 @@ validate_received_messages (TestIOStreamThreadData *data, gsize buffer_offset,
if
(
stream_api_is_blocking
(
test_data
->
stream_api
)
&&
data
->
reliable
)
if
(
stream_api_is_blocking
(
test_data
->
stream_api
)
&&
data
->
reliable
)
g_assert_cmpuint
(
message
->
length
,
==
,
total_buf_len
);
g_assert_cmpuint
(
message
->
length
,
==
,
total_buf_len
);
g_assert
(
message
->
from
==
NULL
);
g_assert
_true
(
message
->
from
==
NULL
);
}
}
/* Free all messages. */
/* Free all messages. */
...
...
tests/test-set-port-range.c
View file @
8e257029
...
@@ -56,14 +56,14 @@ int main (int argc, char **argv)
...
@@ -56,14 +56,14 @@ int main (int argc, char **argv)
nice_agent_set_port_range
(
agent
,
stream1
,
2
,
8888
,
8888
);
nice_agent_set_port_range
(
agent
,
stream1
,
2
,
8888
,
8888
);
/* First test with ICE-TCP enabled, this should fail on creating the port */
/* First test with ICE-TCP enabled, this should fail on creating the port */
g_assert
(
nice_agent_gather_candidates
(
agent
,
stream1
)
==
FALSE
);
g_assert
_true
(
nice_agent_gather_candidates
(
agent
,
stream1
)
==
FALSE
);
/* First test with ICE-TCP disabled, this should fail on our explicit test */
/* First test with ICE-TCP disabled, this should fail on our explicit test */
g_object_set
(
agent
,
"ice-tcp"
,
FALSE
,
NULL
);
g_object_set
(
agent
,
"ice-tcp"
,
FALSE
,
NULL
);
g_assert
(
nice_agent_gather_candidates
(
agent
,
stream1
)
==
FALSE
);
g_assert
_true
(
nice_agent_gather_candidates
(
agent
,
stream1
)
==
FALSE
);
nice_agent_set_port_range
(
agent
,
stream1
,
2
,
9999
,
9999
);
nice_agent_set_port_range
(
agent
,
stream1
,
2
,
9999
,
9999
);
g_assert
(
nice_agent_gather_candidates
(
agent
,
stream1
));
g_assert
_true
(
nice_agent_gather_candidates
(
agent
,
stream1
));
g_object_unref
(
agent
);
g_object_unref
(
agent
);
...
...
tests/test-socket-is-based-on.c
View file @
8e257029
...
@@ -45,37 +45,37 @@ static NiceSocket *udp_turn_over_tcp;
...
@@ -45,37 +45,37 @@ static NiceSocket *udp_turn_over_tcp;
static
void
static
void
socket_base_udp_bsd
(
void
)
socket_base_udp_bsd
(
void
)
{
{
g_assert
(
nice_socket_is_based_on
(
udp_bsd
,
udp_bsd
));
g_assert
_true
(
nice_socket_is_based_on
(
udp_bsd
,
udp_bsd
));
g_assert
(
!
nice_socket_is_based_on
(
udp_bsd
,
tcp_active
));
g_assert
_true
(
!
nice_socket_is_based_on
(
udp_bsd
,
tcp_active
));
g_assert
(
!
nice_socket_is_based_on
(
udp_bsd
,
pseudossl
));
g_assert
_true
(
!
nice_socket_is_based_on
(
udp_bsd
,
pseudossl
));
g_assert
(
!
nice_socket_is_based_on
(
udp_bsd
,
udp_turn_over_tcp
));
g_assert
_true
(
!
nice_socket_is_based_on
(
udp_bsd
,
udp_turn_over_tcp
));
}
}
static
void
static
void
socket_base_tcp_active
(
void
)
socket_base_tcp_active
(
void
)
{
{
g_assert
(
!
nice_socket_is_based_on
(
tcp_active
,
udp_bsd
));
g_assert
_true
(
!
nice_socket_is_based_on
(
tcp_active
,
udp_bsd
));
g_assert
(
nice_socket_is_based_on
(
tcp_active
,
tcp_active
));
g_assert
_true
(
nice_socket_is_based_on
(
tcp_active
,
tcp_active
));
g_assert
(
!
nice_socket_is_based_on
(
tcp_active
,
pseudossl
));
g_assert
_true
(
!
nice_socket_is_based_on
(
tcp_active
,
pseudossl
));
g_assert
(
!
nice_socket_is_based_on
(
tcp_active
,
udp_turn_over_tcp
));
g_assert
_true
(
!
nice_socket_is_based_on
(
tcp_active
,
udp_turn_over_tcp
));
}
}
static
void
static
void
socket_base_pseudossl
(
void
)
socket_base_pseudossl
(
void
)
{
{
g_assert
(
!
nice_socket_is_based_on
(
pseudossl
,
udp_bsd
));
g_assert
_true
(
!
nice_socket_is_based_on
(
pseudossl
,
udp_bsd
));
g_assert
(
nice_socket_is_based_on
(
pseudossl
,
tcp_active
));
g_assert
_true
(
nice_socket_is_based_on
(
pseudossl
,
tcp_active
));
g_assert
(
nice_socket_is_based_on
(
pseudossl
,
pseudossl
));
g_assert
_true
(
nice_socket_is_based_on
(
pseudossl
,
pseudossl
));
g_assert
(
!
nice_socket_is_based_on
(
pseudossl
,
udp_turn_over_tcp
));
g_assert
_true
(
!
nice_socket_is_based_on
(
pseudossl
,
udp_turn_over_tcp
));
}
}
static
void
static
void
socket_base_udp_turn_over_tcp
(
void
)
socket_base_udp_turn_over_tcp
(
void
)
{
{
g_assert
(
!
nice_socket_is_based_on
(
udp_turn_over_tcp
,
udp_bsd
));
g_assert
_true
(
!
nice_socket_is_based_on
(
udp_turn_over_tcp
,
udp_bsd
));
g_assert
(
nice_socket_is_based_on
(
udp_turn_over_tcp
,
tcp_active
));
g_assert
_true
(
nice_socket_is_based_on
(
udp_turn_over_tcp
,
tcp_active
));
g_assert
(
nice_socket_is_based_on
(
udp_turn_over_tcp
,
pseudossl
));
g_assert
_true
(
nice_socket_is_based_on
(
udp_turn_over_tcp
,
pseudossl
));
g_assert
(
nice_socket_is_based_on
(
udp_turn_over_tcp
,
udp_turn_over_tcp
));
g_assert
_true
(
nice_socket_is_based_on
(
udp_turn_over_tcp
,
udp_turn_over_tcp
));
}
}
int
int
...
...
tests/test-tcp.c
View file @
8e257029
...
@@ -52,7 +52,7 @@ static gboolean
...
@@ -52,7 +52,7 @@ static gboolean
on_server_connection_available
(
gpointer
user_data
)
on_server_connection_available
(
gpointer
user_data
)
{
{
server
=
nice_tcp_passive_socket_accept
(
passive_sock
);
server
=
nice_tcp_passive_socket_accept
(
passive_sock
);
g_assert
(
server
);
g_assert
_true
(
server
);
g_main_loop_quit
(
mainloop
);
g_main_loop_quit
(
mainloop
);
...
@@ -63,7 +63,7 @@ static gboolean
...
@@ -63,7 +63,7 @@ static gboolean
on_server_input_available
(
gpointer
user_data
)
on_server_input_available
(
gpointer
user_data
)
{
{
g_assert_cmpint
(
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_assert
_true
(
nice_address_equal
(
&
tmp
,
&
client
->
addr
));
g_main_loop_quit
(
mainloop
);
g_main_loop_quit
(
mainloop
);
...
@@ -74,7 +74,7 @@ static gboolean
...
@@ -74,7 +74,7 @@ static gboolean
on_client_input_available
(
gpointer
user_data
)
on_client_input_available
(
gpointer
user_data
)
{
{
g_assert_cmpint
(
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_assert
_true
(
nice_address_equal
(
&
tmp
,
&
server
->
addr
));
g_main_loop_quit
(
mainloop
);
g_main_loop_quit
(
mainloop
);
...
@@ -93,10 +93,10 @@ main (void)
...
@@ -93,10 +93,10 @@ main (void)
mainloop
=
g_main_loop_new
(
NULL
,
FALSE
);
mainloop
=
g_main_loop_new
(
NULL
,
FALSE
);
nice_address_init
(
&
active_bind_addr
);
nice_address_init
(
&
active_bind_addr
);
g_assert
(
nice_address_set_from_string
(
&
active_bind_addr
,
"::1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
active_bind_addr
,
"::1"
));
nice_address_init
(
&
passive_bind_addr
);
nice_address_init
(
&
passive_bind_addr
);
g_assert
(
nice_address_set_from_string
(
&
passive_bind_addr
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
passive_bind_addr
,
"127.0.0.1"
));
nice_address_set_port
(
&
passive_bind_addr
,
0
);
nice_address_set_port
(
&
passive_bind_addr
,
0
);
nice_address_init
(
&
tmp
);
nice_address_init
(
&
tmp
);
...
@@ -104,7 +104,7 @@ main (void)
...
@@ -104,7 +104,7 @@ main (void)
passive_sock
=
nice_tcp_passive_socket_new
(
g_main_loop_get_context
(
mainloop
),
passive_sock
=
nice_tcp_passive_socket_new
(
g_main_loop_get_context
(
mainloop
),
&
passive_bind_addr
,
&
error
);
&
passive_bind_addr
,
&
error
);
g_assert_no_error
(
error
);
g_assert_no_error
(
error
);
g_assert
(
passive_sock
);
g_assert
_true
(
passive_sock
);
srv_listen_source
=
g_socket_create_source
(
passive_sock
->
fileno
,
srv_listen_source
=
g_socket_create_source
(
passive_sock
->
fileno
,
G_IO_IN
,
NULL
);
G_IO_IN
,
NULL
);
...
@@ -114,15 +114,15 @@ main (void)
...
@@ -114,15 +114,15 @@ main (void)
active_sock
=
nice_tcp_active_socket_new
(
g_main_loop_get_context
(
mainloop
),
active_sock
=
nice_tcp_active_socket_new
(
g_main_loop_get_context
(
mainloop
),
&
active_bind_addr
);
&
active_bind_addr
);
g_assert
(
active_sock
);
g_assert
_true
(
active_sock
);
client
=
nice_tcp_active_socket_connect
(
active_sock
,
&
passive_sock
->
addr
);
client
=
nice_tcp_active_socket_connect
(
active_sock
,
&
passive_sock
->
addr
);
g_assert
(
client
);
g_assert
_true
(
client
);
nice_socket_free
(
active_sock
);
nice_socket_free
(
active_sock
);
active_sock
=
NULL
;
active_sock
=
NULL
;
g_main_loop_run
(
mainloop
);
/* -> on_server_connection_available */
g_main_loop_run
(
mainloop
);
/* -> on_server_connection_available */
g_assert
(
server
);
g_assert
_true
(
server
);
srv_input_source
=
g_socket_create_source
(
server
->
fileno
,
G_IO_IN
,
NULL
);
srv_input_source
=
g_socket_create_source
(
server
->
fileno
,
G_IO_IN
,
NULL
);
g_source_set_callback
(
srv_input_source
,
g_source_set_callback
(
srv_input_source
,
...
@@ -134,20 +134,20 @@ main (void)
...
@@ -134,20 +134,20 @@ main (void)
on_client_input_available
,
NULL
,
NULL
);
on_client_input_available
,
NULL
,
NULL
);
g_source_attach
(
cli_input_source
,
g_main_loop_get_context
(
mainloop
));
g_source_attach
(
cli_input_source
,
g_main_loop_get_context
(
mainloop
));
g_assert
(
nice_address_get_port
(
&
client
->
addr
)
!=
0
);
g_assert
_true
(
nice_address_get_port
(
&
client
->
addr
)
!=
0
);
g_assert
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
tmp
,
"127.0.0.1"
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
nice_address_set_port
(
&
tmp
,
nice_address_get_port
(
&
server
->
addr
));
g_assert
(
nice_address_get_port
(
&
tmp
)
!=
0
);
g_assert
_true
(
nice_address_get_port
(
&
tmp
)
!=
0
);
g_assert_cmpint
(
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_main_loop_run
(
mainloop
);
/* -> on_server_input_available */
g_assert
(
0
==
strncmp
(
buf
,
"hello"
,
5
));
g_assert
_true
(
0
==
strncmp
(
buf
,
"hello"
,
5
));
g_assert_cmpint
(
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_main_loop_run
(
mainloop
);
/* -> on_client_input_available */
g_assert
(
0
==
strncmp
(
buf
,
"uryyb"
,
5
));
g_assert
_true
(
0
==
strncmp
(
buf
,
"uryyb"
,
5
));
nice_socket_free
(
client
);
nice_socket_free
(
client
);
nice_socket_free
(
server
);
nice_socket_free
(
server
);
...
...
tests/test-thread.c
View file @
8e257029
...
@@ -66,7 +66,7 @@ gint global_ragent_buffers = 0;
...
@@ -66,7 +66,7 @@ gint global_ragent_buffers = 0;
g_main_context_iteration (context, FALSE); \
g_main_context_iteration (context, FALSE); \
} \
} \
\
\
g_assert (!(var)); \
g_assert
_true
(!(var)); \
}
}
static
gpointer
static
gpointer
...
@@ -119,7 +119,7 @@ static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpoin
...
@@ -119,7 +119,7 @@ static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpoin
g_free
(
password
);
g_free
(
password
);
cands
=
nice_agent_get_local_candidates
(
agent
,
id
,
1
);
cands
=
nice_agent_get_local_candidates
(
agent
,
id
,
1
);
g_assert
(
cands
!=
NULL
);
g_assert
_true
(
cands
!=
NULL
);
nice_agent_set_remote_candidates
(
other
,
other_id
,
1
,
cands
);
nice_agent_set_remote_candidates
(
other
,
other_id
,
1
,
cands
);
...
@@ -263,12 +263,12 @@ int main (void)
...
@@ -263,12 +263,12 @@ int main (void)
guint
port
=
0
;
guint
port
=
0
;
gboolean
mode
=
FALSE
;
gboolean
mode
=
FALSE
;
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server"
,
&
string
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server"
,
&
string
,
NULL
);
g_assert
(
stun_server
==
NULL
||
strcmp
(
string
,
stun_server
)
==
0
);
g_assert
_true
(
stun_server
==
NULL
||
strcmp
(
string
,
stun_server
)
==
0
);
g_free
(
string
);
g_free
(
string
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server-port"
,
&
port
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server-port"
,
&
port
,
NULL
);
g_assert
(
stun_server_port
==
NULL
||
port
==
(
guint
)
atoi
(
stun_server_port
));
g_assert
_true
(
stun_server_port
==
NULL
||
port
==
(
guint
)
atoi
(
stun_server_port
));
g_object_get
(
G_OBJECT
(
lagent
),
"controlling-mode"
,
&
mode
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"controlling-mode"
,
&
mode
,
NULL
);
g_assert
(
mode
==
TRUE
);
g_assert
_true
(
mode
==
TRUE
);
g_object_set
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
300
,
NULL
);
g_object_set
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
300
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
&
max_checks
,
NULL
);
g_object_get
(
G_OBJECT
(
lagent
),
"max-connectivity-checks"
,
&
max_checks
,
NULL
);
g_assert_cmpuint
(
max_checks
,
==
,
300
);
g_assert_cmpuint
(
max_checks
,
==
,
300
);
...
@@ -280,8 +280,8 @@ int main (void)
...
@@ -280,8 +280,8 @@ int main (void)
lthread
=
g_thread_new
(
"lthread libnice"
,
mainloop_thread
,
lmainloop
);
lthread
=
g_thread_new
(
"lthread libnice"
,
mainloop_thread
,
lmainloop
);
rthread
=
g_thread_new
(
"rthread libnice"
,
mainloop_thread
,
rmainloop
);
rthread
=
g_thread_new
(
"rthread libnice"
,
mainloop_thread
,
rmainloop
);
g_assert
(
lthread
);
g_assert
_true
(
lthread
);
g_assert
(
rthread
);
g_assert
_true
(
rthread
);
ls_id
=
nice_agent_add_stream
(
lagent
,
2
);
ls_id
=
nice_agent_add_stream
(
lagent
,
2
);
rs_id
=
nice_agent_add_stream
(
ragent
,
2
);
rs_id
=
nice_agent_add_stream
(
ragent
,
2
);
...
@@ -302,8 +302,8 @@ int main (void)
...
@@ -302,8 +302,8 @@ int main (void)
ldthread
=
g_thread_new
(
"ldthread libnice"
,
mainloop_thread
,
ldmainloop
);
ldthread
=
g_thread_new
(
"ldthread libnice"
,
mainloop_thread
,
ldmainloop
);
rdthread
=
g_thread_new
(
"rdthread libnice"
,
mainloop_thread
,
rdmainloop
);
rdthread
=
g_thread_new
(
"rdthread libnice"
,
mainloop_thread
,
rdmainloop
);
g_assert
(
ldthread
);
g_assert
_true
(
ldthread
);
g_assert
(
rdthread
);
g_assert
_true
(
rdthread
);
g_debug
(
"ragent_buffers: %d lagent_buffers: %d"
,
global_lagent_buffers
,
g_debug
(
"ragent_buffers: %d lagent_buffers: %d"
,
global_lagent_buffers
,
global_ragent_buffers
);
global_ragent_buffers
);
...
...
tests/test-trickle.c
View file @
8e257029
...
@@ -311,8 +311,8 @@ int main (void)
...
@@ -311,8 +311,8 @@ int main (void)
global_ragent_gathering_done
!=
TRUE
)
{
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-trickle: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_debug
(
"test-trickle: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
}
}
{
{
...
@@ -349,7 +349,7 @@ int main (void)
...
@@ -349,7 +349,7 @@ int main (void)
g_main_loop_run
(
global_mainloop
);
g_main_loop_run
(
global_mainloop
);
/* note: verify that STUN binding requests were sent */
/* note: verify that STUN binding requests were sent */
g_assert
(
global_lagent_ibr_received
==
TRUE
);
g_assert
_true
(
global_lagent_ibr_received
==
TRUE
);
g_assert_cmpint
(
global_ragent_ibr_received
,
==
,
TRUE
);
g_assert_cmpint
(
global_ragent_ibr_received
,
==
,
TRUE
);
g_assert_cmpint
(
global_lagent_state
,
==
,
NICE_COMPONENT_STATE_READY
);
g_assert_cmpint
(
global_lagent_state
,
==
,
NICE_COMPONENT_STATE_READY
);
...
...
tests/test-turn.c
View file @
8e257029
...
@@ -85,7 +85,7 @@ static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint
...
@@ -85,7 +85,7 @@ static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint
global_components_ready
++
;
global_components_ready
++
;
else
if
(
state
==
NICE_COMPONENT_STATE_CONNECTED
&&
ready_to_connected
)
else
if
(
state
==
NICE_COMPONENT_STATE_CONNECTED
&&
ready_to_connected
)
global_components_ready
--
;
global_components_ready
--
;
g_assert
(
state
!=
NICE_COMPONENT_STATE_FAILED
);
g_assert
_true
(
state
!=
NICE_COMPONENT_STATE_FAILED
);
g_debug
(
"test-turn: checks READY %u."
,
global_components_ready
);
g_debug
(
"test-turn: checks READY %u."
,
global_components_ready
);
}
}
...
@@ -222,13 +222,13 @@ run_test(guint turn_port, gboolean is_ipv6,
...
@@ -222,13 +222,13 @@ run_test(guint turn_port, gboolean is_ipv6,
nice_agent_set_relay_info
(
ragent
,
rs_id
,
1
,
nice_agent_set_relay_info
(
ragent
,
rs_id
,
1
,
localhost
,
turn_port
,
TURN_USER
,
TURN_PASS
,
turn_type
);
localhost
,
turn_port
,
TURN_USER
,
TURN_PASS
,
turn_type
);
g_assert
(
global_lagent_gathering_done
==
FALSE
);
g_assert
_true
(
global_lagent_gathering_done
==
FALSE
);
g_assert
(
global_ragent_gathering_done
==
FALSE
);
g_assert
_true
(
global_ragent_gathering_done
==
FALSE
);
g_debug
(
"test-turn: Added streams, running context until 'candidate-gathering-done'..."
);
g_debug
(
"test-turn: Added streams, running context until 'candidate-gathering-done'..."
);
/* Gather candidates and test nice_agent_set_port_range */
/* Gather candidates and test nice_agent_set_port_range */
g_assert
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
lagent
,
ls_id
)
==
TRUE
);
g_assert
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
g_assert
_true
(
nice_agent_gather_candidates
(
ragent
,
rs_id
)
==
TRUE
);
nice_agent_attach_recv
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
nice_agent_attach_recv
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
g_main_context_default
(),
cb_nice_recv
,
GUINT_TO_POINTER
(
1
));
g_main_context_default
(),
cb_nice_recv
,
GUINT_TO_POINTER
(
1
));
...
@@ -237,10 +237,10 @@ run_test(guint turn_port, gboolean is_ipv6,
...
@@ -237,10 +237,10 @@ run_test(guint turn_port, gboolean is_ipv6,
while
(
!
global_lagent_gathering_done
)
while
(
!
global_lagent_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
_true
(
global_lagent_gathering_done
==
TRUE
);
while
(
!
global_ragent_gathering_done
)
while
(
!
global_ragent_gathering_done
)
g_main_context_iteration
(
NULL
,
TRUE
);
g_main_context_iteration
(
NULL
,
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
g_assert
_true
(
global_ragent_gathering_done
==
TRUE
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
set_credentials
(
lagent
,
ls_id
,
ragent
,
rs_id
);
...
...
tests/test.c
View file @
8e257029
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
g_main_context_iteration (context, FALSE); \
g_main_context_iteration (context, FALSE); \
} \
} \
\
\
g_assert (!(var)); \
g_assert
_true
(!(var)); \
}
}
gint
gint
...
@@ -76,21 +76,21 @@ main (void)
...
@@ -76,21 +76,21 @@ main (void)
nice_address_init
(
&
addr_local
);
nice_address_init
(
&
addr_local
);
nice_address_init
(
&
addr_remote
);
nice_address_init
(
&
addr_remote
);
g_assert
(
nice_address_set_from_string
(
&
addr_local
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
addr_local
,
"127.0.0.1"
));
g_assert
(
nice_address_set_from_string
(
&
addr_remote
,
"127.0.0.1"
));
g_assert
_true
(
nice_address_set_from_string
(
&
addr_remote
,
"127.0.0.1"
));
nice_address_set_port
(
&
addr_remote
,
2345
);
nice_address_set_port
(
&
addr_remote
,
2345
);
agent
=
nice_agent_new
(
NULL
,
NICE_COMPATIBILITY_RFC5245
);
agent
=
nice_agent_new
(
NULL
,
NICE_COMPATIBILITY_RFC5245
);
g_object_set
(
G_OBJECT
(
agent
),
"ice-tcp"
,
FALSE
,
NULL
);
g_object_set
(
G_OBJECT
(
agent
),
"ice-tcp"
,
FALSE
,
NULL
);
g_assert
(
agent
->
local_addresses
==
NULL
);
g_assert
_true
(
agent
->
local_addresses
==
NULL
);
/* add one local address */
/* add one local address */
nice_agent_add_local_address
(
agent
,
&
addr_local
);
nice_agent_add_local_address
(
agent
,
&
addr_local
);
g_assert
(
agent
->
local_addresses
!=
NULL
);
g_assert
_true
(
agent
->
local_addresses
!=
NULL
);
g_assert_cmpuint
(
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
));
g_assert
_true
(
nice_address_equal
(
agent
->
local_addresses
->
data
,
&
addr_local
));
/* add a stream */
/* add a stream */
stream_id
=
nice_agent_add_stream
(
agent
,
1
);
stream_id
=
nice_agent_add_stream
(
agent
,
1
);
...
@@ -103,8 +103,8 @@ main (void)
...
@@ -103,8 +103,8 @@ main (void)
/* socket manager uses random port number */
/* socket manager uses random port number */
nice_address_set_port
(
&
addr_local
,
1
);
nice_address_set_port
(
&
addr_local
,
1
);
nice_address_set_port
(
&
(
candidate
->
addr
),
1
);
nice_address_set_port
(
&
(
candidate
->
addr
),
1
);
g_assert
(
nice_address_equal
(
&
(
candidate
->
addr
),
&
addr_local
));
g_assert
_true
(
nice_address_equal
(
&
(
candidate
->
addr
),
&
addr_local
));
g_assert
(
strncmp
(
candidate
->
foundation
,
"1"
,
1
)
==
0
);
g_assert
_true
(
strncmp
(
candidate
->
foundation
,
"1"
,
1
)
==
0
);
for
(
i
=
candidates
;
i
;
i
=
i
->
next
)
for
(
i
=
candidates
;
i
;
i
=
i
->
next
)
nice_candidate_free
((
NiceCandidate
*
)
i
->
data
);
nice_candidate_free
((
NiceCandidate
*
)
i
->
data
);
g_slist_free
(
candidates
);
g_slist_free
(
candidates
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment