blob: 6d5b0222adace6801b8b4b5a07393eca79556d8d [file] [log] [blame]
Benny Prijono4ea0bf12006-02-02 19:16:07 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono4ea0bf12006-02-02 19:16:07 +00005 *
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
22#define THIS_FILE "test.c"
23
24#define DO_TEST(test) do { \
25 PJ_LOG(3, (THIS_FILE, "Running %s...", #test)); \
26 rc = test; \
27 PJ_LOG(3, (THIS_FILE, \
28 "%s(%d)", \
29 (rc ? "..ERROR" : "..success"), rc)); \
30 if (rc!=0) goto on_return; \
31 } while (0)
32
33
34pj_pool_factory *mem;
35
36
37void app_perror(pj_status_t status, const char *msg)
38{
Benny Prijonocf5c06d2008-03-26 16:18:17 +000039 char errbuf[PJ_ERR_MSG_SIZE];
Benny Prijono4ea0bf12006-02-02 19:16:07 +000040
41 pjmedia_strerror(status, errbuf, sizeof(errbuf));
42
43 PJ_LOG(3,(THIS_FILE, "%s: %s", msg, errbuf));
44}
45
46int test_main(void)
47{
Benny Prijonocf5c06d2008-03-26 16:18:17 +000048 int rc = 0;
Benny Prijono4ea0bf12006-02-02 19:16:07 +000049 pj_caching_pool caching_pool;
Sauw Ming6e6c2152010-12-14 13:03:10 +000050 pj_pool_t *pool;
Benny Prijono4ea0bf12006-02-02 19:16:07 +000051
52 pj_init();
53 pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
Sauw Ming6e6c2152010-12-14 13:03:10 +000054 pool = pj_pool_create(&caching_pool.factory, "test", 1000, 512, NULL);
55
Benny Prijono4ea0bf12006-02-02 19:16:07 +000056 pj_log_set_decor(PJ_LOG_HAS_NEWLINE);
Benny Prijono0ff56dc2008-07-04 16:45:17 +000057 pj_log_set_level(3);
Benny Prijono4ea0bf12006-02-02 19:16:07 +000058
59 mem = &caching_pool.factory;
60
Sauw Ming6e6c2152010-12-14 13:03:10 +000061 pjmedia_video_format_mgr_create(pool, 64, 0, NULL);
62 pjmedia_converter_mgr_create(pool, NULL);
63 pjmedia_vid_codec_mgr_create(pool, NULL);
64
Benny Prijonoc45d9512010-12-10 11:04:30 +000065#if HAS_VID_DEV_TEST
66 DO_TEST(vid_dev_test());
67#endif
68
69#if HAS_VID_CODEC_TEST
70 DO_TEST(vid_codec_test());
71#endif
72
Benny Prijono41a14512009-08-15 10:05:36 +000073#if HAS_SDP_NEG_TEST
Benny Prijono1dc0da72009-04-18 00:12:13 +000074 DO_TEST(sdp_neg_test());
Benny Prijono41a14512009-08-15 10:05:36 +000075#endif
Benny Prijono1dc0da72009-04-18 00:12:13 +000076 //DO_TEST(sdp_test (&caching_pool.factory));
77 //DO_TEST(rtp_test(&caching_pool.factory));
78 //DO_TEST(session_test (&caching_pool.factory));
Benny Prijono41a14512009-08-15 10:05:36 +000079#if HAS_JBUF_TEST
Nanang Izzuddinad4bb0a2009-04-06 17:13:33 +000080 DO_TEST(jbuf_main());
Benny Prijono41a14512009-08-15 10:05:36 +000081#endif
82#if HAS_MIPS_TEST
Benny Prijono1dc0da72009-04-18 00:12:13 +000083 DO_TEST(mips_test());
Benny Prijono41a14512009-08-15 10:05:36 +000084#endif
85#if HAS_CODEC_VECTOR_TEST
Benny Prijono1dc0da72009-04-18 00:12:13 +000086 DO_TEST(codec_test_vectors());
Benny Prijono41a14512009-08-15 10:05:36 +000087#endif
Benny Prijono4ea0bf12006-02-02 19:16:07 +000088
89 PJ_LOG(3,(THIS_FILE," "));
90
Nanang Izzuddinad4bb0a2009-04-06 17:13:33 +000091on_return:
Benny Prijono4ea0bf12006-02-02 19:16:07 +000092 if (rc != 0) {
93 PJ_LOG(3,(THIS_FILE,"Test completed with error(s)!"));
94 } else {
95 PJ_LOG(3,(THIS_FILE,"Looks like everything is okay!"));
96 }
97
Sauw Ming6e6c2152010-12-14 13:03:10 +000098 pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance());
99 pjmedia_converter_mgr_destroy(pjmedia_converter_mgr_instance());
100 pjmedia_vid_codec_mgr_destroy(pjmedia_vid_codec_mgr_instance());
101
102 pj_pool_release(pool);
Benny Prijono4ea0bf12006-02-02 19:16:07 +0000103 pj_caching_pool_destroy(&caching_pool);
Nanang Izzuddinad4bb0a2009-04-06 17:13:33 +0000104
Benny Prijono4ea0bf12006-02-02 19:16:07 +0000105 return rc;
106}