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
This commit is contained in:
parent
c4b7fe91fc
commit
150d8ca9f3
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user