Commit 7d3b2c13 authored by Nick Connolly's avatar Nick Connolly Committed by Tomasz Zawadzki
Browse files

unittest/bdev: initialize mutex for portability



For correct behaviour, pthread_mutex must be initialized before use
and destroyed when finished. Add mutex initialization and destroy
calls to io_valid_test.

Signed-off-by: default avatarNick Connolly <nick.connolly@mayadata.io>
Change-Id: Idbbf857f3103ba15ab851ed16ce9f4e2bc99f7dd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6218


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 00afb746
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -749,6 +749,8 @@ io_valid_test(void)
	memset(&bdev, 0, sizeof(bdev));

	bdev.blocklen = 512;
	CU_ASSERT(pthread_mutex_init(&bdev.internal.mutex, NULL) == 0);

	spdk_bdev_notify_blockcnt_change(&bdev, 100);

	/* All parameters valid */
@@ -765,6 +767,8 @@ io_valid_test(void)

	/* Offset near end of uint64_t range (2^64 - 1) */
	CU_ASSERT(bdev_io_valid_blocks(&bdev, 18446744073709551615ULL, 1) == false);

	CU_ASSERT(pthread_mutex_destroy(&bdev.internal.mutex) == 0);
}

static void