mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-14 06:49:35 -04:00
test/regress_ssl: cover case when server didn't up (failed with timeout)
This commit is contained in:
parent
df507afafd
commit
74845f1198
@ -178,6 +178,7 @@ static int test_is_done = 0;
|
|||||||
static int n_connected = 0;
|
static int n_connected = 0;
|
||||||
static int got_close = 0;
|
static int got_close = 0;
|
||||||
static int got_error = 0;
|
static int got_error = 0;
|
||||||
|
static int got_timeout = 0;
|
||||||
static int renegotiate_at = -1;
|
static int renegotiate_at = -1;
|
||||||
static int stop_when_connected = 0;
|
static int stop_when_connected = 0;
|
||||||
static int pending_connect_events = 0;
|
static int pending_connect_events = 0;
|
||||||
@ -196,6 +197,7 @@ enum regress_openssl_type
|
|||||||
REGRESS_OPENSSL_SERVER = 128,
|
REGRESS_OPENSSL_SERVER = 128,
|
||||||
|
|
||||||
REGRESS_OPENSSL_FREED = 256,
|
REGRESS_OPENSSL_FREED = 256,
|
||||||
|
REGRESS_OPENSSL_TIMEOUT = 512,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -311,6 +313,16 @@ eventcb(struct bufferevent *bev, short what, void *ctx)
|
|||||||
bufferevent_openssl_check_freed(bev);
|
bufferevent_openssl_check_freed(bev);
|
||||||
}
|
}
|
||||||
bufferevent_free(bev);
|
bufferevent_free(bev);
|
||||||
|
} else if (what & BEV_EVENT_TIMEOUT) {
|
||||||
|
TT_BLATHER(("Got timeout."));
|
||||||
|
++got_timeout;
|
||||||
|
if (type & REGRESS_OPENSSL_FD) {
|
||||||
|
bufferevent_openssl_check_fd(bev, type & REGRESS_OPENSSL_FILTER);
|
||||||
|
}
|
||||||
|
if (type & REGRESS_OPENSSL_FREED) {
|
||||||
|
bufferevent_openssl_check_freed(bev);
|
||||||
|
}
|
||||||
|
bufferevent_free(bev);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
;
|
;
|
||||||
@ -420,22 +432,43 @@ regress_bufferevent_openssl(void *arg)
|
|||||||
fd_pair, bev_ll, type);
|
fd_pair, bev_ll, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferevent_enable(bev1, EV_READ|EV_WRITE);
|
if (!(type & REGRESS_OPENSSL_TIMEOUT)) {
|
||||||
bufferevent_enable(bev2, EV_READ|EV_WRITE);
|
bufferevent_enable(bev1, EV_READ|EV_WRITE);
|
||||||
|
bufferevent_enable(bev2, EV_READ|EV_WRITE);
|
||||||
|
|
||||||
evbuffer_add_printf(bufferevent_get_output(bev1), "1\n");
|
evbuffer_add_printf(bufferevent_get_output(bev1), "1\n");
|
||||||
|
|
||||||
event_base_dispatch(data->base);
|
event_base_dispatch(data->base);
|
||||||
|
|
||||||
tt_assert(test_is_done == 1);
|
tt_assert(test_is_done == 1);
|
||||||
tt_assert(n_connected == 2);
|
tt_assert(n_connected == 2);
|
||||||
|
|
||||||
/* We don't handle shutdown properly yet */
|
/* We don't handle shutdown properly yet */
|
||||||
if (type & REGRESS_OPENSSL_DIRTY_SHUTDOWN) {
|
if (type & REGRESS_OPENSSL_DIRTY_SHUTDOWN) {
|
||||||
tt_int_op(got_close, ==, 1);
|
tt_int_op(got_close, ==, 1);
|
||||||
tt_int_op(got_error, ==, 0);
|
tt_int_op(got_error, ==, 0);
|
||||||
|
} else {
|
||||||
|
tt_int_op(got_error, ==, 1);
|
||||||
|
}
|
||||||
|
tt_int_op(got_timeout, ==, 0);
|
||||||
} else {
|
} else {
|
||||||
tt_int_op(got_error, ==, 1);
|
struct timeval t = { 2 };
|
||||||
|
|
||||||
|
bufferevent_enable(bev1, EV_READ|EV_WRITE);
|
||||||
|
bufferevent_disable(bev2, EV_READ|EV_WRITE);
|
||||||
|
|
||||||
|
bufferevent_set_timeouts(bev1, &t, &t);
|
||||||
|
|
||||||
|
evbuffer_add_printf(bufferevent_get_output(bev1), "1\n");
|
||||||
|
|
||||||
|
event_base_dispatch(data->base);
|
||||||
|
|
||||||
|
tt_assert(test_is_done == 0);
|
||||||
|
tt_assert(n_connected == 0);
|
||||||
|
|
||||||
|
tt_int_op(got_close, ==, 0);
|
||||||
|
tt_int_op(got_error, ==, 0);
|
||||||
|
tt_int_op(got_timeout, ==, 1);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
return;
|
return;
|
||||||
@ -577,6 +610,10 @@ struct testcase_t ssl_testcases[] = {
|
|||||||
{ "bufferevent_filter_freed_fd", regress_bufferevent_openssl,
|
{ "bufferevent_filter_freed_fd", regress_bufferevent_openssl,
|
||||||
TT_ISOLATED, &basic_setup,
|
TT_ISOLATED, &basic_setup,
|
||||||
T(REGRESS_OPENSSL_FILTER | REGRESS_OPENSSL_FREED | REGRESS_OPENSSL_FD) },
|
T(REGRESS_OPENSSL_FILTER | REGRESS_OPENSSL_FREED | REGRESS_OPENSSL_FD) },
|
||||||
|
|
||||||
|
{ "bufferevent_socketpair_timeout", regress_bufferevent_openssl,
|
||||||
|
TT_ISOLATED, &basic_setup,
|
||||||
|
T(REGRESS_OPENSSL_SOCKETPAIR | REGRESS_OPENSSL_TIMEOUT) },
|
||||||
#undef T
|
#undef T
|
||||||
|
|
||||||
{ "bufferevent_connect", regress_bufferevent_openssl_connect,
|
{ "bufferevent_connect", regress_bufferevent_openssl_connect,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user