Commit 679bf39e authored by Seth Howell's avatar Seth Howell Committed by Darek Stojaczyk
Browse files

test/unit: fix scan-build error in the crypto unittests.



The scan-build error this fixes assumes that we do not reallocate an
iov_base for the g_bdev_io object in between calls to
_crypto_opration_complete. So I explicitly tell it that's what we are
doing.

Change-Id: Ie15c517ea60a2a527a0520005cb044ab2ba4412e
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/437988


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avataryidong0635 <dongx.yi@intel.com>
parent 36325127
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -781,6 +781,10 @@ test_initdrivers(void)
static void
test_crypto_op_complete(void)
{
	/* Need to prove to scan-build that we are setting iov_bases properly. */
	void *old_iov_base;
	struct crypto_bdev_io *orig_ctx;

	/* Make sure completion code respects failure. */
	g_bdev_io->internal.status = SPDK_BDEV_IO_STATUS_FAILED;
	g_completion_called = false;
@@ -803,6 +807,8 @@ test_crypto_op_complete(void)
	MOCK_SET(spdk_bdev_writev_blocks, 0);
	/* Code under test will free this, if not ASAN will complain. */
	g_io_ctx->cry_iov.iov_base = spdk_dma_malloc(16, 0x10, NULL);
	orig_ctx = (struct crypto_bdev_io *)g_bdev_io->driver_ctx;
	old_iov_base = orig_ctx->cry_iov.iov_base;
	_crypto_operation_complete(g_bdev_io);
	CU_ASSERT(g_bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS);
	CU_ASSERT(g_completion_called == true);
@@ -814,6 +820,7 @@ test_crypto_op_complete(void)
	MOCK_SET(spdk_bdev_writev_blocks, -1);
	/* Code under test will free this, if not ASAN will complain. */
	g_io_ctx->cry_iov.iov_base = spdk_dma_malloc(16, 0x10, NULL);
	SPDK_CU_ASSERT_FATAL(old_iov_base != orig_ctx->cry_iov.iov_base);
	_crypto_operation_complete(g_bdev_io);
	CU_ASSERT(g_bdev_io->internal.status == SPDK_BDEV_IO_STATUS_FAILED);
	CU_ASSERT(g_completion_called == true);