test/sock: Limit sleep to only FreeBSD

There is a sleep in a test to allow a socket close to
propagate through the kernel stack. This is only required
on FreeBSD, so limit it's use to FreeBSD.

This results in slightly faster unit test run times on Linux.

Change-Id: I495d8b91e7247d0757650c4993d18f707c524a22
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475312
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2019-11-20 13:33:37 -07:00 committed by Tomasz Zawadzki
parent f56f15cc28
commit b0472ac853

View File

@ -435,9 +435,11 @@ _sock(const char *ip, int port)
CU_ASSERT(client_sock == NULL);
CU_ASSERT(rc == 0);
#if defined(__FreeBSD__)
/* On FreeBSD, it takes a small amount of time for a close to propagate to the
* other side, even in loopback. Introduce a small sleep. */
sleep(1);
#endif
CU_ASSERT(spdk_sock_is_connected(server_sock) == false);
rc = spdk_sock_close(&server_sock);