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