From 5f1d6e640f965d468122598b92be609a483d1923 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 2 Nov 2009 17:42:16 +0000 Subject: [PATCH] Add more IOCP tests. They might not pass yet. svn:r1487 --- test/regress.h | 2 ++ test/regress_bufferevent.c | 22 ++++++++++++++++++++++ test/regress_listener.c | 4 ++++ test/regress_main.c | 17 ++++++++++++++++- 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/test/regress.h b/test/regress.h index 92b81688..24f3aa64 100644 --- a/test/regress.h +++ b/test/regress.h @@ -38,6 +38,7 @@ extern struct testcase_t main_testcases[]; extern struct testcase_t evtag_testcases[]; extern struct testcase_t evbuffer_testcases[]; extern struct testcase_t bufferevent_testcases[]; +extern struct testcase_t bufferevent_iocp_testcases[]; extern struct testcase_t util_testcases[]; extern struct testcase_t signal_testcases[]; extern struct testcase_t http_testcases[]; @@ -82,6 +83,7 @@ void run_legacy_test_fn(void *ptr); #define TT_LEGACY (TT_FIRST_USER_FLAG<<3) #define TT_NEED_THREADS (TT_FIRST_USER_FLAG<<4) #define TT_NO_LOGS (TT_FIRST_USER_FLAG<<5) +#define TT_ENABLE_IOCP (TT_FIRST_USER_FLAG<<6) /* All the flags that a legacy test needs. */ #define TT_ISOLATED TT_FORK|TT_NEED_SOCKETPAIR|TT_NEED_BASE diff --git a/test/regress_bufferevent.c b/test/regress_bufferevent.c index 6fdff374..7658741c 100644 --- a/test/regress_bufferevent.c +++ b/test/regress_bufferevent.c @@ -609,3 +609,25 @@ struct testcase_t bufferevent_testcases[] = { END_OF_TESTCASES, }; + +struct testcase_t bufferevent_iocp_testcases[] = { + + LEGACY(bufferevent, TT_ISOLATED|TT_ENABLE_IOCP), + LEGACY(bufferevent_watermarks, TT_ISOLATED|TT_ENABLE_IOCP), + LEGACY(bufferevent_filters, TT_ISOLATED|TT_ENABLE_IOCP), +#if 0 + { "bufferevent_connect", test_bufferevent_connect, TT_FORK|TT_NEED_BASE, + &basic_setup, (void*)"" }, + { "bufferevent_connect_defer", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE, &basic_setup, (void*)"defer" }, + { "bufferevent_connect_lock", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS, &basic_setup, (void*)"lock" }, + { "bufferevent_connect_lock_defer", test_bufferevent_connect, + TT_FORK|TT_NEED_BASE|TT_NEED_THREADS, &basic_setup, + (void*)"defer lock" }, + { "bufferevent_connect_fail", test_bufferevent_connect_fail, + TT_FORK|TT_NEED_BASE, &basic_setup, NULL }, +#endif + + END_OF_TESTCASES, +}; diff --git a/test/regress_listener.c b/test/regress_listener.c index 2390bd0f..b9de0af3 100644 --- a/test/regress_listener.c +++ b/test/regress_listener.c @@ -131,5 +131,9 @@ struct testcase_t listener_testcases[] = { { "randport", regress_pick_a_port, TT_FORK|TT_NEED_BASE, &basic_setup, NULL}, + { "iocp/randport", regress_pick_a_port, + TT_FORK|TT_NEED_BASE|TT_ENABLE_IOCP, + &basic_setup, NULL}, + END_OF_TESTCASES, }; diff --git a/test/regress_main.c b/test/regress_main.c index 985fc4b8..f4d11c16 100644 --- a/test/regress_main.c +++ b/test/regress_main.c @@ -75,6 +75,8 @@ #include "regress.h" #include "tinytest.h" #include "tinytest_macros.h" +#include "../iocp-internal.h" + /* ============================================================ */ /* Code to wrap up old legacy test cases that used setup() and cleanup(). @@ -132,6 +134,11 @@ basic_test_setup(const struct testcase_t *testcase) int spair[2] = { -1, -1 }; struct basic_test_data *data = NULL; +#ifndef WIN32 + if (testcase->flags & TT_ENABLE_IOCP) + return (void*)TT_SKIP; +#endif + if (testcase->flags & TT_NEED_THREADS) { if (!(testcase->flags & TT_FORK)) return NULL; @@ -170,7 +177,12 @@ basic_test_setup(const struct testcase_t *testcase) if (!base) exit(1); } - + if (testcase->flags & TT_ENABLE_IOCP) { + if (event_base_start_iocp(base)<0) { + event_base_free(base); + return (void*)TT_SKIP; + } + } if (testcase->flags & TT_NEED_DNS) { evdns_set_log_fn(dnslogcb); @@ -232,6 +244,8 @@ static void * legacy_test_setup(const struct testcase_t *testcase) { struct basic_test_data *data = basic_test_setup(testcase); + if (data == (void*)TT_SKIP) + return data; global_base = data->base; pair[0] = data->pair[0]; pair[1] = data->pair[1]; @@ -306,6 +320,7 @@ struct testgroup_t testgroups[] = { #ifdef WIN32 { "iocp/", iocp_testcases }, #endif + { "iocp/bufferevent/", bufferevent_iocp_testcases }, #ifdef _EVENT_HAVE_OPENSSL { "ssl/", ssl_testcases }, #endif