From: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx> Don't use a static port number. It might already be in use, resulting in a test failure. Use an ephemeral port to make this test reliable. Cc: Dylan Yudaken <dylany@xxxxxx> Cc: Facebook Kernel Team <kernel-team@xxxxxx> Cc: Pavel Begunkov <asml.silence@xxxxxxxxx> Signed-off-by: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx> --- test/accept.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/accept.c b/test/accept.c index b35ded4..1821faa 100644 --- a/test/accept.c +++ b/test/accept.c @@ -185,29 +185,26 @@ static int start_accept_listen(struct sockaddr_in *addr, int port_off, int32_t val = 1; ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val)); assert(ret != -1); ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); assert(ret != -1); struct sockaddr_in laddr; if (!addr) addr = &laddr; addr->sin_family = AF_INET; - addr->sin_port = htons(0x1235 + port_off); addr->sin_addr.s_addr = inet_addr("127.0.0.1"); - - ret = bind(fd, (struct sockaddr*)addr, sizeof(*addr)); - assert(ret != -1); + assert(!t_bind_ephemeral_port(fd, addr)); ret = listen(fd, 128); assert(ret != -1); return fd; } static int set_client_fd(struct sockaddr_in *addr) { int32_t val; int fd, ret; fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP); -- Ammar Faizi