Commit 88ddf0f2 authored by tone.zhang's avatar tone.zhang Committed by Jim Harris
Browse files

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: default avatartone.zhang <tone.zhang@arm.com>
Reviewed-on: https://review.gerrithub.io/c/439983


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 42dba604
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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? */
+4 −4
Original line number Diff line number Diff line
@@ -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);