git: 150d8ca9f3ba - main - socket afinet tests: using dynamic ports instead of the same static port
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 04 Jul 2023 19:19:40 UTC
The branch main has been updated by olivier: URL: https://cgit.FreeBSD.org/src/commit/?id=150d8ca9f3baa0c0b049ce2e6ba4a88dc5d8e341 commit 150d8ca9f3baa0c0b049ce2e6ba4a88dc5d8e341 Author: Olivier Cochard <olivier@FreeBSD.org> AuthorDate: 2023-07-04 19:11:24 +0000 Commit: Olivier Cochard <olivier@FreeBSD.org> CommitDate: 2023-07-04 19:17:56 +0000 socket afinet tests: using dynamic ports instead of the same static port Allows these tests to be run in parallel. Approved by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D40859 --- tests/sys/netinet/socket_afinet.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/sys/netinet/socket_afinet.c b/tests/sys/netinet/socket_afinet.c index 482f767dd094..8c6bb4ccd294 100644 --- a/tests/sys/netinet/socket_afinet.c +++ b/tests/sys/netinet/socket_afinet.c @@ -82,7 +82,7 @@ ATF_TC_BODY(socket_afinet_bind_ok, tc) bzero(&sin, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(sin); - sin.sin_port = htons(6666); + sin.sin_port = htons(0); sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); rc = bind(sd, (struct sockaddr *)&sin, sizeof(sin)); ATF_CHECK_EQ(0, rc); @@ -95,6 +95,7 @@ ATF_TC_BODY(socket_afinet_poll_no_rdhup, tc) { int ss, ss2, cs, rc; struct sockaddr_in sin; + socklen_t slen; struct pollfd pfd; int one = 1; @@ -108,12 +109,15 @@ ATF_TC_BODY(socket_afinet_poll_no_rdhup, tc) bzero(&sin, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(sin); - sin.sin_port = htons(6666); + sin.sin_port = htons(0); sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); rc = bind(ss, (struct sockaddr *)&sin, sizeof(sin)); ATF_CHECK_EQ(0, rc); rc = listen(ss, 1); ATF_CHECK_EQ(0, rc); + slen = sizeof(sin); + rc = getsockname(ss, (struct sockaddr *)&sin, &slen); + ATF_CHECK_EQ(0, rc); /* Client connects, server accepts. */ cs = socket(PF_INET, SOCK_STREAM, 0); @@ -154,6 +158,7 @@ ATF_TC_BODY(socket_afinet_poll_rdhup, tc) { int ss, ss2, cs, rc; struct sockaddr_in sin; + socklen_t slen; struct pollfd pfd; char buffer; int one = 1; @@ -168,12 +173,15 @@ ATF_TC_BODY(socket_afinet_poll_rdhup, tc) bzero(&sin, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(sin); - sin.sin_port = htons(6666); + sin.sin_port = htons(0); sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); rc = bind(ss, (struct sockaddr *)&sin, sizeof(sin)); ATF_CHECK_EQ(0, rc); rc = listen(ss, 1); ATF_CHECK_EQ(0, rc); + slen = sizeof(sin); + rc = getsockname(ss, (struct sockaddr *)&sin, &slen); + ATF_CHECK_EQ(0, rc); /* Client connects, server accepts. */ cs = socket(PF_INET, SOCK_STREAM, 0); @@ -232,6 +240,7 @@ ATF_TC_WITHOUT_HEAD(socket_afinet_stream_reconnect); ATF_TC_BODY(socket_afinet_stream_reconnect, tc) { struct sockaddr_in sin; + socklen_t slen; int ss, cs, rc; /* @@ -245,12 +254,15 @@ ATF_TC_BODY(socket_afinet_stream_reconnect, tc) bzero(&sin, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(sin); - sin.sin_port = htons(6666); + sin.sin_port = htons(0); sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); rc = bind(ss, (struct sockaddr *)&sin, sizeof(sin)); ATF_CHECK_EQ(0, rc); rc = listen(ss, 1); ATF_CHECK_EQ(0, rc); + slen = sizeof(sin); + rc = getsockname(ss, (struct sockaddr *)&sin, &slen); + ATF_CHECK_EQ(0, rc); /* Client connects, shuts down. */ cs = socket(PF_INET, SOCK_STREAM, 0);