blob: 690598b96e256ea1e0d4c0e7b9a71723f6ac5292 [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $Id$ */
2/*
Nanang Izzuddina62ffc92011-05-05 06:14:19 +00003 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono5dcb38d2005-11-21 01:55:47 +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#ifndef __TEST_H__
21#define __TEST_H__
22
23#include <pjsip/sip_types.h>
24
25extern pjsip_endpoint *endpt;
Benny Prijono74f85142013-03-05 11:59:54 +000026extern pj_caching_pool caching_pool;
Benny Prijono5dcb38d2005-11-21 01:55:47 +000027
Benny Prijonofa73e3e2006-01-05 23:35:46 +000028#define TEST_UDP_PORT 15060
29#define TEST_UDP_PORT_STR "15060"
Benny Prijono5dcb38d2005-11-21 01:55:47 +000030
Benny Prijono95c63482006-07-06 14:28:45 +000031/**
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
Benny Prijono02b8fd82006-06-26 15:12:55 +000040
Benny Prijonof4721ca2007-02-17 19:40:06 +000041#define INCLUDE_MESSAGING_GROUP 1
42#define INCLUDE_TRANSPORT_GROUP 1
43#define INCLUDE_TSX_GROUP 1
Benny Prijono1f7767b2007-10-03 18:28:49 +000044#define INCLUDE_INV_GROUP 1
Benny Prijonodd742da2008-05-17 12:45:00 +000045#define INCLUDE_REGC_GROUP 1
Benny Prijono02b8fd82006-06-26 15:12:55 +000046
Benny Prijonod0bd4982007-12-02 15:40:52 +000047#define INCLUDE_BENCHMARKS 1
48
Benny Prijonoe93e2872006-06-28 16:46:49 +000049/*
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
Benny Prijono02b8fd82006-06-26 15:12:55 +000056
57
58#define INCLUDE_URI_TEST INCLUDE_MESSAGING_GROUP
59#define INCLUDE_MSG_TEST INCLUDE_MESSAGING_GROUP
Benny Prijono1c1d7342010-08-01 09:48:51 +000060#define INCLUDE_MULTIPART_TEST INCLUDE_MESSAGING_GROUP
Benny Prijono02b8fd82006-06-26 15:12:55 +000061#define INCLUDE_TXDATA_TEST INCLUDE_MESSAGING_GROUP
Benny Prijonoe93e2872006-06-28 16:46:49 +000062#define INCLUDE_TSX_BENCH INCLUDE_MESSAGING_GROUP
Benny Prijono02b8fd82006-06-26 15:12:55 +000063#define INCLUDE_UDP_TEST INCLUDE_TRANSPORT_GROUP
64#define INCLUDE_LOOP_TEST INCLUDE_TRANSPORT_GROUP
Benny Prijonoe93e2872006-06-28 16:46:49 +000065#define INCLUDE_TCP_TEST INCLUDE_TRANSPORT_GROUP
Benny Prijonof4721ca2007-02-17 19:40:06 +000066#define INCLUDE_RESOLVE_TEST INCLUDE_TRANSPORT_GROUP
Benny Prijono02b8fd82006-06-26 15:12:55 +000067#define INCLUDE_TSX_TEST INCLUDE_TSX_GROUP
Benny Prijono74f85142013-03-05 11:59:54 +000068#define INCLUDE_TSX_DESTROY_TEST INCLUDE_TSX_GROUP
Benny Prijono1f7767b2007-10-03 18:28:49 +000069#define INCLUDE_INV_OA_TEST INCLUDE_INV_GROUP
Benny Prijonodd742da2008-05-17 12:45:00 +000070#define INCLUDE_REGC_TEST INCLUDE_REGC_GROUP
Benny Prijono02b8fd82006-06-26 15:12:55 +000071
72
Benny Prijono0ca04b62005-12-30 23:50:15 +000073/* The tests */
74int uri_test(void);
75int msg_test(void);
Benny Prijono733c67a2006-06-23 01:03:52 +000076int msg_err_test(void);
Benny Prijono1c1d7342010-08-01 09:48:51 +000077int multipart_test(void);
Benny Prijono0ca04b62005-12-30 23:50:15 +000078int txdata_test(void);
Benny Prijonoe93e2872006-06-28 16:46:49 +000079int tsx_bench(void);
Benny Prijono74f85142013-03-05 11:59:54 +000080int tsx_destroy_test(void);
Benny Prijono0ca04b62005-12-30 23:50:15 +000081int transport_udp_test(void);
Benny Prijonofa73e3e2006-01-05 23:35:46 +000082int transport_loop_test(void);
Benny Prijonoe93e2872006-06-28 16:46:49 +000083int transport_tcp_test(void);
Benny Prijonofa9e5b12006-10-08 12:39:34 +000084int resolve_test(void);
Benny Prijonodd742da2008-05-17 12:45:00 +000085int regc_test(void);
Benny Prijonoe93e2872006-06-28 16:46:49 +000086
87struct tsx_test_param
88{
89 int type;
90 int port;
91 char *tp_type;
92};
93
94int tsx_basic_test(struct tsx_test_param *param);
95int tsx_uac_test(struct tsx_test_param *param);
96int tsx_uas_test(struct tsx_test_param *param);
Benny Prijono0ca04b62005-12-30 23:50:15 +000097
98/* Transport test helpers (transport_test.c). */
99int generic_transport_test(pjsip_transport *tp);
100int transport_send_recv_test( pjsip_transport_type_e tp_type,
101 pjsip_transport *ref_tp,
Benny Prijonoe93e2872006-06-28 16:46:49 +0000102 char *target_url,
103 int *p_usec_rtt);
Benny Prijono0ca04b62005-12-30 23:50:15 +0000104int transport_rt_test( pjsip_transport_type_e tp_type,
105 pjsip_transport *ref_tp,
Benny Prijono85598d92006-01-07 18:44:25 +0000106 char *target_url,
107 int *pkt_lost);
Benny Prijono33c9db02008-08-04 14:30:33 +0000108int transport_load_test(char *target_url);
Benny Prijono0ca04b62005-12-30 23:50:15 +0000109
Benny Prijono1f7767b2007-10-03 18:28:49 +0000110/* Invite session */
111int inv_offer_answer_test(void);
112
Benny Prijono0ca04b62005-12-30 23:50:15 +0000113/* Test main entry */
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000114int test_main(void);
Benny Prijono0ca04b62005-12-30 23:50:15 +0000115
116/* Test utilities. */
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000117void app_perror(const char *msg, pj_status_t status);
Benny Prijonoe93e2872006-06-28 16:46:49 +0000118int init_msg_logger(void);
119int msg_logger_set_enabled(pj_bool_t enabled);
Benny Prijono85598d92006-01-07 18:44:25 +0000120void flush_events(unsigned duration);
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000121
Benny Prijonoe93e2872006-06-28 16:46:49 +0000122
123void report_ival(const char *name, int value, const char *valname, const char *desc);
124void report_sval(const char *name, const char* value, const char *valname, const char *desc);
125
126
Benny Prijono9c1d9f52006-01-07 23:01:56 +0000127/* Settings. */
128extern int log_level;
129
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000130#endif /* __TEST_H__ */