]> granicus.if.org Git - strace/commitdiff
tests/net: fix portability issues
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 8 May 2013 14:03:38 +0000 (14:03 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 8 May 2013 14:03:38 +0000 (14:03 +0000)
* tests/net-accept-connect.c: Fix address length passed to bind()
and connect().
* tests/net: Update regexps.

tests/net
tests/net-accept-connect.c

index 3fb10ba4c6814afe9f65f4bac1f8d43d50bdc409..64bcc772e91ad2be52bde83be50430f139921a09 100755 (executable)
--- 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
index 9d296f7b1a0e3d9f5e5d080937c857eee93f88a6..5af7d81b7342109ed2321f82a99af9ca6a8c78ce 100644 (file)
@@ -1,4 +1,5 @@
 #include <assert.h>
+#include <stddef.h>
 #include <string.h>
 #include <unistd.h>
 #include <sys/wait.h>
@@ -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;
        }