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: Nick 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: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Nick Connolly 2021-02-02 10:01:21 +00:00 committed by Tomasz Zawadzki
parent 00afb74669
commit 7d3b2c137a

View File

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