diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-08-01 09:40:02 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-08-01 11:01:52 -0400 |
commit | fc0dc5aa9ef526a8ed776fe4896fe4007173c638 (patch) | |
tree | bdc21beb7071ec3370700744ef3a16e823ba065c /src/test/test_util.c | |
parent | 9b24609af003cb79091e628c179cf617ff41aae7 (diff) | |
download | tor-fc0dc5aa9ef526a8ed776fe4896fe4007173c638.tar.gz tor-fc0dc5aa9ef526a8ed776fe4896fe4007173c638.zip |
Refactor tor_ersatz_socketpair() not to need socket.
This change also makes tor_ersatz_socketpair() follow the same
interface as socketpair() rather than tor_socketpair(), so it now
needs to be wrapped in the same code as socketpair() does.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 7afe83c692..d8246941e2 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -5540,10 +5540,13 @@ test_util_socketpair(void *arg) tt_assert(SOCKET_OK(fds[0])); tt_assert(SOCKET_OK(fds[1])); - tt_int_op(get_n_open_sockets(), OP_EQ, n + 2); + if (ersatz) + tt_int_op(get_n_open_sockets(), OP_EQ, n); + else + tt_int_op(get_n_open_sockets(), OP_EQ, n + 2); #ifdef CAN_CHECK_CLOEXEC - tt_int_op(fd_is_cloexec(fds[0]), OP_EQ, 1); - tt_int_op(fd_is_cloexec(fds[1]), OP_EQ, 1); + tt_int_op(fd_is_cloexec(fds[0]), OP_EQ, !ersatz); + tt_int_op(fd_is_cloexec(fds[1]), OP_EQ, !ersatz); #endif #ifdef CAN_CHECK_NONBLOCK tt_int_op(fd_is_nonblocking(fds[0]), OP_EQ, 0); @@ -5551,10 +5554,17 @@ test_util_socketpair(void *arg) #endif done: - if (SOCKET_OK(fds[0])) - tor_close_socket(fds[0]); - if (SOCKET_OK(fds[1])) - tor_close_socket(fds[1]); + if (ersatz) { + if (SOCKET_OK(fds[0])) + tor_close_socket_simple(fds[0]); + if (SOCKET_OK(fds[1])) + tor_close_socket_simple(fds[1]); + } else { + if (SOCKET_OK(fds[0])) + tor_close_socket(fds[0]); + if (SOCKET_OK(fds[1])) + tor_close_socket(fds[1]); + } } #undef SOCKET_EPROTO |