diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-09-09 10:28:12 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-09-09 10:28:12 -0400 |
commit | 4c55e8a58f41933e76bcb309206c98e7b5a1d834 (patch) | |
tree | dc806fb333a97fa1e6891fd3ca725e2ae8d8e05f /src/test | |
parent | 2fe7e3d9d214b5cd7883ce83e5b11e14b02c5973 (diff) | |
download | tor-4c55e8a58f41933e76bcb309206c98e7b5a1d834.tar.gz tor-4c55e8a58f41933e76bcb309206c98e7b5a1d834.zip |
Fix cases where the tests were doing closesocket() on a non-socket
These seem to have caused warnings on windows. Hmmm.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_address.c | 12 | ||||
-rw-r--r-- | src/test/test_connection.c | 11 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/test/test_address.c b/src/test/test_address.c index 9b4c52fdfc..1d13d5339c 100644 --- a/src/test/test_address.c +++ b/src/test/test_address.c @@ -557,6 +557,13 @@ fake_open_socket(int domain, int type, int protocol) return FAKE_SOCKET_FD; } +static int +fake_close_socket(tor_socket_t s) +{ + (void)s; + return 0; +} + static int last_connected_socket_fd = 0; static int connect_retval = 0; @@ -617,6 +624,7 @@ test_address_udp_socket_trick_whitebox(void *arg) MOCK(tor_open_socket,fake_open_socket); MOCK(tor_connect_socket,pretend_to_connect); MOCK(tor_getsockname,fake_getsockname); + MOCK(tor_close_socket,fake_close_socket); mock_addr = tor_malloc_zero(sizeof(struct sockaddr_storage)); sockaddr_in_from_string("23.32.246.118",(struct sockaddr_in *)mock_addr); @@ -647,11 +655,13 @@ test_address_udp_socket_trick_whitebox(void *arg) tt_assert(sockaddr_in6_are_equal(mock_addr6,ipv6_to_check)); + + done: UNMOCK(tor_open_socket); UNMOCK(tor_connect_socket); UNMOCK(tor_getsockname); + UNMOCK(tor_close_socket); - done: tor_free(ipv6_to_check); tor_free(mock_addr); tor_free(addr_from_hack); diff --git a/src/test/test_connection.c b/src/test/test_connection.c index bf2cf18b96..d394fc9852 100644 --- a/src/test/test_connection.c +++ b/src/test/test_connection.c @@ -95,6 +95,13 @@ mock_connection_connect_sockaddr(connection_t *conn, return 1; } +static int +fake_close_socket(evutil_socket_t sock) +{ + (void)sock; + return 0; +} + static void test_conn_lookup_addr_helper(const char *address, int family, tor_addr_t *addr) { @@ -124,6 +131,7 @@ test_conn_get_connection(uint8_t state, uint8_t type, uint8_t purpose) MOCK(connection_connect_sockaddr, mock_connection_connect_sockaddr); + MOCK(tor_close_socket, fake_close_socket); init_connection_lists(); @@ -148,12 +156,13 @@ test_conn_get_connection(uint8_t state, uint8_t type, uint8_t purpose) assert_connection_ok(conn, time(NULL)); UNMOCK(connection_connect_sockaddr); - + UNMOCK(tor_close_socket); return conn; /* On failure */ done: UNMOCK(connection_connect_sockaddr); + UNMOCK(tor_close_socket); return NULL; } |