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 <tone.zhang@arm.com>
Reviewed-on: https://review.gerrithub.io/c/439983
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
tone.zhang 2019-01-11 16:39:07 +08:00 committed by Jim Harris
parent 42dba6047b
commit 88ddf0f22e
2 changed files with 5 additions and 5 deletions

View File

@ -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? */

View File

@ -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);