From 56ef5ef90f23e1875247b1ee2b74549845c3eb63 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 8 May 2013 14:03:38 +0000 Subject: [PATCH] tests/net: fix portability issues * tests/net-accept-connect.c: Fix address length passed to bind() and connect(). * tests/net: Update regexps. --- tests/net | 4 ++-- tests/net-accept-connect.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/net b/tests/net index 3fb10ba4..64bcc772 100755 --- a/tests/net +++ b/tests/net @@ -38,10 +38,10 @@ grep_log() grep_log socket '\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0' grep_log socket '\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 1' -grep_log bind '\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 110\) += 0' +grep_log bind '\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 15\) += 0' grep_log listen '\(0, 5\) += 0' grep_log getsockname '\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, \[15\]\) += 0' grep_log accept '\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), NULL\}, \[2\]\) += 1' -grep_log connect '\(1, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 110\) += 0' +grep_log connect '\(1, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 15\) += 0' exit 0 diff --git a/tests/net-accept-connect.c b/tests/net-accept-connect.c index 9d296f7b..5af7d81b 100644 --- a/tests/net-accept-connect.c +++ b/tests/net-accept-connect.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -12,7 +13,7 @@ int main(void) .sun_family = AF_UNIX, .sun_path = SUN_PATH }; - socklen_t len = sizeof addr; + socklen_t len = offsetof(struct sockaddr_un, sun_path) + sizeof SUN_PATH; unlink(SUN_PATH); close(0); @@ -38,7 +39,7 @@ int main(void) } else { assert(socket(PF_LOCAL, SOCK_STREAM, 0) == 1); assert(close(0) == 0); - assert(connect(1, (struct sockaddr *) &addr, sizeof addr) == 0); + assert(connect(1, (struct sockaddr *) &addr, len) == 0); assert(close(1) == 0); return 0; } -- 2.40.0