~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjlib/src/pjlib-test/test.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: test.c 3553 2011-05-05 06:14:19Z nanang $ */
2
 
/*
3
 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
 
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
 */
20
 
#include "test.h"
21
 
#include <pjlib.h>
22
 
#ifdef _MSC_VER
23
 
#  pragma warning(disable:4127)
24
 
#endif
25
 
 
26
 
#define DO_TEST(test)   do { \
27
 
                            PJ_LOG(3, ("test", "Running %s...", #test));  \
28
 
                            rc = test; \
29
 
                            PJ_LOG(3, ("test",  \
30
 
                                       "%s(%d)",  \
31
 
                                       (rc ? "..ERROR" : "..success"), rc)); \
32
 
                            if (rc!=0) goto on_return; \
33
 
                        } while (0)
34
 
 
35
 
 
36
 
pj_pool_factory *mem;
37
 
 
38
 
int param_echo_sock_type;
39
 
const char *param_echo_server = ECHO_SERVER_ADDRESS;
40
 
int param_echo_port = ECHO_SERVER_START_PORT;
41
 
int param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
42
 
                      PJ_LOG_HAS_MICRO_SEC;
43
 
 
44
 
int null_func()
45
 
{
46
 
    return 0;
47
 
}
48
 
 
49
 
int test_inner(void)
50
 
{
51
 
    pj_caching_pool caching_pool;
52
 
    const char *filename;
53
 
    int line;
54
 
    int rc = 0;
55
 
 
56
 
    mem = &caching_pool.factory;
57
 
 
58
 
    pj_log_set_level(3);
59
 
    pj_log_set_decor(param_log_decor);
60
 
 
61
 
    rc = pj_init();
62
 
    if (rc != 0) {
63
 
        app_perror("pj_init() error!!", rc);
64
 
        return rc;
65
 
    }
66
 
 
67
 
    //pj_dump_config();
68
 
    pj_caching_pool_init( &caching_pool, NULL, 0 );
69
 
 
70
 
#if INCLUDE_ERRNO_TEST
71
 
    DO_TEST( errno_test() );
72
 
#endif
73
 
 
74
 
#if INCLUDE_EXCEPTION_TEST
75
 
    DO_TEST( exception_test() );
76
 
#endif
77
 
 
78
 
#if INCLUDE_OS_TEST
79
 
    DO_TEST( os_test() );
80
 
#endif
81
 
 
82
 
#if INCLUDE_RAND_TEST
83
 
    DO_TEST( rand_test() );
84
 
#endif
85
 
 
86
 
#if INCLUDE_LIST_TEST
87
 
    DO_TEST( list_test() );
88
 
#endif
89
 
 
90
 
#if INCLUDE_POOL_TEST
91
 
    DO_TEST( pool_test() );
92
 
#endif
93
 
 
94
 
#if INCLUDE_POOL_PERF_TEST
95
 
    DO_TEST( pool_perf_test() );
96
 
#endif
97
 
 
98
 
#if INCLUDE_STRING_TEST
99
 
    DO_TEST( string_test() );
100
 
#endif
101
 
 
102
 
#if INCLUDE_FIFOBUF_TEST
103
 
    DO_TEST( fifobuf_test() );
104
 
#endif
105
 
 
106
 
#if INCLUDE_RBTREE_TEST
107
 
    DO_TEST( rbtree_test() );
108
 
#endif
109
 
 
110
 
#if INCLUDE_HASH_TEST
111
 
    DO_TEST( hash_test() );
112
 
#endif
113
 
 
114
 
#if INCLUDE_TIMESTAMP_TEST
115
 
    DO_TEST( timestamp_test() );
116
 
#endif
117
 
 
118
 
#if INCLUDE_ATOMIC_TEST
119
 
    DO_TEST( atomic_test() );
120
 
#endif
121
 
 
122
 
#if INCLUDE_MUTEX_TEST
123
 
    DO_TEST( mutex_test() );
124
 
#endif
125
 
 
126
 
#if INCLUDE_TIMER_TEST
127
 
    DO_TEST( timer_test() );
128
 
#endif
129
 
 
130
 
#if INCLUDE_SLEEP_TEST
131
 
    DO_TEST( sleep_test() );
132
 
#endif
133
 
 
134
 
#if INCLUDE_THREAD_TEST
135
 
    DO_TEST( thread_test() );
136
 
#endif
137
 
 
138
 
#if INCLUDE_SOCK_TEST
139
 
    DO_TEST( sock_test() );
140
 
#endif
141
 
 
142
 
#if INCLUDE_SOCK_PERF_TEST
143
 
    DO_TEST( sock_perf_test() );
144
 
#endif
145
 
 
146
 
#if INCLUDE_SELECT_TEST
147
 
    DO_TEST( select_test() );
148
 
#endif
149
 
 
150
 
#if INCLUDE_UDP_IOQUEUE_TEST
151
 
    DO_TEST( udp_ioqueue_test() );
152
 
#endif
153
 
 
154
 
#if PJ_HAS_TCP && INCLUDE_TCP_IOQUEUE_TEST
155
 
    DO_TEST( tcp_ioqueue_test() );
156
 
#endif
157
 
 
158
 
#if INCLUDE_IOQUEUE_PERF_TEST
159
 
    DO_TEST( ioqueue_perf_test() );
160
 
#endif
161
 
 
162
 
#if INCLUDE_IOQUEUE_UNREG_TEST
163
 
    DO_TEST( udp_ioqueue_unreg_test() );
164
 
#endif
165
 
 
166
 
#if INCLUDE_ACTIVESOCK_TEST
167
 
    DO_TEST( activesock_test() );
168
 
#endif
169
 
 
170
 
#if INCLUDE_FILE_TEST
171
 
    DO_TEST( file_test() );
172
 
#endif
173
 
 
174
 
#if INCLUDE_SSLSOCK_TEST
175
 
    DO_TEST( ssl_sock_test() );
176
 
#endif
177
 
 
178
 
#if INCLUDE_ECHO_SERVER
179
 
    //echo_server();
180
 
    //echo_srv_sync();
181
 
    udp_echo_srv_ioqueue();
182
 
 
183
 
#elif INCLUDE_ECHO_CLIENT
184
 
    if (param_echo_sock_type == 0)
185
 
        param_echo_sock_type = pj_SOCK_DGRAM();
186
 
 
187
 
    echo_client( param_echo_sock_type,
188
 
                 param_echo_server,
189
 
                 param_echo_port);
190
 
#endif
191
 
 
192
 
    goto on_return;
193
 
 
194
 
on_return:
195
 
 
196
 
    pj_caching_pool_destroy( &caching_pool );
197
 
 
198
 
    PJ_LOG(3,("test", ""));
199
 
 
200
 
    pj_thread_get_stack_info(pj_thread_this(), &filename, &line);
201
 
    PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u",
202
 
                      pj_thread_get_stack_max_usage(pj_thread_this()),
203
 
                      filename, line));
204
 
    if (rc == 0)
205
 
        PJ_LOG(3,("test", "Looks like everything is okay!.."));
206
 
    else
207
 
        PJ_LOG(3,("test", "Test completed with error(s)"));
208
 
 
209
 
    pj_shutdown();
210
 
 
211
 
    return 0;
212
 
}
213
 
 
214
 
#include <pj/sock.h>
215
 
 
216
 
int test_main(void)
217
 
{
218
 
    int i;
219
 
    PJ_USE_EXCEPTION;
220
 
 
221
 
    i = pj_AF_INET();
222
 
 
223
 
    PJ_TRY {
224
 
        return test_inner();
225
 
    }
226
 
    PJ_CATCH_ANY {
227
 
        int id = PJ_GET_EXCEPTION();
228
 
        PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)",
229
 
                  id, pj_exception_id_name(id)));
230
 
    }
231
 
    PJ_END;
232
 
 
233
 
    return -1;
234
 
}