Skip to content

Commit

Permalink
Add more IOCP tests. They might not pass yet.
Browse files Browse the repository at this point in the history
svn:r1487
  • Loading branch information
nmathewson committed Nov 2, 2009
1 parent 5d2c165 commit 5f1d6e6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/regress.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions test/regress_bufferevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
4 changes: 4 additions & 0 deletions test/regress_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
17 changes: 16 additions & 1 deletion test/regress_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5f1d6e6

Please sign in to comment.