Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> |
| 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 | |
| 20 | |
| 21 | #include "test.h" |
| 22 | #include <pjlib.h> |
| 23 | #include <pjsip_core.h> |
| 24 | |
| 25 | #define DO_TEST(test) do { \ |
| 26 | PJ_LOG(3, ("test", "Running %s...", #test)); \ |
| 27 | rc = test; \ |
| 28 | PJ_LOG(3, ("test", \ |
| 29 | "%s(%d)", \ |
| 30 | (rc ? "..ERROR" : "..success"), rc)); \ |
| 31 | if (rc!=0) goto on_return; \ |
| 32 | } while (0) |
| 33 | |
| 34 | |
| 35 | |
| 36 | pjsip_endpoint *endpt; |
| 37 | |
| 38 | void app_perror(const char *msg, pj_status_t rc) |
| 39 | { |
| 40 | char errbuf[256]; |
| 41 | |
| 42 | PJ_CHECK_STACK(); |
| 43 | |
| 44 | pjsip_strerror(rc, errbuf, sizeof(errbuf)); |
Benny Prijono | 3818c93 | 2005-11-22 01:06:33 +0000 | [diff] [blame] | 45 | PJ_LOG(3,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf)); |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 46 | |
| 47 | } |
| 48 | |
| 49 | pj_status_t register_static_modules(pj_size_t *count, pjsip_module **modules) |
| 50 | { |
| 51 | *count = 0; |
| 52 | return PJ_SUCCESS; |
| 53 | } |
| 54 | |
| 55 | int test_main(void) |
| 56 | { |
| 57 | pj_status_t rc; |
| 58 | pj_caching_pool caching_pool; |
| 59 | const char *filename; |
| 60 | int line; |
| 61 | |
| 62 | pj_log_set_level(3); |
| 63 | pj_log_set_decor(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME | |
| 64 | PJ_LOG_HAS_MICRO_SEC); |
| 65 | |
| 66 | if ((rc=pj_init()) != PJ_SUCCESS) { |
| 67 | app_perror("pj_init", rc); |
| 68 | return rc; |
| 69 | } |
| 70 | |
| 71 | pj_dump_config(); |
| 72 | |
| 73 | pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 ); |
| 74 | |
| 75 | rc = pjsip_endpt_create(&caching_pool.factory, "endpt", &endpt); |
| 76 | if (rc != PJ_SUCCESS) { |
| 77 | app_perror("pjsip_endpt_create", rc); |
| 78 | pj_caching_pool_destroy(&caching_pool); |
| 79 | return rc; |
| 80 | } |
| 81 | |
| 82 | PJ_LOG(3,("","")); |
| 83 | |
Benny Prijono | fa73e3e | 2006-01-05 23:35:46 +0000 | [diff] [blame^] | 84 | //DO_TEST(uri_test()); |
| 85 | //DO_TEST(msg_test()); |
| 86 | //DO_TEST(txdata_test()); |
| 87 | //DO_TEST(transport_udp_test()); |
| 88 | DO_TEST(transport_loop_test()); |
| 89 | //DO_TEST(tsx_uac_test()); |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 90 | |
| 91 | on_return: |
| 92 | |
| 93 | pjsip_endpt_destroy(endpt); |
| 94 | pj_caching_pool_destroy(&caching_pool); |
| 95 | |
| 96 | PJ_LOG(3,("test", "")); |
| 97 | |
| 98 | pj_thread_get_stack_info(pj_thread_this(), &filename, &line); |
| 99 | PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u", |
| 100 | pj_thread_get_stack_max_usage(pj_thread_this()), |
| 101 | filename, line)); |
| 102 | if (rc == 0) |
| 103 | PJ_LOG(3,("test", "Looks like everything is okay!..")); |
| 104 | else |
| 105 | PJ_LOG(3,("test", "Test completed with error(s)")); |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |