]> granicus.if.org Git - libevent/commitdiff
Allow more than one copy of regression tests to run at once
authorNick Mathewson <nickm@torproject.org>
Fri, 3 Sep 2010 22:48:31 +0000 (18:48 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 3 Sep 2010 22:48:31 +0000 (18:48 -0400)
Mostly this was a matter of just removing all the hardwired ports in
the test code.  The http/connection_retry test is still a little
screwy, though.

test/regress_bufferevent.c
test/regress_dns.c
test/regress_http.c
test/regress_rpc.c
test/regress_testutils.h

index fd9c7e4e894044ae204433c31a3fceff1a09a75b..8f4ca68585ae6e6cb508f11879768cbbcb580789 100644 (file)
@@ -470,7 +470,10 @@ test_bufferevent_connect(void *arg)
        struct evconnlistener *lev=NULL;
        struct bufferevent *bev1=NULL, *bev2=NULL;
        struct sockaddr_in localhost;
-       struct sockaddr *sa = (struct sockaddr*)&localhost;
+       struct sockaddr_storage ss;
+       struct sockaddr *sa;
+       ev_socklen_t slen;
+
        int be_flags=BEV_OPT_CLOSE_ON_FREE;
 
        if (strstr((char*)data->setup_data, "defer")) {
@@ -494,14 +497,21 @@ test_bufferevent_connect(void *arg)
 
        memset(&localhost, 0, sizeof(localhost));
 
-       localhost.sin_port = htons(27015);
+       localhost.sin_port = 0; /* pick-a-port */
        localhost.sin_addr.s_addr = htonl(0x7f000001L);
        localhost.sin_family = AF_INET;
-
+       sa = (struct sockaddr *)&localhost;
        lev = evconnlistener_new_bind(data->base, listen_cb, data->base,
            LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE,
            16, sa, sizeof(localhost));
        tt_assert(lev);
+
+       sa = (struct sockaddr *)&ss;
+       slen = sizeof(ss);
+       if (evconnlistener_get_address(lev, sa, &slen) < 0) {
+               tt_abort_perror("getsockname");
+       }
+
        tt_assert(!evconnlistener_enable(lev));
        bev1 = bufferevent_socket_new(data->base, -1, be_flags);
        bev2 = bufferevent_socket_new(data->base, -1, be_flags);
@@ -584,7 +594,7 @@ test_bufferevent_connect_fail(void *arg)
        test_ok = 0;
 
        memset(&localhost, 0, sizeof(localhost));
-       localhost.sin_port = 0;
+       localhost.sin_port = 0; /* have the kernel pick a port */
        localhost.sin_addr.s_addr = htonl(0x7f000001L);
        localhost.sin_family = AF_INET;
 
index a2d9b10d36aea4a8cb24c3a6e0c8d47157bfb31c..55f1158bf6755ac1f5347c4b4bb4a71c3a626c06 100644 (file)
@@ -364,6 +364,8 @@ dns_server(void)
 {
        evutil_socket_t sock=-1;
        struct sockaddr_in my_addr;
+       struct sockaddr_storage ss;
+       ev_socklen_t slen;
        struct evdns_server_port *port=NULL;
        struct in_addr resolve_addr;
        struct in6_addr resolve_addr6;
@@ -374,11 +376,6 @@ dns_server(void)
 
        base = evdns_base_new(NULL, 0);
 
-       /* Add ourself as the only nameserver, and make sure we really are
-        * the only nameserver. */
-       evdns_base_nameserver_ip_add(base, "127.0.0.1:35353");
-
-       tt_int_op(evdns_base_count_nameservers(base), ==, 1);
        /* Now configure a nameserver port. */
        sock = socket(AF_INET, SOCK_DGRAM, 0);
        if (sock<0) {
@@ -389,13 +386,23 @@ dns_server(void)
 
        memset(&my_addr, 0, sizeof(my_addr));
        my_addr.sin_family = AF_INET;
-       my_addr.sin_port = htons(35353);
+       my_addr.sin_port = 0; /* kernel picks */
        my_addr.sin_addr.s_addr = htonl(0x7f000001UL);
        if (bind(sock, (struct sockaddr*)&my_addr, sizeof(my_addr)) < 0) {
                tt_abort_perror("bind");
        }
+       slen = sizeof(ss);
+       if (getsockname(sock, (struct sockaddr*)&ss, &slen) < 0) {
+               tt_abort_perror("getsockname");
+       }
+
        port = evdns_add_server_port(sock, 0, dns_server_request_cb, NULL);
 
+       /* Add ourself as the only nameserver, and make sure we really are
+        * the only nameserver. */
+       evdns_base_nameserver_sockaddr_add(base, (struct sockaddr*)&ss, slen, 0);
+       tt_int_op(evdns_base_count_nameservers(base), ==, 1);
+
        /* Send some queries. */
        evdns_base_resolve_ipv4(base, "zz.example.com", DNS_QUERY_NO_SEARCH,
                                           dns_server_gethostbyname_cb, NULL);
@@ -496,14 +503,16 @@ dns_search_test(void *arg)
        struct basic_test_data *data = arg;
        struct event_base *base = data->base;
        struct evdns_base *dns = NULL;
-       ev_uint16_t portnum = 53900;/*XXXX let the code pick a port*/
+       ev_uint16_t portnum = 0;
+       char buf[64];
 
        struct generic_dns_callback_result r1, r2, r3, r4, r5;
 
        tt_assert(regress_dnsserver(base, &portnum, search_table));
+       evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum);
 
        dns = evdns_base_new(base, 0);
-       tt_assert(!evdns_base_nameserver_ip_add(dns, "127.0.0.1:53900"));
+       tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
 
        evdns_base_search_add(dns, "a.example.com");
        evdns_base_search_add(dns, "b.example.com");
@@ -570,15 +579,17 @@ dns_search_cancel_test(void *arg)
        struct event_base *base = data->base;
        struct evdns_base *dns = NULL;
        struct evdns_server_port *port = NULL;
-       ev_uint16_t portnum = 53900;/*XXXX let the code pick a port*/
+       ev_uint16_t portnum = 0;
        struct generic_dns_callback_result r1;
+       char buf[64];
 
        port = regress_get_dnsserver(base, &portnum, NULL,
            search_cancel_server_cb, NULL);
        tt_assert(port);
+       evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum);
 
        dns = evdns_base_new(base, 0);
-       tt_assert(!evdns_base_nameserver_ip_add(dns, "127.0.0.1:53900"));
+       tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
 
        evdns_base_search_add(dns, "a.example.com");
        evdns_base_search_add(dns, "b.example.com");
@@ -588,7 +599,7 @@ dns_search_cancel_test(void *arg)
        exit_base = base;
        request_count = 3;
        n_replies_left = 1;
-       
+
        current_req = evdns_base_resolve_ipv4(dns, "host", 0,
                                        generic_dns_callback, &r1);
        event_base_dispatch(base);
@@ -644,16 +655,18 @@ dns_retry_test(void *arg)
        struct evdns_server_port *port = NULL;
        struct evdns_base *dns = NULL;
        int drop_count = 2;
-       ev_uint16_t portnum = 53900;/*XXXX let the code pick a port*/
+       ev_uint16_t portnum = 0;
+       char buf[64];
 
        struct generic_dns_callback_result r1;
 
        port = regress_get_dnsserver(base, &portnum, NULL,
            fail_server_cb, &drop_count);
        tt_assert(port);
+       evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum);
 
        dns = evdns_base_new(base, 0);
-       tt_assert(!evdns_base_nameserver_ip_add(dns, "127.0.0.1:53900"));
+       tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
        tt_assert(! evdns_base_set_option(dns, "timeout", "0.3"));
        tt_assert(! evdns_base_set_option(dns, "max-timeouts:", "10"));
        tt_assert(! evdns_base_set_option(dns, "initial-probe-timeout", "0.5"));
@@ -731,7 +744,8 @@ dns_reissue_test(void *arg)
        struct evdns_server_port *port1 = NULL, *port2 = NULL;
        struct evdns_base *dns = NULL;
        struct generic_dns_callback_result r1;
-       ev_uint16_t portnum1 = 53900, portnum2=53901;
+       ev_uint16_t portnum1 = 0, portnum2=0;
+       char buf1[64], buf2[64];
 
        port1 = regress_get_dnsserver(base, &portnum1, NULL,
            regress_dns_server_cb, internal_error_table);
@@ -739,9 +753,11 @@ dns_reissue_test(void *arg)
        port2 = regress_get_dnsserver(base, &portnum2, NULL,
            regress_dns_server_cb, reissue_table);
        tt_assert(port2);
+       evutil_snprintf(buf1, sizeof(buf1), "127.0.0.1:%d", (int)portnum1);
+       evutil_snprintf(buf2, sizeof(buf2), "127.0.0.1:%d", (int)portnum2);
 
        dns = evdns_base_new(base, 0);
-       tt_assert(!evdns_base_nameserver_ip_add(dns, "127.0.0.1:53900"));
+       tt_assert(!evdns_base_nameserver_ip_add(dns, buf1));
        tt_assert(! evdns_base_set_option(dns, "timeout:", "0.3"));
        tt_assert(! evdns_base_set_option(dns, "max-timeouts:", "2"));
        tt_assert(! evdns_base_set_option(dns, "attempts:", "5"));
@@ -751,7 +767,7 @@ dns_reissue_test(void *arg)
            generic_dns_callback, &r1);
 
        /* Add this after, so that we are sure to get a reissue. */
-       tt_assert(!evdns_base_nameserver_ip_add(dns, "127.0.0.1:53901"));
+       tt_assert(!evdns_base_nameserver_ip_add(dns, buf2));
 
        n_replies_left = 1;
        exit_base = base;
@@ -792,21 +808,17 @@ dns_inflight_test(void *arg)
        struct basic_test_data *data = arg;
        struct event_base *base = data->base;
        struct evdns_base *dns = NULL;
-       ev_uint16_t portnum = 53900;/*XXXX let the code pick a port*/
+       ev_uint16_t portnum = 0;
+       char buf[64];
 
        struct generic_dns_callback_result r[20];
        int i;
 
        tt_assert(regress_dnsserver(base, &portnum, reissue_table));
-
-#if 0
-       /* Make sure that having another (very bad!) RNG doesn't mess us
-        * up. */
-       evdns_set_random_bytes_fn(dumb_bytes_fn);
-#endif
+       evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum);
 
        dns = evdns_base_new(base, 0);
-       tt_assert(!evdns_base_nameserver_ip_add(dns, "127.0.0.1:53900"));
+       tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
        tt_assert(! evdns_base_set_option(dns, "max-inflight:", "3"));
        tt_assert(! evdns_base_set_option(dns, "randomize-case:", "0"));
 
@@ -1042,7 +1054,7 @@ test_bufferevent_connect_hostname(void *arg)
 
        /* Start an evdns_base that uses the server as its resolver. */
        dns = evdns_base_new(data->base, 0);
-       evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", dns_port);
+       evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)dns_port);
        evdns_base_nameserver_ip_add(dns, buf);
 
        /* Now, finally, at long last, launch the bufferevents.  One should do
index 3625f8606b298f21466eae8c68b8c4d757925994..ca6a23e6e41b9bc2ce80f857381399c5045ba993 100644 (file)
@@ -75,24 +75,34 @@ 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 port;
+       struct evhttp_bound_socket *sock;
+
+       sock = evhttp_bind_socket_with_handle(myhttp, "127.0.0.1", *pport);
+       if (sock == NULL)
+               event_errx(1, "Could not start web server");
+
+       port = regress_get_socket_port(evhttp_bound_socket_get_fd(sock));
+       if (port < 0)
+               return -1;
+       *pport = (ev_uint16_t) port;
+
+       return 0;
+}
+
 static struct evhttp *
-http_setup(short *pport, struct event_base *base)
+http_setup(ev_uint16_t *pport, struct event_base *base)
 {
-       int i;
        struct evhttp *myhttp;
-       short port = -1;
 
        /* Try a few different ports */
        myhttp = evhttp_new(base);
-       for (i = 0; i < 50; ++i) {
-               if (evhttp_bind_socket(myhttp, "127.0.0.1", 8080 + i) != -1) {
-                       port = 8080 + i;
-                       break;
-               }
-       }
 
-       if (port == -1)
-               event_errx(1, "Could not start web server");
+       if (http_bind(myhttp, pport) < 0)
+               return NULL;
 
        /* Register a callback for certain types of requests */
        evhttp_set_cb(myhttp, "/test", http_basic_cb, NULL);
@@ -105,8 +115,6 @@ http_setup(short *pport, struct event_base *base)
        evhttp_set_cb(myhttp, "/largedelay", http_large_delay_cb, NULL);
        evhttp_set_cb(myhttp, "/badrequest", http_badreq_cb, NULL);
        evhttp_set_cb(myhttp, "/", http_dispatcher_cb, NULL);
-
-       *pport = port;
        return (myhttp);
 }
 
@@ -330,14 +338,14 @@ http_basic_test(void)
        struct bufferevent *bev;
        evutil_socket_t fd;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port = 0, port2 = 0;
 
        test_ok = 0;
 
        http = http_setup(&port, NULL);
 
        /* bind to a second socket */
-       if (evhttp_bind_socket(http, "127.0.0.1", port + 1) == -1) {
+       if (http_bind(http, &port2) == -1) {
                fprintf(stdout, "FAILED (bind)\n");
                exit(1);
        }
@@ -366,7 +374,7 @@ http_basic_test(void)
        bufferevent_free(bev);
        evutil_closesocket(fd);
 
-       fd = http_connect("127.0.0.1", port + 1);
+       fd = http_connect("127.0.0.1", port2);
 
        /* Stupid thing to send a request */
        bev = bufferevent_new(fd, http_readcb, http_writecb,
@@ -498,7 +506,7 @@ http_bad_request_test(void)
        struct bufferevent *bev = NULL;
        evutil_socket_t fd;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port, port2;
 
        test_ok = 0;
 
@@ -507,7 +515,7 @@ http_bad_request_test(void)
        http = http_setup(&port, NULL);
 
        /* bind to a second socket */
-       if (evhttp_bind_socket(http, "127.0.0.1", port + 1) == -1)
+       if (http_bind(http, &port2) == -1)
                TT_DIE(("Bind socket failed"));
 
        /* NULL request test */
@@ -539,7 +547,7 @@ http_bad_request_test(void)
        /* Second answer (BAD REQUEST) on connection close */
 
        /* connect to the second port */
-       fd = http_connect("127.0.0.1", port + 1);
+       fd = http_connect("127.0.0.1", port2);
 
        /* Stupid thing to send a request */
        bev = bufferevent_new(fd, http_badreq_readcb, http_writecb,
@@ -613,7 +621,7 @@ http_delete_test(void)
        struct bufferevent *bev;
        evutil_socket_t fd;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port;
 
        test_ok = 0;
 
@@ -651,7 +659,7 @@ static void http_request_empty_done(struct evhttp_request *, void *);
 static void
 _http_connection_test(int persistent)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
 
@@ -746,7 +754,7 @@ static struct regress_dns_server_table search_table[] = {
 static void
 http_connection_async_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
        struct evdns_base *dns_base = NULL;
@@ -863,7 +871,7 @@ http_do_cancel(evutil_socket_t fd, short what, void *arg)
 static void
 http_cancel_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
        struct timeval tv;
@@ -979,7 +987,7 @@ http_request_expect_error(struct evhttp_request *req, void *arg)
 static void
 http_virtual_host_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
        struct evhttp *second = NULL, *third = NULL;
@@ -1150,7 +1158,7 @@ http_dispatcher_test_done(struct evhttp_request *req, void *arg)
 static void
 http_dispatcher_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
 
@@ -1199,7 +1207,7 @@ void http_postrequest_done(struct evhttp_request *, void *);
 static void
 http_post_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
 
@@ -1317,7 +1325,7 @@ void http_putrequest_done(struct evhttp_request *, void *);
 static void
 http_put_test(void)
 {
-  short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
 
@@ -1444,7 +1452,7 @@ http_failure_test(void)
        struct bufferevent *bev;
        evutil_socket_t fd;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port = 0;
 
        test_ok = 0;
 
@@ -1527,7 +1535,7 @@ close_detect_cb(struct evhttp_request *req, void *arg)
 static void
 _http_close_detection(int with_delay)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
 
@@ -1663,7 +1671,7 @@ http_base_test(void *ptr)
        struct bufferevent *bev;
        evutil_socket_t fd;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port = 0;
 
        test_ok = 0;
        base = event_init();
@@ -1741,7 +1749,7 @@ _http_incomplete_test(int use_timeout)
        struct bufferevent *bev;
        evutil_socket_t fd;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port = 0;
        struct timeval tv_start, tv_end;
 
        test_ok = 0;
@@ -1943,7 +1951,7 @@ http_chunk_out_test(void)
        struct bufferevent *bev;
        evutil_socket_t fd;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port = 0;
        struct timeval tv_start, tv_end;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
@@ -2014,7 +2022,7 @@ http_chunk_out_test(void)
 static void
 http_stream_out_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
 
@@ -2085,7 +2093,7 @@ _http_stream_in_test(char const *url,
        struct evhttp_connection *evcon;
        struct evbuffer *reply = evbuffer_new();
        struct evhttp_request *req = NULL;
-       short port = -1;
+       ev_uint16_t port = 0;
 
        http = http_setup(&port, NULL);
 
@@ -2154,7 +2162,7 @@ http_stream_in_cancel_test(void)
 {
        struct evhttp_connection *evcon;
        struct evhttp_request *req = NULL;
-       short port = -1;
+       ev_uint16_t port = 0;
 
        http = http_setup(&port, NULL);
 
@@ -2197,23 +2205,24 @@ http_connection_retry_done(struct evhttp_request *req, void *arg)
 static void
 http_make_web_server(evutil_socket_t fd, short what, void *arg)
 {
-       short port = -1;
+       ev_uint16_t port = *(ev_uint16_t*)arg;
        http = http_setup(&port, NULL);
 }
 
 static void
 http_connection_retry_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
        struct timeval tv, tv_start, tv_end;
 
        test_ok = 0;
 
-       /* auto detect the port */
+       /* auto detect a port */
        http = http_setup(&port, NULL);
        evhttp_free(http);
+       http = NULL;
 
        evcon = evhttp_connection_new("127.0.0.1", port);
        tt_assert(evcon);
@@ -2299,7 +2308,7 @@ http_connection_retry_test(void)
         */
        evutil_timerclear(&tv);
        tv.tv_sec = 1;
-       event_once(-1, EV_TIMEOUT, http_make_web_server, NULL, &tv);
+       event_once(-1, EV_TIMEOUT, http_make_web_server, &port, &tv);
 
        evutil_gettimeofday(&tv_start, NULL);
        event_dispatch();
@@ -2351,7 +2360,7 @@ http_multi_line_header_test(void)
        struct bufferevent *bev= NULL;
        evutil_socket_t fd = -1;
        const char *http_start_request;
-       short port = -1;
+       ev_uint16_t port = 0;
 
        test_ok = 0;
 
@@ -2402,7 +2411,7 @@ http_request_bad(struct evhttp_request *req, void *arg)
 static void
 http_negative_content_length_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
 
@@ -2450,7 +2459,7 @@ end:
 static void
 http_data_length_constraints_test(void)
 {
-       short port = -1;
+       ev_uint16_t port = 0;
        struct evhttp_connection *evcon = NULL;
        struct evhttp_request *req = NULL;
        char long_str[8192];
@@ -2596,7 +2605,7 @@ http_terminate_chunked_test(void)
        struct bufferevent *bev = NULL;
        struct timeval tv;
        const char *http_request;
-       short port = -1;
+       ev_uint16_t port = 0;
        evutil_socket_t fd = -1;
 
        test_ok = 0;
index 3620afae791abf9462ab803fb9c413ee8f6365e6..bd66bde7ffe6b8f2724417a018f27838ebca10a7 100644 (file)
 #include "regress.gen.h"
 
 #include "regress.h"
+#include "regress_testutils.h"
 
 static struct evhttp *
-http_setup(short *pport)
+http_setup(ev_uint16_t *pport)
 {
-       int i;
        struct evhttp *myhttp;
-       short port = -1;
+       ev_uint16_t port;
+       struct evhttp_bound_socket *sock;
+
+       myhttp = evhttp_new(NULL);
+       if (!myhttp)
+               event_errx(1, "Could not start web server");
 
        /* Try a few different ports */
-       for (i = 0; i < 50; ++i) {
-               myhttp = evhttp_start("127.0.0.1", 8080 + i);
-               if (myhttp != NULL) {
-                       port = 8080 + i;
-                       break;
-               }
-       }
+       sock = evhttp_bind_socket_with_handle(myhttp, "127.0.0.1", 0);
+       if (!sock)
+               event_errx(1, "Couldn't open web port");
 
-       if (port == -1)
-               event_errx(1, "Could not start web server");
+       port = regress_get_socket_port(evhttp_bound_socket_get_fd(sock));
 
        *pport = port;
        return (myhttp);
@@ -126,9 +126,9 @@ NeverReplyCb(EVRPC_STRUCT(NeverReply)* rpc, void *arg)
 }
 
 static void
-rpc_setup(struct evhttp **phttp, short *pport, struct evrpc_base **pbase)
+rpc_setup(struct evhttp **phttp, ev_uint16_t *pport, struct evrpc_base **pbase)
 {
-       short port;
+       ev_uint16_t port;
        struct evhttp *http = NULL;
        struct evrpc_base *base = NULL;
 
@@ -175,7 +175,7 @@ rpc_postrequest_failure(struct evhttp_request *req, void *arg)
 static void
 rpc_basic_test(void)
 {
-       short port;
+       ev_uint16_t port;
        struct evhttp *http = NULL;
        struct evrpc_base *base = NULL;
        struct evhttp_connection *evcon = NULL;
@@ -244,7 +244,7 @@ rpc_postrequest_done(struct evhttp_request *req, void *arg)
 static void
 rpc_basic_message(void)
 {
-       short port;
+       ev_uint16_t port;
        struct evhttp *http = NULL;
        struct evrpc_base *base = NULL;
        struct evhttp_connection *evcon = NULL;
@@ -297,7 +297,7 @@ end:
 }
 
 static struct evrpc_pool *
-rpc_pool_with_connection(short port)
+rpc_pool_with_connection(ev_uint16_t port)
 {
        struct evhttp_connection *evcon;
        struct evrpc_pool *pool;
@@ -435,7 +435,7 @@ rpc_hook_remove_header(void *ctx, struct evhttp_request *req,
 static void
 rpc_basic_client(void)
 {
-       short port;
+       ev_uint16_t port;
        struct evhttp *http = NULL;
        struct evrpc_base *base = NULL;
        struct evrpc_pool *pool = NULL;
@@ -519,7 +519,7 @@ end:
 static void
 rpc_basic_queued_client(void)
 {
-       short port;
+       ev_uint16_t port;
        struct evhttp *http = NULL;
        struct evrpc_base *base = NULL;
        struct evrpc_pool *pool = NULL;
@@ -617,7 +617,7 @@ rpc_hook_pause(void *ctx, struct evhttp_request *req, struct evbuffer *evbuf,
 static void
 rpc_basic_client_with_pause(void)
 {
-       short port;
+       ev_uint16_t port;
        struct evhttp *http = NULL;
        struct evrpc_base *base = NULL;
        struct evrpc_pool *pool = NULL;
@@ -668,7 +668,7 @@ end:
 static void
 rpc_client_timeout(void)
 {
-       short port;
+       ev_uint16_t port;
        struct evhttp *http = NULL;
        struct evrpc_base *base = NULL;
        struct evrpc_pool *pool = NULL;
index 064047c89335b7e7e0bc8f05e6911bffbb27ee37..56b3214063bfdc898a6cfb1ddbc0c7396802e126 100644 (file)
@@ -27,6 +27,8 @@
 #ifndef _TESTUTILS_H
 #define _TESTUTILS_H
 
+#include <event2/dns.h>
+
 struct regress_dns_server_table {
        const char *q;
        const char *anstype;