From fbc323b76b338119dad640f733ee100a88435501 Mon Sep 17 00:00:00 2001 From: Maxime Henrion Date: Wed, 31 Jul 2013 15:02:07 +0000 Subject: [PATCH] Add checks for evhttp_connection_get_server() in unit tests. They validate that this function behave as expected; that is, it returns NULL for outgoing connections, and returns the HTTP server object that received the connection for incoming ones. --- test/regress_http.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/regress_http.c b/test/regress_http.c index 3117b184..6389c4d7 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -281,10 +281,14 @@ static void http_basic_cb(struct evhttp_request *req, void *arg) { struct evbuffer *evb = evbuffer_new(); + struct evhttp_connection *evcon; int empty = evhttp_find_header(evhttp_request_get_input_headers(req), "Empty") != NULL; event_debug(("%s: called\n", __func__)); evbuffer_add_printf(evb, BASIC_REQUEST_BODY); + evcon = evhttp_request_get_connection(req); + tt_assert(evhttp_connection_get_server(evcon) == http); + /* For multi-line headers test */ { const char *multi = @@ -315,6 +319,7 @@ http_basic_cb(struct evhttp_request *req, void *arg) evhttp_send_reply(req, HTTP_OK, "Everything is fine", !empty ? evb : NULL); +end: evbuffer_free(evb); } @@ -869,11 +874,13 @@ http_connection_test_(struct basic_test_data *data, int persistent, const char * tt_assert(evhttp_connection_get_base(evcon) == data->base); exit_base = data->base; + + tt_assert(evhttp_connection_get_server(evcon) == NULL); + /* * At this point, we want to schedule a request to the HTTP * server using our make request method. */ - req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY); /* Add the information that we care about */ -- 2.40.0