Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 844653c | 2008-12-23 17:27:53 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) |
Benny Prijono | 32177c0 | 2008-06-20 22:44:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 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 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 22 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 23 | # include <CoreFoundation/CFRunLoop.h> |
| 24 | #endif |
| 25 | |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 26 | #define THIS_FILE "test.c" |
| 27 | |
| 28 | #define DO_TEST(test) do { \ |
| 29 | PJ_LOG(3, (THIS_FILE, "Running %s...", #test)); \ |
| 30 | rc = test; \ |
| 31 | PJ_LOG(3, (THIS_FILE, \ |
| 32 | "%s(%d)", \ |
| 33 | (rc ? "..ERROR" : "..success"), rc)); \ |
| 34 | if (rc!=0) goto on_return; \ |
| 35 | } while (0) |
| 36 | |
| 37 | |
| 38 | pj_pool_factory *mem; |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 39 | pj_bool_t is_quit = PJ_FALSE; |
| 40 | pj_thread_t *thread; |
| 41 | pj_caching_pool caching_pool; |
| 42 | pj_pool_t *pool; |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 43 | |
| 44 | void app_perror(pj_status_t status, const char *msg) |
| 45 | { |
Benny Prijono | cf5c06d | 2008-03-26 16:18:17 +0000 | [diff] [blame] | 46 | char errbuf[PJ_ERR_MSG_SIZE]; |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 47 | |
| 48 | pjmedia_strerror(status, errbuf, sizeof(errbuf)); |
| 49 | |
| 50 | PJ_LOG(3,(THIS_FILE, "%s: %s", msg, errbuf)); |
| 51 | } |
| 52 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 53 | static int test_func(void *data) |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 54 | { |
Benny Prijono | cf5c06d | 2008-03-26 16:18:17 +0000 | [diff] [blame] | 55 | int rc = 0; |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 56 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 57 | #if HAS_VID_DEV_TEST |
| 58 | DO_TEST(vid_dev_test()); |
| 59 | #endif |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 60 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 61 | #if HAS_VID_CODEC_TEST |
| 62 | DO_TEST(vid_codec_test()); |
| 63 | #endif |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 64 | |
Benny Prijono | 41a1451 | 2009-08-15 10:05:36 +0000 | [diff] [blame] | 65 | #if HAS_SDP_NEG_TEST |
Benny Prijono | 1dc0da7 | 2009-04-18 00:12:13 +0000 | [diff] [blame] | 66 | DO_TEST(sdp_neg_test()); |
Benny Prijono | 41a1451 | 2009-08-15 10:05:36 +0000 | [diff] [blame] | 67 | #endif |
Benny Prijono | 1dc0da7 | 2009-04-18 00:12:13 +0000 | [diff] [blame] | 68 | //DO_TEST(sdp_test (&caching_pool.factory)); |
| 69 | //DO_TEST(rtp_test(&caching_pool.factory)); |
| 70 | //DO_TEST(session_test (&caching_pool.factory)); |
Benny Prijono | 41a1451 | 2009-08-15 10:05:36 +0000 | [diff] [blame] | 71 | #if HAS_JBUF_TEST |
Nanang Izzuddin | ad4bb0a | 2009-04-06 17:13:33 +0000 | [diff] [blame] | 72 | DO_TEST(jbuf_main()); |
Benny Prijono | 41a1451 | 2009-08-15 10:05:36 +0000 | [diff] [blame] | 73 | #endif |
| 74 | #if HAS_MIPS_TEST |
Benny Prijono | 1dc0da7 | 2009-04-18 00:12:13 +0000 | [diff] [blame] | 75 | DO_TEST(mips_test()); |
Benny Prijono | 41a1451 | 2009-08-15 10:05:36 +0000 | [diff] [blame] | 76 | #endif |
| 77 | #if HAS_CODEC_VECTOR_TEST |
Benny Prijono | 1dc0da7 | 2009-04-18 00:12:13 +0000 | [diff] [blame] | 78 | DO_TEST(codec_test_vectors()); |
Benny Prijono | 41a1451 | 2009-08-15 10:05:36 +0000 | [diff] [blame] | 79 | #endif |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 80 | |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 81 | PJ_LOG(3,(THIS_FILE," ")); |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 82 | |
Nanang Izzuddin | ad4bb0a | 2009-04-06 17:13:33 +0000 | [diff] [blame] | 83 | on_return: |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 84 | if (rc != 0) { |
| 85 | PJ_LOG(3,(THIS_FILE,"Test completed with error(s)!")); |
| 86 | } else { |
| 87 | PJ_LOG(3,(THIS_FILE,"Looks like everything is okay!")); |
| 88 | } |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 89 | |
| 90 | is_quit = PJ_TRUE; |
| 91 | return rc; |
| 92 | } |
| 93 | |
| 94 | int test_main(void) |
| 95 | { |
| 96 | int rc = 0; |
| 97 | |
| 98 | pj_init(); |
| 99 | pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0); |
| 100 | pool = pj_pool_create(&caching_pool.factory, "test", 1000, 512, NULL); |
| 101 | |
| 102 | pj_log_set_decor(PJ_LOG_HAS_NEWLINE); |
| 103 | pj_log_set_level(3); |
| 104 | |
| 105 | mem = &caching_pool.factory; |
| 106 | |
| 107 | pjmedia_video_format_mgr_create(pool, 64, 0, NULL); |
| 108 | pjmedia_converter_mgr_create(pool, NULL); |
| 109 | pjmedia_vid_codec_mgr_create(pool, NULL); |
| 110 | |
| 111 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 112 | { |
| 113 | if (pj_thread_create(pool, "test_func", test_func, NULL, 0, 0, |
| 114 | &thread) == PJ_SUCCESS) { |
| 115 | while (!is_quit) { |
| 116 | CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false); |
| 117 | } |
| 118 | } |
| 119 | return 0; |
| 120 | } |
| 121 | #else |
| 122 | rc = test_func(NULL); |
| 123 | #endif |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 124 | |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 125 | pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance()); |
| 126 | pjmedia_converter_mgr_destroy(pjmedia_converter_mgr_instance()); |
| 127 | pjmedia_vid_codec_mgr_destroy(pjmedia_vid_codec_mgr_instance()); |
| 128 | |
| 129 | pj_pool_release(pool); |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 130 | pj_caching_pool_destroy(&caching_pool); |
Nanang Izzuddin | ad4bb0a | 2009-04-06 17:13:33 +0000 | [diff] [blame] | 131 | |
Benny Prijono | 4ea0bf1 | 2006-02-02 19:16:07 +0000 | [diff] [blame] | 132 | return rc; |
| 133 | } |