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.
This commit is contained in:
Maxime Henrion 2013-07-31 15:02:07 +00:00 committed by Nick Mathewson
parent a7f82a314f
commit fbc323b76b

View File

@ -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 */