test/http: connection_fail for https

This commit is contained in:
Azat Khuzhin 2015-11-15 00:08:24 +03:00
parent ac04968311
commit 7ea26f71b8

View File

@ -3352,24 +3352,27 @@ http_connection_fail_done(struct evhttp_request *req, void *arg)
/* Test unrecoverable evhttp_connection errors by generating an ENETUNREACH
* error on connection. */
static void
http_connection_fail_test(void *arg)
http_connection_fail_test_impl(void *arg, int ssl)
{
struct basic_test_data *data = arg;
ev_uint16_t port = 0;
struct evhttp_connection *evcon = NULL;
struct evhttp_request *req = NULL;
struct bufferevent *bev;
exit_base = data->base;
test_ok = 0;
/* auto detect a port */
http = http_setup(&port, data->base, 0);
http = http_setup(&port, data->base, ssl ? HTTP_BIND_SSL : 0);
evhttp_free(http);
http = NULL;
bev = create_bev(data->base, -1, ssl);
/* Pick an unroutable address. This administratively scoped multicast
* address should do when working with TCP. */
evcon = evhttp_connection_base_new(data->base, NULL, "239.10.20.30", 80);
evcon = evhttp_connection_base_bufferevent_new(
data->base, NULL, bev, "239.10.20.30", 80);
tt_assert(evcon);
/*
@ -3391,6 +3394,8 @@ http_connection_fail_test(void *arg)
end:
;
}
static void http_connection_fail_test(void *arg)
{ return http_connection_fail_test_impl(arg, 0); }
static void
http_connection_retry_done(struct evhttp_request *req, void *arg)
@ -4245,6 +4250,8 @@ static void https_chunk_out_test(void *arg)
{ return http_chunk_out_test_impl(arg, 1); }
static void https_stream_out_test(void *arg)
{ return http_stream_out_test_impl(arg, 1); }
static void https_connection_fail_test(void *arg)
{ return http_connection_fail_test_impl(arg, 1); }
#endif
struct testcase_t http_testcases[] = {
@ -4315,6 +4322,7 @@ struct testcase_t http_testcases[] = {
TT_ISOLATED|TT_OFF_BY_DEFAULT, &basic_setup, NULL },
HTTPS(chunk_out),
HTTPS(stream_out),
HTTPS(connection_fail),
#endif
END_OF_TESTCASES