summaryrefslogtreecommitdiffstats
path: root/tests/test_echo_tcp_bind.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-05-31 03:31:56 +0200
committerMichael Adam <obnox@samba.org>2014-06-01 10:03:29 +0200
commit0c3efeb3b07083e36068e354b20208316d02c79a (patch)
treedafb019f92c1730adf6d0414110651f5e020f514 /tests/test_echo_tcp_bind.c
parenta14a1afe966a45000fa768df43a25d84a68772dd (diff)
downloadsocket_wrapper-0c3efeb3b07083e36068e354b20208316d02c79a.tar.gz
socket_wrapper-0c3efeb3b07083e36068e354b20208316d02c79a.tar.xz
socket_wrapper-0c3efeb3b07083e36068e354b20208316d02c79a.zip
tests: extend the ipv6 bind test
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'tests/test_echo_tcp_bind.c')
-rw-r--r--tests/test_echo_tcp_bind.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_echo_tcp_bind.c b/tests/test_echo_tcp_bind.c
index 2348a2f..51528c2 100644
--- a/tests/test_echo_tcp_bind.c
+++ b/tests/test_echo_tcp_bind.c
@@ -219,6 +219,10 @@ static void test_bind_on_ipv6_sock(void **state)
{
struct sockaddr_in sin;
socklen_t slen = sizeof(struct sockaddr_in);
+ struct sockaddr_in6 sin6;
+ socklen_t slen6 = sizeof(struct sockaddr_in6);
+ struct sockaddr_un sun;
+ socklen_t sulen = sizeof(struct sockaddr_un);
int rc;
int s;
@@ -227,6 +231,19 @@ static void test_bind_on_ipv6_sock(void **state)
s = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
assert_return_code(s, errno);
+ ZERO_STRUCT(sun);
+ sun.sun_family = AF_UNIX;
+ rc = bind(s, (struct sockaddr *)&sun, sulen);
+ assert_int_equal(rc, -1);
+ /* FreeBSD uses EINVAL here... */
+ assert_true(errno == EAFNOSUPPORT || errno == EINVAL);
+
+ ZERO_STRUCT(sin);
+ sin.sin_family = AF_INET;
+ rc = bind(s, (struct sockaddr *)&sin, slen);
+ assert_int_equal(rc, -1);
+ assert_int_equal(errno, EINVAL);
+
ZERO_STRUCT(sin);
sin.sin_family = AF_INET;
@@ -235,6 +252,12 @@ static void test_bind_on_ipv6_sock(void **state)
rc = bind(s, (struct sockaddr *)&sin, slen);
assert_int_equal(rc, -1);
+ assert_int_equal(errno, EINVAL);
+
+ ZERO_STRUCT(sin6);
+ sin6.sin6_family = AF_INET;
+ rc = bind(s, (struct sockaddr *)&sin6, slen6);
+ assert_int_equal(rc, -1);
assert_int_equal(errno, EAFNOSUPPORT);
close(s);