Debian Codegraph @

Xpjproject/pjnath/src/pjnath-test/test.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include <pjlib.h>
20 #include <pjlib-util.h>
21 #include <pjnath.h>
22
23 #if defined(PJ_EXCLUDE_BENCHMARK_TESTS) && (PJ_EXCLUDE_BENCHMARK_TESTS==1)
24 # define WITH_BENCHMARK 0
25 #else
26 # define WITH_BENCHMARK 1
27 #endif
28
29 #define INCLUDE_STUN_TEST 1
30 #define INCLUDE_ICE_TEST 1
31 #define INCLUDE_TRICKLE_ICE_TEST 1
32 #define INCLUDE_STUN_SOCK_TEST 1
33 #define INCLUDE_TURN_SOCK_TEST 1
34 #define INCLUDE_CONCUR_TEST 1
35
36 #define GET_AF(use_ipv6) (use_ipv6?pj_AF_INET6():pj_AF_INET())
37
38 #if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6
39 # define USE_IPV6 1
40 #else
41 # define USE_IPV6 0
42 #endif
43
44 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK
45 # define USE_TLS 1
46 #else
47 # define USE_TLS 0
48 #endif
49
50 #define ICE_TEST_ARRAY_COUNT 6
51
52 /* Test id to be specified in ice_test() */
53 enum ice_test_id_t
54 {
55 ICE_TEST_BASIC_HOST,
56 ICE_TEST_BASIC_SRFLX,
57 ICE_TEST_BASIC_RELAY,
58 ICE_TEST_STUN_RES_FAIL,
59 ICE_TEST_TURN_ALLOC_FAIL,
60 ICE_TEST_STUN_FAIL_TURN_DEALLOC,
61
62 ICE_TEST_START_ARRAY,
63 };
64
65 int stun_test(void);
66 int sess_auth_test(void);
67 int stun_sock_test(void);
68 int turn_sock_test(void*);
69 int ice_test(void*);
70 int ice_conc_test(void);
71 int trickle_ice_test(void);
72 int concur_test(void);
73 int test_main(int argc, char *argv[]);
74
75 #define app_perror(msg, rc) app_perror_dbg(msg, rc, __FILE__, __LINE__)
76 extern void app_perror_dbg(const char *msg, pj_status_t rc,
77 const char *file, int line);
78 extern void app_set_sock_nb(pj_sock_t sock);
79 extern pj_pool_factory *mem;
80
81 int ice_one_conc_test(pj_stun_config *stun_cfg, int err_quit);
82
83 #define UT_MAX_TESTS 80
84 #include "../../../pjlib/src/pjlib-test/test_util.h"
85
86 struct test_app_t
87 {
88 ut_app_t ut_app;
89 };
90 extern struct test_app_t test_app;
91
92
93 ////////////////////////////////////
94 /*
95 * Utilities
96 */
97 typedef struct app_sess_t
98 {
99 pj_caching_pool cp;
100 pj_pool_t *pool;
101 pj_stun_config stun_cfg;
102 } app_sess_t;
103
104 pj_status_t create_stun_config(app_sess_t *stun_cfg);
105 void destroy_stun_config(app_sess_t *stun_cfg);
106
107 void poll_events(pj_stun_config *stun_cfg, unsigned msec,
108 pj_bool_t first_event_only);
109
110 typedef struct pjlib_state
111 {
112 unsigned timer_cnt; /* Number of timer entries */
113 unsigned pool_used_cnt; /* Number of app pools */
114 } pjlib_state;
115
116
117 void capture_pjlib_state(pj_stun_config *cfg, struct pjlib_state *st);
118 int check_pjlib_state(pj_stun_config *cfg,
119 const struct pjlib_state *initial_st);
120
121 pj_turn_tp_type get_turn_tp_type(pj_uint32_t flag);
122
123 #define ERR_MEMORY_LEAK 1
124 #define ERR_TIMER_LEAK 2
125