From 88ddf0f22e6e6ccb9a21c4905944a6601fdf4776 Mon Sep 17 00:00:00 2001 From: "tone.zhang" Date: Fri, 11 Jan 2019 16:39:07 +0800 Subject: [PATCH] UT: fix the sock_ut failure because of the port conflict In SPDK sock_ut, the port 3260 is tested. It is conflict with the SCSI Target Daemon (tgtd). If the service is enabled, it makes sock_ut failure. Suite: sock Test: posix_sock .../home/ubuntu/spdk/lib/sock/posix/posix.c: 238:spdk_posix_sock_create: *ERROR*: bind() failed errno = 98 FAILED The patch changes port 3260 to UT_PORT, and enhance the error log when socket bind is failed. Also enhance error log carrying port value in posix.c. Change-Id: I31e47af49335cdf7eaffa44237860ebc140d2419 Signed-off-by: tone.zhang Reviewed-on: https://review.gerrithub.io/c/439983 Tested-by: SPDK CI Jenkins Reviewed-by: Ziye Yang Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/sock/posix/posix.c | 2 +- test/unit/lib/sock/sock.c/sock_ut.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/sock/posix/posix.c b/lib/sock/posix/posix.c index 565d38926..3da0ff549 100644 --- a/lib/sock/posix/posix.c +++ b/lib/sock/posix/posix.c @@ -235,7 +235,7 @@ retry: if (type == SPDK_SOCK_CREATE_LISTEN) { rc = bind(fd, res->ai_addr, res->ai_addrlen); if (rc != 0) { - SPDK_ERRLOG("bind() failed, errno = %d\n", errno); + SPDK_ERRLOG("bind() failed at port %d, errno = %d\n", port, errno); switch (errno) { case EINTR: /* interrupted? */ diff --git a/test/unit/lib/sock/sock.c/sock_ut.c b/test/unit/lib/sock/sock.c/sock_ut.c index a0176f11c..df520accd 100644 --- a/test/unit/lib/sock/sock.c/sock_ut.c +++ b/test/unit/lib/sock/sock.c/sock_ut.c @@ -364,7 +364,7 @@ _sock(const char *ip, int port) static void posix_sock(void) { - _sock("127.0.0.1", 3260); + _sock("127.0.0.1", UT_PORT); } static void @@ -484,7 +484,7 @@ _sock_group(const char *ip, int port) static void posix_sock_group(void) { - _sock_group("127.0.0.1", 3260); + _sock_group("127.0.0.1", UT_PORT); } static void @@ -520,14 +520,14 @@ posix_sock_group_fairness(void) struct iovec iov; int i, rc; - listen_sock = spdk_sock_listen("127.0.0.1", 3260); + listen_sock = spdk_sock_listen("127.0.0.1", UT_PORT); SPDK_CU_ASSERT_FATAL(listen_sock != NULL); group = spdk_sock_group_create(); SPDK_CU_ASSERT_FATAL(group != NULL); for (i = 0; i < 3; i++) { - client_sock[i] = spdk_sock_connect("127.0.0.1", 3260); + client_sock[i] = spdk_sock_connect("127.0.0.1", UT_PORT); SPDK_CU_ASSERT_FATAL(client_sock[i] != NULL); usleep(1000);