michael@0: /* michael@0: * Copyright (c) 2000-2007 Niels Provos michael@0: * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * 1. Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * 2. Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * 3. The name of the author may not be used to endorse or promote products michael@0: * derived from this software without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR michael@0: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES michael@0: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@0: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, michael@0: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT michael@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF michael@0: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: #ifndef _REGRESS_H_ michael@0: #define _REGRESS_H_ michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: #include "tinytest.h" michael@0: #include "tinytest_macros.h" michael@0: michael@0: extern struct testcase_t main_testcases[]; michael@0: extern struct testcase_t evtag_testcases[]; michael@0: extern struct testcase_t evbuffer_testcases[]; michael@0: extern struct testcase_t bufferevent_testcases[]; michael@0: extern struct testcase_t bufferevent_iocp_testcases[]; michael@0: extern struct testcase_t util_testcases[]; michael@0: extern struct testcase_t signal_testcases[]; michael@0: extern struct testcase_t http_testcases[]; michael@0: extern struct testcase_t dns_testcases[]; michael@0: extern struct testcase_t rpc_testcases[]; michael@0: extern struct testcase_t edgetriggered_testcases[]; michael@0: extern struct testcase_t minheap_testcases[]; michael@0: extern struct testcase_t iocp_testcases[]; michael@0: extern struct testcase_t ssl_testcases[]; michael@0: extern struct testcase_t listener_testcases[]; michael@0: extern struct testcase_t listener_iocp_testcases[]; michael@0: extern struct testcase_t thread_testcases[]; michael@0: michael@0: void regress_threads(void *); michael@0: void test_bufferevent_zlib(void *); michael@0: michael@0: /* Helpers to wrap old testcases */ michael@0: extern evutil_socket_t pair[2]; michael@0: extern int test_ok; michael@0: extern int called; michael@0: extern struct event_base *global_base; michael@0: extern int in_legacy_test_wrapper; michael@0: michael@0: int regress_make_tmpfile(const void *data, size_t datalen); michael@0: michael@0: struct basic_test_data { michael@0: struct event_base *base; michael@0: evutil_socket_t pair[2]; michael@0: michael@0: void (*legacy_test_fn)(void); michael@0: michael@0: void *setup_data; michael@0: }; michael@0: extern const struct testcase_setup_t basic_setup; michael@0: michael@0: michael@0: extern const struct testcase_setup_t legacy_setup; michael@0: void run_legacy_test_fn(void *ptr); michael@0: michael@0: /* A couple of flags that basic/legacy_setup can support. */ michael@0: #define TT_NEED_SOCKETPAIR TT_FIRST_USER_FLAG michael@0: #define TT_NEED_BASE (TT_FIRST_USER_FLAG<<1) michael@0: #define TT_NEED_DNS (TT_FIRST_USER_FLAG<<2) michael@0: #define TT_LEGACY (TT_FIRST_USER_FLAG<<3) michael@0: #define TT_NEED_THREADS (TT_FIRST_USER_FLAG<<4) michael@0: #define TT_NO_LOGS (TT_FIRST_USER_FLAG<<5) michael@0: #define TT_ENABLE_IOCP_FLAG (TT_FIRST_USER_FLAG<<6) michael@0: #define TT_ENABLE_IOCP (TT_ENABLE_IOCP_FLAG|TT_NEED_THREADS) michael@0: michael@0: /* All the flags that a legacy test needs. */ michael@0: #define TT_ISOLATED TT_FORK|TT_NEED_SOCKETPAIR|TT_NEED_BASE michael@0: michael@0: michael@0: #define BASIC(name,flags) \ michael@0: { #name, test_## name, flags, &basic_setup, NULL } michael@0: michael@0: #define LEGACY(name,flags) \ michael@0: { #name, run_legacy_test_fn, flags|TT_LEGACY, &legacy_setup, \ michael@0: test_## name } michael@0: michael@0: struct evutil_addrinfo; michael@0: struct evutil_addrinfo *ai_find_by_family(struct evutil_addrinfo *ai, int f); michael@0: struct evutil_addrinfo *ai_find_by_protocol(struct evutil_addrinfo *ai, int p); michael@0: int _test_ai_eq(const struct evutil_addrinfo *ai, const char *sockaddr_port, michael@0: int socktype, int protocol, int line); michael@0: michael@0: #define test_ai_eq(ai, str, s, p) do { \ michael@0: if (_test_ai_eq((ai), (str), (s), (p), __LINE__)<0) \ michael@0: goto end; \ michael@0: } while (0) michael@0: michael@0: #define test_timeval_diff_leq(tv1, tv2, diff, tolerance) \ michael@0: tt_int_op(abs(timeval_msec_diff((tv1), (tv2)) - diff), <=, tolerance) michael@0: michael@0: #define test_timeval_diff_eq(tv1, tv2, diff) \ michael@0: test_timeval_diff_leq((tv1), (tv2), (diff), 50) michael@0: michael@0: long timeval_msec_diff(const struct timeval *start, const struct timeval *end); michael@0: michael@0: #ifndef _WIN32 michael@0: pid_t regress_fork(void); michael@0: #endif michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif /* _REGRESS_H_ */