Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* $Id: test.h 4420 2013-03-05 11:59:54Z bennylp $ */ |
| 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 | #ifndef __TEST_H__ |
| 21 | #define __TEST_H__ |
| 22 | |
| 23 | #include <pjsip/sip_types.h> |
| 24 | |
| 25 | extern pjsip_endpoint *endpt; |
| 26 | extern pj_caching_pool caching_pool; |
| 27 | |
| 28 | #define TEST_UDP_PORT 15060 |
| 29 | #define TEST_UDP_PORT_STR "15060" |
| 30 | |
| 31 | /** |
| 32 | * Memory size to use in caching pool. |
| 33 | * Default: 2MB |
| 34 | */ |
| 35 | #ifndef PJSIP_TEST_MEM_SIZE |
| 36 | # define PJSIP_TEST_MEM_SIZE (2*1024*1024) |
| 37 | #endif |
| 38 | |
| 39 | |
| 40 | |
| 41 | #define INCLUDE_MESSAGING_GROUP 1 |
| 42 | #define INCLUDE_TRANSPORT_GROUP 1 |
| 43 | #define INCLUDE_TSX_GROUP 1 |
| 44 | #define INCLUDE_INV_GROUP 1 |
| 45 | #define INCLUDE_REGC_GROUP 1 |
| 46 | |
| 47 | #define INCLUDE_BENCHMARKS 1 |
| 48 | |
| 49 | /* |
| 50 | * Include tests that normally would fail under certain gcc |
| 51 | * optimization levels. |
| 52 | */ |
| 53 | #ifndef INCLUDE_GCC_TEST |
| 54 | # define INCLUDE_GCC_TEST 0 |
| 55 | #endif |
| 56 | |
| 57 | |
| 58 | #define INCLUDE_URI_TEST INCLUDE_MESSAGING_GROUP |
| 59 | #define INCLUDE_MSG_TEST INCLUDE_MESSAGING_GROUP |
| 60 | #define INCLUDE_MULTIPART_TEST INCLUDE_MESSAGING_GROUP |
| 61 | #define INCLUDE_TXDATA_TEST INCLUDE_MESSAGING_GROUP |
| 62 | #define INCLUDE_TSX_BENCH INCLUDE_MESSAGING_GROUP |
| 63 | #define INCLUDE_UDP_TEST INCLUDE_TRANSPORT_GROUP |
| 64 | #define INCLUDE_LOOP_TEST INCLUDE_TRANSPORT_GROUP |
| 65 | #define INCLUDE_TCP_TEST INCLUDE_TRANSPORT_GROUP |
| 66 | #define INCLUDE_RESOLVE_TEST INCLUDE_TRANSPORT_GROUP |
| 67 | #define INCLUDE_TSX_TEST INCLUDE_TSX_GROUP |
| 68 | #define INCLUDE_TSX_DESTROY_TEST INCLUDE_TSX_GROUP |
| 69 | #define INCLUDE_INV_OA_TEST INCLUDE_INV_GROUP |
| 70 | #define INCLUDE_REGC_TEST INCLUDE_REGC_GROUP |
| 71 | |
| 72 | |
| 73 | /* The tests */ |
| 74 | int uri_test(void); |
| 75 | int msg_test(void); |
| 76 | int msg_err_test(void); |
| 77 | int multipart_test(void); |
| 78 | int txdata_test(void); |
| 79 | int tsx_bench(void); |
| 80 | int tsx_destroy_test(void); |
| 81 | int transport_udp_test(void); |
| 82 | int transport_loop_test(void); |
| 83 | int transport_tcp_test(void); |
| 84 | int resolve_test(void); |
| 85 | int regc_test(void); |
| 86 | |
| 87 | struct tsx_test_param |
| 88 | { |
| 89 | int type; |
| 90 | int port; |
| 91 | char *tp_type; |
| 92 | }; |
| 93 | |
| 94 | int tsx_basic_test(struct tsx_test_param *param); |
| 95 | int tsx_uac_test(struct tsx_test_param *param); |
| 96 | int tsx_uas_test(struct tsx_test_param *param); |
| 97 | |
| 98 | /* Transport test helpers (transport_test.c). */ |
| 99 | int generic_transport_test(pjsip_transport *tp); |
| 100 | int transport_send_recv_test( pjsip_transport_type_e tp_type, |
| 101 | pjsip_transport *ref_tp, |
| 102 | char *target_url, |
| 103 | int *p_usec_rtt); |
| 104 | int transport_rt_test( pjsip_transport_type_e tp_type, |
| 105 | pjsip_transport *ref_tp, |
| 106 | char *target_url, |
| 107 | int *pkt_lost); |
| 108 | int transport_load_test(char *target_url); |
| 109 | |
| 110 | /* Invite session */ |
| 111 | int inv_offer_answer_test(void); |
| 112 | |
| 113 | /* Test main entry */ |
| 114 | int test_main(void); |
| 115 | |
| 116 | /* Test utilities. */ |
| 117 | void app_perror(const char *msg, pj_status_t status); |
| 118 | int init_msg_logger(void); |
| 119 | int msg_logger_set_enabled(pj_bool_t enabled); |
| 120 | void flush_events(unsigned duration); |
| 121 | |
| 122 | |
| 123 | void report_ival(const char *name, int value, const char *valname, const char *desc); |
| 124 | void report_sval(const char *name, const char* value, const char *valname, const char *desc); |
| 125 | |
| 126 | |
| 127 | /* Settings. */ |
| 128 | extern int log_level; |
| 129 | |
| 130 | #endif /* __TEST_H__ */ |