summaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-11-19 11:19:31 -0500
committerNick Mathewson <nickm@torproject.org>2015-11-19 11:19:31 -0500
commit35bfd782eae29646dcf69e6fff84030721ff7a7d (patch)
tree419171b01a6939ac835c9f0dc1067897a2e3c691 /src/test/test_util.c
parent5f4cd245ec4a944339630c5b3a3368c837d1535d (diff)
parent2c151d8082d9a7969e8775c410601f308d0011ab (diff)
downloadtor-35bfd782eae29646dcf69e6fff84030721ff7a7d.tar.gz
tor-35bfd782eae29646dcf69e6fff84030721ff7a7d.zip
Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost-squashed'
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 05c57c32a7..4cf2f9bda1 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -4342,6 +4342,9 @@ fd_is_nonblocking(tor_socket_t fd)
}
#endif
+#define ERRNO_IS_EPROTO(e) (e == SOCK_ERRNO(EPROTONOSUPPORT))
+#define SOCK_ERR_IS_EPROTO(s) ERRNO_IS_EPROTO(tor_socket_errno(s))
+
/* Test for tor_open_socket*, using IPv4 or IPv6 depending on arg. */
static void
test_util_socket(void *arg)
@@ -4358,7 +4361,7 @@ test_util_socket(void *arg)
(void)arg;
fd1 = tor_open_socket_with_extensions(domain, SOCK_STREAM, 0, 0, 0);
- if (tor_socket_errno(fd1) == SOCK_ERRNO(EPROTONOSUPPORT)) {
+ if (SOCK_ERR_IS_EPROTO(fd1)) {
/* Assume we're on an IPv4-only or IPv6-only system, and give up now. */
goto done;
}
@@ -4425,12 +4428,13 @@ test_util_socketpair(void *arg)
* Otherwise, we risk exposing a socketpair on a routable IP address. (Some
* BSD jails use a routable address for localhost. Fortunately, they have
* the real AF_UNIX socketpair.) */
- if (-socketpair_result == SOCK_ERRNO(EINVAL)) {
+ if (ersatz && ERRNO_IS_EPROTO(-socketpair_result)) {
/* In my testing, an IPv6-only FreeBSD jail without ::1 returned EINVAL.
* Assume we're on a machine without 127.0.0.1 or ::1 and give up now. */
goto done;
}
tt_int_op(0, OP_EQ, socketpair_result);
+
tt_assert(SOCKET_OK(fds[0]));
tt_assert(SOCKET_OK(fds[1]));
tt_int_op(get_n_open_sockets(), OP_EQ, n + 2);
@@ -4450,6 +4454,8 @@ test_util_socketpair(void *arg)
tor_close_socket(fds[1]);
}
+#undef SOCKET_EPROTO
+
static void
test_util_max_mem(void *arg)
{