From 862c217a29c37a7d98009d5bf7f603e56125641d Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 22 Mar 2013 14:35:47 +0400 Subject: [PATCH] Add test for EVREQ_HTTP_REQUEST_CANCEL into http_cancel_test() --- test/regress_http.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/regress_http.c b/test/regress_http.c index eff97950..76abe33b 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -71,6 +71,19 @@ static struct event_base *exit_base; static char const BASIC_REQUEST_BODY[] = "This is funny"; +#define IMPL_HTTP_REQUEST_ERROR_CB(name, expecting_error) \ + static void \ + http_request_error_cb_with_##name##_(enum evhttp_request_error error, \ + void *arg) \ + { \ + if (error != expecting_error) { \ + fprintf(stderr, "FAILED\n"); \ + exit(1); \ + } \ + test_ok = 1; \ + } +IMPL_HTTP_REQUEST_ERROR_CB(cancel, EVREQ_HTTP_REQUEST_CANCEL) + static void http_basic_cb(struct evhttp_request *req, void *arg); static void http_chunked_cb(struct evhttp_request *req, void *arg); static void http_post_cb(struct evhttp_request *req, void *arg); @@ -80,6 +93,7 @@ static void http_delay_cb(struct evhttp_request *req, void *arg); static void http_large_delay_cb(struct evhttp_request *req, void *arg); static void http_badreq_cb(struct evhttp_request *req, void *arg); static void http_dispatcher_cb(struct evhttp_request *req, void *arg); + static int http_bind(struct evhttp *myhttp, ev_uint16_t *pport, int ipv6) { @@ -1080,6 +1094,7 @@ http_cancel_test(void *arg) */ req = evhttp_request_new(http_request_never_call, NULL); + evhttp_request_set_error_cb(req, http_request_error_cb_with_cancel_); /* Add the information that we care about */ evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost"); @@ -1096,7 +1111,7 @@ http_cancel_test(void *arg) event_base_dispatch(data->base); - tt_int_op(test_ok, ==, 2); + tt_int_op(test_ok, ==, 3); /* try to make another request over the same connection */ test_ok = 0; -- 2.40.0