1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/third_party/libevent/test/regress.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,129 @@ 1.4 +/* 1.5 + * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> 1.6 + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 1.7 + * 1.8 + * Redistribution and use in source and binary forms, with or without 1.9 + * modification, are permitted provided that the following conditions 1.10 + * are met: 1.11 + * 1. Redistributions of source code must retain the above copyright 1.12 + * notice, this list of conditions and the following disclaimer. 1.13 + * 2. Redistributions in binary form must reproduce the above copyright 1.14 + * notice, this list of conditions and the following disclaimer in the 1.15 + * documentation and/or other materials provided with the distribution. 1.16 + * 3. The name of the author may not be used to endorse or promote products 1.17 + * derived from this software without specific prior written permission. 1.18 + * 1.19 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1.20 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1.21 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.22 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1.23 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1.24 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.25 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.26 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.27 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 1.28 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.29 + */ 1.30 +#ifndef _REGRESS_H_ 1.31 +#define _REGRESS_H_ 1.32 + 1.33 +#ifdef __cplusplus 1.34 +extern "C" { 1.35 +#endif 1.36 + 1.37 +#include "tinytest.h" 1.38 +#include "tinytest_macros.h" 1.39 + 1.40 +extern struct testcase_t main_testcases[]; 1.41 +extern struct testcase_t evtag_testcases[]; 1.42 +extern struct testcase_t evbuffer_testcases[]; 1.43 +extern struct testcase_t bufferevent_testcases[]; 1.44 +extern struct testcase_t bufferevent_iocp_testcases[]; 1.45 +extern struct testcase_t util_testcases[]; 1.46 +extern struct testcase_t signal_testcases[]; 1.47 +extern struct testcase_t http_testcases[]; 1.48 +extern struct testcase_t dns_testcases[]; 1.49 +extern struct testcase_t rpc_testcases[]; 1.50 +extern struct testcase_t edgetriggered_testcases[]; 1.51 +extern struct testcase_t minheap_testcases[]; 1.52 +extern struct testcase_t iocp_testcases[]; 1.53 +extern struct testcase_t ssl_testcases[]; 1.54 +extern struct testcase_t listener_testcases[]; 1.55 +extern struct testcase_t listener_iocp_testcases[]; 1.56 +extern struct testcase_t thread_testcases[]; 1.57 + 1.58 +void regress_threads(void *); 1.59 +void test_bufferevent_zlib(void *); 1.60 + 1.61 +/* Helpers to wrap old testcases */ 1.62 +extern evutil_socket_t pair[2]; 1.63 +extern int test_ok; 1.64 +extern int called; 1.65 +extern struct event_base *global_base; 1.66 +extern int in_legacy_test_wrapper; 1.67 + 1.68 +int regress_make_tmpfile(const void *data, size_t datalen); 1.69 + 1.70 +struct basic_test_data { 1.71 + struct event_base *base; 1.72 + evutil_socket_t pair[2]; 1.73 + 1.74 + void (*legacy_test_fn)(void); 1.75 + 1.76 + void *setup_data; 1.77 +}; 1.78 +extern const struct testcase_setup_t basic_setup; 1.79 + 1.80 + 1.81 +extern const struct testcase_setup_t legacy_setup; 1.82 +void run_legacy_test_fn(void *ptr); 1.83 + 1.84 +/* A couple of flags that basic/legacy_setup can support. */ 1.85 +#define TT_NEED_SOCKETPAIR TT_FIRST_USER_FLAG 1.86 +#define TT_NEED_BASE (TT_FIRST_USER_FLAG<<1) 1.87 +#define TT_NEED_DNS (TT_FIRST_USER_FLAG<<2) 1.88 +#define TT_LEGACY (TT_FIRST_USER_FLAG<<3) 1.89 +#define TT_NEED_THREADS (TT_FIRST_USER_FLAG<<4) 1.90 +#define TT_NO_LOGS (TT_FIRST_USER_FLAG<<5) 1.91 +#define TT_ENABLE_IOCP_FLAG (TT_FIRST_USER_FLAG<<6) 1.92 +#define TT_ENABLE_IOCP (TT_ENABLE_IOCP_FLAG|TT_NEED_THREADS) 1.93 + 1.94 +/* All the flags that a legacy test needs. */ 1.95 +#define TT_ISOLATED TT_FORK|TT_NEED_SOCKETPAIR|TT_NEED_BASE 1.96 + 1.97 + 1.98 +#define BASIC(name,flags) \ 1.99 + { #name, test_## name, flags, &basic_setup, NULL } 1.100 + 1.101 +#define LEGACY(name,flags) \ 1.102 + { #name, run_legacy_test_fn, flags|TT_LEGACY, &legacy_setup, \ 1.103 + test_## name } 1.104 + 1.105 +struct evutil_addrinfo; 1.106 +struct evutil_addrinfo *ai_find_by_family(struct evutil_addrinfo *ai, int f); 1.107 +struct evutil_addrinfo *ai_find_by_protocol(struct evutil_addrinfo *ai, int p); 1.108 +int _test_ai_eq(const struct evutil_addrinfo *ai, const char *sockaddr_port, 1.109 + int socktype, int protocol, int line); 1.110 + 1.111 +#define test_ai_eq(ai, str, s, p) do { \ 1.112 + if (_test_ai_eq((ai), (str), (s), (p), __LINE__)<0) \ 1.113 + goto end; \ 1.114 + } while (0) 1.115 + 1.116 +#define test_timeval_diff_leq(tv1, tv2, diff, tolerance) \ 1.117 + tt_int_op(abs(timeval_msec_diff((tv1), (tv2)) - diff), <=, tolerance) 1.118 + 1.119 +#define test_timeval_diff_eq(tv1, tv2, diff) \ 1.120 + test_timeval_diff_leq((tv1), (tv2), (diff), 50) 1.121 + 1.122 +long timeval_msec_diff(const struct timeval *start, const struct timeval *end); 1.123 + 1.124 +#ifndef _WIN32 1.125 +pid_t regress_fork(void); 1.126 +#endif 1.127 + 1.128 +#ifdef __cplusplus 1.129 +} 1.130 +#endif 1.131 + 1.132 +#endif /* _REGRESS_H_ */