Debian Codegraph @

Xpjproject/pjmedia/src/test/test.c

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 "test.h"
20
21 #define THIS_FILE "test.c"
22
23 pj_pool_factory *mem;
24 struct test_app_t test_app;
25
26
27 void app_perror(pj_status_t status, const char *msg)
28 {
29 char errbuf[PJ_ERR_MSG_SIZE];
30
31 pjmedia_strerror(status, errbuf, sizeof(errbuf));
32
33 PJ_LOG(3,(THIS_FILE, "%s: %s", msg, errbuf));
34 }
35
36 /* Force linking PLC stuff if G.711 is disabled. See:
37 * https://github.com/pjsip/pjproject/issues/1337
38 */
39 #if PJMEDIA_HAS_G711_CODEC==0
40 void *dummy()
41 {
42 // Dummy
43 return &pjmedia_plc_save;
44 }
45 #endif
46
47 int test_main(int argc, char *argv[])
48 {
49 int rc = 0;
50 pj_caching_pool caching_pool;
51 pj_pool_t *pool = NULL;
52
53 PJ_TEST_SUCCESS(pj_init(), NULL, return 1);
54
55 if (test_app.ut_app.prm_config)
56 pj_dump_config();
57
58 pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
59 PJ_TEST_NOT_NULL(pool=pj_pool_create(&caching_pool.factory, "test",
60 1000, 512, NULL),
61 NULL, {rc=10; goto on_return;});
62
63 pj_log_set_decor(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
64 PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_INDENT);
65 pj_log_set_level(3);
66
67 mem = &caching_pool.factory;
68
69 PJ_TEST_SUCCESS(pjmedia_event_mgr_create(pool, 0, NULL),
70 NULL, {rc=30; goto on_return;});
71
72 #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
73 PJ_TEST_SUCCESS(pjmedia_video_format_mgr_create(pool, 64, 0, NULL),
74 NULL, {rc=50; goto on_return;});
75 PJ_TEST_SUCCESS(pjmedia_converter_mgr_create(pool, NULL),
76 NULL, {rc=60; goto on_return;});
77 PJ_TEST_SUCCESS(pjmedia_vid_codec_mgr_create(pool, NULL),
78 NULL, {rc=70; goto on_return;});
79 #endif
80
81 PJ_TEST_SUCCESS(ut_app_init1(&test_app.ut_app, mem),
82 NULL, {rc=40; goto on_return;});
83
84 #if HAS_MIPS_TEST
85 /* Run in exclusive mode to get the best performance */
86 UT_ADD_TEST(&test_app.ut_app, mips_test, PJ_TEST_EXCLUSIVE);
87 #endif
88
89 #if HAS_VID_CODEC_TEST
90 /* Run in exclusive mode due to device sharing error? */
91 UT_ADD_TEST(&test_app.ut_app, vid_codec_test, PJ_TEST_EXCLUSIVE);
92 #endif
93
94 #if HAS_VID_PORT_TEST
95 UT_ADD_TEST(&test_app.ut_app, vid_port_test, 0);
96 #endif
97
98 #if HAS_VID_DEV_TEST
99 UT_ADD_TEST(&test_app.ut_app, vid_dev_test, 0);
100 #endif
101
102 #if HAS_SDP_NEG_TEST
103 UT_ADD_TEST(&test_app.ut_app, sdp_neg_test, 0);
104 #endif
105 //DO_TEST(sdp_test (&caching_pool.factory));
106 //DO_TEST(rtp_test(&caching_pool.factory));
107 //DO_TEST(session_test (&caching_pool.factory));
108 #if HAS_JBUF_TEST
109 UT_ADD_TEST(&test_app.ut_app, jbuf_test, 0);
110 #endif
111 #if HAS_CODEC_VECTOR_TEST
112 /* Run in exclusive mode: creates/destroys a local pjmedia_endpt which
113 * sets/clears the global def_codec_mgr. If sdp_neg_test runs
114 * concurrently, it may access the codec manager mutex after it has
115 * been destroyed, causing an assertion failure.
116 */
117 UT_ADD_TEST(&test_app.ut_app, codec_test_vectors, PJ_TEST_EXCLUSIVE);
118 #endif
119
120 if (ut_run_tests(&test_app.ut_app, "pjmedia tests", argc, argv)) {
121 rc = 99;
122 } else {
123 rc = 0;
124 }
125
126 ut_app_destroy(&test_app.ut_app);
127
128 on_return:
129 if (rc != 0) {
130 PJ_LOG(3,(THIS_FILE,"Test completed with error(s)!"));
131 } else {
132 PJ_LOG(3,(THIS_FILE,"Looks like everything is okay!"));
133 }
134
135 #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
136 pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance());
137 pjmedia_converter_mgr_destroy(pjmedia_converter_mgr_instance());
138 pjmedia_vid_codec_mgr_destroy(pjmedia_vid_codec_mgr_instance());
139 #endif
140
141 pjmedia_event_mgr_destroy(pjmedia_event_mgr_instance());
142 if (pool)
143 pj_pool_release(pool);
144 pj_caching_pool_destroy(&caching_pool);
145
146 return rc;
147 }