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
0ccf0d7c
Commit
0ccf0d7c
authored
Aug 04, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port libnice tests to match new API
parent
6056277b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
75 deletions
+29
-75
agent/test-add-remove-stream.c
agent/test-add-remove-stream.c
+1
-5
agent/test-fallback.c
agent/test-fallback.c
+4
-12
agent/test-fullmode.c
agent/test-fullmode.c
+4
-15
agent/test-mainloop.c
agent/test-mainloop.c
+3
-7
agent/test-poll.c
agent/test-poll.c
+5
-4
agent/test-recv.c
agent/test-recv.c
+3
-7
agent/test-restart.c
agent/test-restart.c
+4
-10
agent/test-thread.c
agent/test-thread.c
+2
-10
agent/test.c
agent/test.c
+3
-5
No files found.
agent/test-add-remove-stream.c
View file @
0ccf0d7c
...
...
@@ -41,7 +41,6 @@
#include "agent.h"
#include "agent-priv.h"
#include "udp-fake.h"
#include <string.h>
int
...
...
@@ -49,18 +48,16 @@ main (void)
{
NiceAgent
*
agent
;
NiceAddress
addr
;
NiceUDPSocketFactory
factory
;
nice_address_init
(
&
addr
);
g_type_init
();
g_thread_init
(
NULL
);
nice_udp_fake_socket_factory_init
(
&
factory
);
if
(
!
nice_address_set_from_string
(
&
addr
,
"127.0.0.1"
))
g_assert_not_reached
();
agent
=
nice_agent_new
(
&
factory
,
NULL
,
NICE_COMPATIBILITY_ID19
);
agent
=
nice_agent_new
(
NULL
,
NICE_COMPATIBILITY_ID19
);
nice_agent_add_local_address
(
agent
,
&
addr
);
g_assert
(
nice_agent_add_stream
(
agent
,
1
)
==
1
);
...
...
@@ -76,7 +73,6 @@ main (void)
g_assert
(
NULL
==
agent
->
streams
);
g_object_unref
(
agent
);
nice_udp_socket_factory_close
(
&
factory
);
return
0
;
}
...
...
agent/test-fallback.c
View file @
0ccf0d7c
...
...
@@ -44,7 +44,6 @@
#include "agent.h"
#include "agent-priv.h"
/* for testing purposes */
#include "udp-bsd.h"
static
NiceComponentState
global_lagent_state
=
NICE_COMPONENT_STATE_LAST
;
static
NiceComponentState
global_ragent_state
=
NICE_COMPONENT_STATE_LAST
;
...
...
@@ -474,7 +473,6 @@ static int run_safe_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAdd
int
main
(
void
)
{
NiceAgent
*
lagent
,
*
ragent
;
/* agent's L and R */
NiceUDPSocketFactory
udpfactory
;
NiceAddress
baseaddr
;
int
result
;
guint
timer_id
;
...
...
@@ -489,13 +487,9 @@ int main (void)
* - no IPv6 support
*/
nice_udp_bsd_socket_factory_init
(
&
udpfactory
);
/* step: create the agents L and R */
lagent
=
nice_agent_new
(
&
udpfactory
,
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
ragent
=
nice_agent_new
(
&
udpfactory
,
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
lagent
=
nice_agent_new
(
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
ragent
=
nice_agent_new
(
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
...
...
@@ -557,10 +551,8 @@ int main (void)
g_object_unref
(
lagent
);
g_object_unref
(
ragent
);
nice_udp_socket_factory_close
(
&
udpfactory
);
g_main_loop_unref
(
global_mainloop
),
global_mainloop
=
NULL
;
g_main_loop_unref
(
global_mainloop
);
global_mainloop
=
NULL
;
g_source_remove
(
timer_id
);
...
...
agent/test-fullmode.c
View file @
0ccf0d7c
...
...
@@ -42,7 +42,6 @@
#include <string.h>
#include "agent.h"
#include "udp-bsd.h"
static
NiceComponentState
global_lagent_state
[
2
]
=
{
NICE_COMPONENT_STATE_LAST
,
NICE_COMPONENT_STATE_LAST
};
static
NiceComponentState
global_ragent_state
[
2
]
=
{
NICE_COMPONENT_STATE_LAST
,
NICE_COMPONENT_STATE_LAST
};
...
...
@@ -721,7 +720,6 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
int
main
(
void
)
{
NiceAgent
*
lagent
,
*
ragent
;
/* agent's L and R */
NiceUDPSocketFactory
udpfactory
;
NiceAddress
baseaddr
;
int
result
;
guint
timer_id
;
...
...
@@ -736,13 +734,9 @@ int main (void)
* - no IPv6 support
*/
nice_udp_bsd_socket_factory_init
(
&
udpfactory
);
/* step: create the agents L and R */
lagent
=
nice_agent_new
(
&
udpfactory
,
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
ragent
=
nice_agent_new
(
&
udpfactory
,
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
lagent
=
nice_agent_new
(
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
ragent
=
nice_agent_new
(
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
/* step: add a timer to catch state changes triggered by signals */
timer_id
=
g_timeout_add
(
30000
,
timer_cb
,
NULL
);
...
...
@@ -785,13 +779,10 @@ int main (void)
/* step: test setter/getter functions for properties */
{
gpointer
pointer
;
guint
max_checks
=
0
;
gchar
*
string
=
NULL
;
guint
port
=
0
;
gboolean
mode
=
FALSE
;
g_object_get
(
G_OBJECT
(
lagent
),
"socket-factory"
,
&
pointer
,
NULL
);
g_assert
(
pointer
==
(
gpointer
)
&
udpfactory
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server"
,
&
string
,
NULL
);
g_assert
(
stun_server
==
NULL
||
strcmp
(
string
,
stun_server
)
==
0
);
g_free
(
string
);
...
...
@@ -905,10 +896,8 @@ int main (void)
g_object_unref
(
lagent
);
g_object_unref
(
ragent
);
nice_udp_socket_factory_close
(
&
udpfactory
);
g_main_loop_unref
(
global_mainloop
),
global_mainloop
=
NULL
;
g_main_loop_unref
(
global_mainloop
);
global_mainloop
=
NULL
;
g_source_remove
(
timer_id
);
...
...
agent/test-mainloop.c
View file @
0ccf0d7c
...
...
@@ -68,7 +68,6 @@ main (void)
{
NiceAgent
*
agent
;
NiceAddress
addr
;
NiceUDPSocketFactory
factory
;
guint
stream
;
nice_address_init
(
&
addr
);
...
...
@@ -76,9 +75,7 @@ main (void)
g_thread_init
(
NULL
);
loop
=
g_main_loop_new
(
NULL
,
FALSE
);
nice_udp_fake_socket_factory_init
(
&
factory
);
agent
=
nice_agent_new
(
&
factory
,
g_main_loop_get_context
(
loop
),
NICE_COMPATIBILITY_ID19
);
agent
=
nice_agent_new
(
g_main_loop_get_context
(
loop
),
NICE_COMPATIBILITY_ID19
);
nice_address_set_ipv4
(
&
addr
,
0x7f000001
);
nice_agent_add_local_address
(
agent
,
&
addr
);
stream
=
nice_agent_add_stream
(
agent
,
1
);
...
...
@@ -96,15 +93,14 @@ main (void)
candidates
=
nice_agent_get_local_candidates
(
agent
,
1
,
1
);
candidate
=
candidates
->
data
;
sock
=
candidate
->
sockptr
;
g_slist_free
(
candidates
);
nice_udp_fake_socket_push_recv
(
sock
,
&
addr
,
6
,
"
\x80
hello"
);
nice_udp_socket_send
(
sock
,
&
(
candidate
->
addr
),
6
,
"
\x80
hello"
);
g_slist_free
(
candidates
);
}
g_main_loop_run
(
loop
);
g_object_unref
(
agent
);
nice_udp_socket_factory_close
(
&
factory
);
return
0
;
}
agent/test-poll.c
View file @
0ccf0d7c
...
...
@@ -44,6 +44,8 @@
#include <unistd.h>
#include <nice/nice.h>
#include "udp.h"
static
gboolean
cb_called
=
FALSE
;
...
...
@@ -71,7 +73,6 @@ main (void)
{
NiceAgent
*
agent
;
NiceAddress
addr
;
NiceUDPSocketFactory
factory
;
NiceUDPSocket
*
sock
;
gint
pipe_fds
[
2
];
GSList
*
fds
=
NULL
;
...
...
@@ -88,8 +89,7 @@ main (void)
if
(
!
nice_address_set_from_string
(
&
addr
,
"127.0.0.1"
))
g_assert_not_reached
();
nice_udp_fake_socket_factory_init
(
&
factory
);
agent
=
nice_agent_new
(
&
factory
,
NULL
,
NICE_COMPATIBILITY_ID19
);
agent
=
nice_agent_new
(
NULL
,
NICE_COMPATIBILITY_ID19
);
nice_agent_add_local_address
(
agent
,
&
addr
);
stream_id
=
nice_agent_add_stream
(
agent
,
1
);
nice_agent_gather_candidates
(
agent
,
stream_id
);
...
...
@@ -101,6 +101,7 @@ main (void)
candidates
=
nice_agent_get_local_candidates
(
agent
,
stream_id
,
1
);
candidate
=
candidates
->
data
;
sock
=
candidate
->
sockptr
;
addr
=
candidate
->
addr
;
g_slist_free
(
candidates
);
}
...
...
@@ -131,7 +132,7 @@ main (void)
/* send fake data */
nice_udp_
fake_socket_push_recv
(
sock
,
&
addr
,
7
,
"
\x80
lalala"
);
nice_udp_
socket_send
(
sock
,
&
addr
,
7
,
"
\x80
lalala"
);
/* poll again */
...
...
agent/test-recv.c
View file @
0ccf0d7c
...
...
@@ -41,7 +41,7 @@
#include <string.h>
#include "udp
-fake
.h"
#include "udp.h"
#include "agent.h"
int
...
...
@@ -49,17 +49,14 @@ main (void)
{
NiceAgent
*
agent
;
NiceAddress
addr
;
NiceUDPSocketFactory
factory
;
guint
stream_id
;
nice_address_init
(
&
addr
);
g_type_init
();
g_thread_init
(
NULL
);
nice_udp_fake_socket_factory_init
(
&
factory
);
/* set up agent */
agent
=
nice_agent_new
(
&
factory
,
NULL
,
NICE_COMPATIBILITY_ID19
);
agent
=
nice_agent_new
(
NULL
,
NICE_COMPATIBILITY_ID19
);
g_assert
(
nice_address_set_from_string
(
&
addr
,
"192.168.0.1"
));
nice_agent_add_local_address
(
agent
,
&
addr
);
stream_id
=
nice_agent_add_stream
(
agent
,
1
);
...
...
@@ -78,7 +75,7 @@ main (void)
candidate
=
candidates
->
data
;
g_slist_free
(
candidates
);
sock
=
candidate
->
sockptr
;
nice_udp_
fake_socket_push_recv
(
sock
,
&
addr
,
7
,
"
\x80
lalala"
);
nice_udp_
socket_send
(
sock
,
&
candidate
->
addr
,
7
,
"
\x80
lalala"
);
len
=
nice_agent_recv
(
agent
,
stream_id
,
candidate
->
component_id
,
1024
,
buf
);
g_assert
(
len
==
7
);
...
...
@@ -87,7 +84,6 @@ main (void)
/* clean up */
g_object_unref
(
agent
);
nice_udp_socket_factory_close
(
&
factory
);
return
0
;
}
...
...
agent/test-restart.c
View file @
0ccf0d7c
...
...
@@ -41,7 +41,6 @@
#include "agent.h"
#include "agent-priv.h"
/* for testing purposes */
#include "udp-bsd.h"
static
NiceComponentState
global_lagent_state
=
NICE_COMPONENT_STATE_LAST
;
static
NiceComponentState
global_ragent_state
=
NICE_COMPONENT_STATE_LAST
;
...
...
@@ -379,7 +378,6 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
int
main
(
void
)
{
NiceAgent
*
lagent
,
*
ragent
;
/* agent's L and R */
NiceUDPSocketFactory
udpfactory
;
NiceAddress
baseaddr
;
int
result
;
guint
timer_id
;
...
...
@@ -394,13 +392,10 @@ int main (void)
* - no IPv6 support
*/
nice_udp_bsd_socket_factory_init
(
&
udpfactory
);
/* step: create the agents L and R */
lagent
=
nice_agent_new
(
&
udpfactory
,
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
ragent
=
nice_agent_new
(
&
udpfactory
,
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
lagent
=
nice_agent_new
(
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
ragent
=
nice_agent_new
(
g_main_loop_get_context
(
global_mainloop
),
NICE_COMPATIBILITY_ID19
);
/* step: add a timer to catch state changes triggered by signals */
...
...
@@ -453,10 +448,9 @@ int main (void)
g_object_unref
(
lagent
);
g_object_unref
(
ragent
);
nice_udp_socket_factory_close
(
&
udpfactory
);
g_main_loop_unref
(
global_mainloop
)
,
global_mainloop
=
NULL
;
g_main_loop_unref
(
global_mainloop
)
;
global_mainloop
=
NULL
;
g_source_remove
(
timer_id
);
...
...
agent/test-thread.c
View file @
0ccf0d7c
...
...
@@ -42,7 +42,6 @@
#include <string.h>
#include "agent.h"
#include "udp-bsd.h"
GMainLoop
*
error_loop
;
...
...
@@ -171,7 +170,6 @@ static void cb_component_state_changed (NiceAgent *agent,
int
main
(
void
)
{
NiceAgent
*
lagent
,
*
ragent
;
/* agent's L and R */
NiceUDPSocketFactory
udpfactory
;
NiceAddress
baseaddr
;
guint
timer_id
;
const
char
*
stun_server
=
NULL
,
*
stun_server_port
=
NULL
;
...
...
@@ -198,11 +196,10 @@ int main (void)
error_loop
=
g_main_loop_new
(
NULL
,
FALSE
);
nice_udp_bsd_socket_factory_init
(
&
udpfactory
);
/* step: create the agents L and R */
lagent
=
nice_agent_new
(
&
udpfactory
,
lmainctx
,
NICE_COMPATIBILITY_GOOGLE
);
ragent
=
nice_agent_new
(
&
udpfactory
,
rmainctx
,
NICE_COMPATIBILITY_GOOGLE
);
lagent
=
nice_agent_new
(
lmainctx
,
NICE_COMPATIBILITY_MSN
);
ragent
=
nice_agent_new
(
rmainctx
,
NICE_COMPATIBILITY_MSN
);
g_object_set_data
(
G_OBJECT
(
lagent
),
"other-agent"
,
ragent
);
g_object_set_data
(
G_OBJECT
(
ragent
),
"other-agent"
,
lagent
);
...
...
@@ -243,13 +240,10 @@ int main (void)
/* step: test setter/getter functions for properties */
{
gpointer
pointer
;
guint
max_checks
=
0
;
gchar
*
string
=
NULL
;
guint
port
=
0
;
gboolean
mode
=
FALSE
;
g_object_get
(
G_OBJECT
(
lagent
),
"socket-factory"
,
&
pointer
,
NULL
);
g_assert
(
pointer
==
(
gpointer
)
&
udpfactory
);
g_object_get
(
G_OBJECT
(
lagent
),
"stun-server"
,
&
string
,
NULL
);
g_assert
(
stun_server
==
NULL
||
strcmp
(
string
,
stun_server
)
==
0
);
g_free
(
string
);
...
...
@@ -322,8 +316,6 @@ int main (void)
g_object_unref
(
lagent
);
g_object_unref
(
ragent
);
nice_udp_socket_factory_close
(
&
udpfactory
);
g_main_loop_unref
(
lmainloop
);
g_main_loop_unref
(
rmainloop
);
g_main_loop_unref
(
ldmainloop
);
...
...
agent/test.c
View file @
0ccf0d7c
...
...
@@ -40,7 +40,6 @@
#include <string.h>
#include "udp-fake.h"
#include "agent.h"
#include "agent-priv.h"
...
...
@@ -50,7 +49,6 @@ main (void)
NiceAgent
*
agent
;
NiceAddress
addr_local
,
addr_remote
;
NiceCandidate
*
candidate
;
NiceUDPSocketFactory
factory
;
GSList
*
candidates
;
guint
stream_id
;
...
...
@@ -59,13 +57,12 @@ main (void)
g_type_init
();
g_thread_init
(
NULL
);
nice_udp_fake_socket_factory_init
(
&
factory
);
g_assert
(
nice_address_set_from_string
(
&
addr_local
,
"192.168.0.1"
));
g_assert
(
nice_address_set_from_string
(
&
addr_remote
,
"192.168.0.2"
));
nice_address_set_port
(
&
addr_remote
,
2345
);
agent
=
nice_agent_new
(
&
factory
,
NULL
,
NICE_COMPATIBILITY_ID19
);
agent
=
nice_agent_new
(
NULL
,
NICE_COMPATIBILITY_ID19
);
g_assert
(
agent
->
local_addresses
==
NULL
);
...
...
@@ -84,8 +81,9 @@ main (void)
candidates
=
nice_agent_get_local_candidates
(
agent
,
stream_id
,
1
);
g_assert
(
g_slist_length
(
candidates
)
==
1
);
candidate
=
candidates
->
data
;
/*
fake socket manager uses incremental port numbers starting at 1
*/
/*
socket manager uses random port number
*/
nice_address_set_port
(
&
addr_local
,
1
);
nice_address_set_port
(
&
(
candidate
->
addr
),
1
);
g_assert
(
nice_address_equal
(
&
(
candidate
->
addr
),
&
addr_local
));
g_assert
(
strncmp
(
candidate
->
foundation
,
"1"
,
1
)
==
0
);
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