blob: 41503d76e1add6cfd1dd36c18b709bd914e2cb04 [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $Id$ */
2/*
Benny Prijono32177c02008-06-20 22:44:47 +00003 * Copyright (C)2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono5dcb38d2005-11-21 01:55:47 +00004 *
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#ifndef __PJLIB_TEST_H__
20#define __PJLIB_TEST_H__
21
22#include <pj/types.h>
23
Benny Prijonoaeeb1d12007-05-01 10:42:22 +000024#define GROUP_LIBC 1
25#define GROUP_OS 1
26#define GROUP_DATA_STRUCTURE 1
Benny Prijono63ab3562006-07-08 19:46:43 +000027#define GROUP_NETWORK 1
Benny Prijonof260e462007-04-30 21:03:32 +000028#if defined(PJ_SYMBIAN)
29# define GROUP_FILE 0
30#else
31# define GROUP_FILE 1
32#endif
Benny Prijono5dcb38d2005-11-21 01:55:47 +000033
Benny Prijonoaeeb1d12007-05-01 10:42:22 +000034#define INCLUDE_ERRNO_TEST GROUP_LIBC
Benny Prijono5dcb38d2005-11-21 01:55:47 +000035#define INCLUDE_TIMESTAMP_TEST GROUP_OS
36#define INCLUDE_EXCEPTION_TEST GROUP_LIBC
37#define INCLUDE_RAND_TEST GROUP_LIBC
38#define INCLUDE_LIST_TEST GROUP_DATA_STRUCTURE
Benny Prijonof1370372008-07-14 16:58:11 +000039#define INCLUDE_HASH_TEST GROUP_DATA_STRUCTURE
Benny Prijono5dcb38d2005-11-21 01:55:47 +000040#define INCLUDE_POOL_TEST GROUP_LIBC
Benny Prijonoaeeb1d12007-05-01 10:42:22 +000041#define INCLUDE_POOL_PERF_TEST GROUP_LIBC
Benny Prijono5dcb38d2005-11-21 01:55:47 +000042#define INCLUDE_STRING_TEST GROUP_DATA_STRUCTURE
43#define INCLUDE_FIFOBUF_TEST 0 // GROUP_DATA_STRUCTURE
44#define INCLUDE_RBTREE_TEST GROUP_DATA_STRUCTURE
45#define INCLUDE_TIMER_TEST GROUP_DATA_STRUCTURE
46#define INCLUDE_ATOMIC_TEST GROUP_OS
Benny Prijonof260e462007-04-30 21:03:32 +000047#define INCLUDE_MUTEX_TEST (PJ_HAS_THREADS && GROUP_OS)
Benny Prijono5dcb38d2005-11-21 01:55:47 +000048#define INCLUDE_SLEEP_TEST GROUP_OS
Benny Prijonof260e462007-04-30 21:03:32 +000049#define INCLUDE_THREAD_TEST (PJ_HAS_THREADS && GROUP_OS)
Benny Prijono5dcb38d2005-11-21 01:55:47 +000050#define INCLUDE_SOCK_TEST GROUP_NETWORK
Benny Prijonoaeeb1d12007-05-01 10:42:22 +000051#define INCLUDE_SOCK_PERF_TEST GROUP_NETWORK
Benny Prijono5dcb38d2005-11-21 01:55:47 +000052#define INCLUDE_SELECT_TEST GROUP_NETWORK
Benny Prijono63ab3562006-07-08 19:46:43 +000053#define INCLUDE_UDP_IOQUEUE_TEST GROUP_NETWORK
Benny Prijono5dcb38d2005-11-21 01:55:47 +000054#define INCLUDE_TCP_IOQUEUE_TEST GROUP_NETWORK
Benny Prijono4bac2c12008-05-11 18:12:16 +000055#define INCLUDE_ACTIVESOCK_TEST GROUP_NETWORK
Benny Prijonof260e462007-04-30 21:03:32 +000056#define INCLUDE_IOQUEUE_PERF_TEST (PJ_HAS_THREADS && GROUP_NETWORK)
57#define INCLUDE_IOQUEUE_UNREG_TEST (PJ_HAS_THREADS && GROUP_NETWORK)
Benny Prijono5dcb38d2005-11-21 01:55:47 +000058#define INCLUDE_FILE_TEST GROUP_FILE
59
60#define INCLUDE_ECHO_SERVER 0
61#define INCLUDE_ECHO_CLIENT 0
62
63
64#define ECHO_SERVER_MAX_THREADS 2
65#define ECHO_SERVER_START_PORT 65000
66#define ECHO_SERVER_ADDRESS "compaq.home"
67#define ECHO_SERVER_DURATION_MSEC (60*60*1000)
68
69#define ECHO_CLIENT_MAX_THREADS 6
70
71PJ_BEGIN_DECL
72
73extern int errno_test(void);
74extern int timestamp_test(void);
75extern int exception_test(void);
76extern int rand_test(void);
77extern int list_test(void);
Benny Prijonof1370372008-07-14 16:58:11 +000078extern int hash_test(void);
Benny Prijono5dcb38d2005-11-21 01:55:47 +000079extern int pool_test(void);
80extern int pool_perf_test(void);
81extern int string_test(void);
82extern int fifobuf_test(void);
83extern int timer_test(void);
84extern int rbtree_test(void);
85extern int atomic_test(void);
86extern int mutex_test(void);
87extern int sleep_test(void);
88extern int thread_test(void);
89extern int sock_test(void);
90extern int sock_perf_test(void);
91extern int select_test(void);
92extern int udp_ioqueue_test(void);
Benny Prijono5accbd02006-03-30 16:32:18 +000093extern int udp_ioqueue_unreg_test(void);
Benny Prijono5dcb38d2005-11-21 01:55:47 +000094extern int tcp_ioqueue_test(void);
95extern int ioqueue_perf_test(void);
Benny Prijono4bac2c12008-05-11 18:12:16 +000096extern int activesock_test(void);
Benny Prijono5dcb38d2005-11-21 01:55:47 +000097extern int file_test(void);
98
99extern int echo_server(void);
100extern int echo_client(int sock_type, const char *server, int port);
101
102extern int echo_srv_sync(void);
103extern int udp_echo_srv_ioqueue(void);
104extern int echo_srv_common_loop(pj_atomic_t *bytes_counter);
105
106extern pj_pool_factory *mem;
107
108extern int test_main(void);
109extern void app_perror(const char *msg, pj_status_t err);
110extern pj_status_t app_socket(int family, int type, int proto, int port,
111 pj_sock_t *ptr_sock);
112extern pj_status_t app_socketpair(int family, int type, int protocol,
113 pj_sock_t *server, pj_sock_t *client);
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000114extern int null_func(void);
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000115
116//#define TRACE_(expr) PJ_LOG(3,expr)
117#define TRACE_(expr)
Benny Prijono42c5b9e2006-05-10 19:24:40 +0000118#define HALT(msg) { PJ_LOG(3,(THIS_FILE,"%s halted",msg)); for(;;) sleep(1); }
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000119
120PJ_END_DECL
121
122#endif /* __PJLIB_TEST_H__ */
123