From e716691a4573888c65e3b768440a93510cc226d6 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Wed, 18 Sep 2019 16:19:29 +0200 Subject: [PATCH] test-tool: use CHECK_FOR_ISCSI() helper macro This removes a large amount of boilerplate code. Signed-off-by: David Disseldorp --- test-tool/test_async_abort_simple.c | 5 +- test-tool/test_async_lu_reset_simple.c | 5 +- test-tool/test_async_read.c | 16 +++---- test-tool/test_async_write.c | 5 +- ...est_compareandwrite_invalid_dataout_size.c | 8 +--- test-tool/test_iscsi_cmdsn_toohigh.c | 8 +--- test-tool/test_iscsi_cmdsn_toolow.c | 8 +--- test-tool/test_iscsi_datasn_invalid.c | 9 +--- test-tool/test_iscsi_nop_simple.c | 8 +--- test-tool/test_iscsi_sendtargets.c | 16 +------ test-tool/test_preventallow_2_itnexuses.c | 9 +--- test-tool/test_preventallow_cold_reset.c | 9 +--- test-tool/test_preventallow_itnexus_loss.c | 9 +--- test-tool/test_preventallow_logout.c | 9 +--- test-tool/test_preventallow_lun_reset.c | 9 +--- test-tool/test_preventallow_warm_reset.c | 9 +--- test-tool/test_prout_preempt.c | 9 +--- test-tool/test_prout_reserve_access.c | 48 +++---------------- test-tool/test_prout_reserve_ownership.c | 48 +++---------------- test-tool/test_read10_invalid.c | 8 +--- test-tool/test_read10_residuals.c | 8 +--- test-tool/test_read12_residuals.c | 8 +--- test-tool/test_read16_residuals.c | 8 +--- test-tool/test_reserve6_2initiators.c | 8 +--- test-tool/test_reserve6_itnexus_loss.c | 8 +--- test-tool/test_reserve6_logout.c | 8 +--- test-tool/test_reserve6_lun_reset.c | 8 +--- test-tool/test_reserve6_target_cold_reset.c | 8 +--- test-tool/test_reserve6_target_warm_reset.c | 8 +--- .../test_sanitize_block_erase_reserved.c | 8 +--- .../test_sanitize_crypto_erase_reserved.c | 8 +--- test-tool/test_sanitize_overwrite_reserved.c | 8 +--- test-tool/test_sanitize_readonly.c | 9 +--- test-tool/test_sanitize_reservations.c | 9 +--- test-tool/test_sanitize_reset.c | 9 +--- test-tool/test_write10_residuals.c | 9 +--- test-tool/test_write12_residuals.c | 9 +--- test-tool/test_write16_residuals.c | 9 +--- test-tool/test_writeverify10_residuals.c | 9 +--- test-tool/test_writeverify12_residuals.c | 9 +--- test-tool/test_writeverify16_residuals.c | 17 +------ 41 files changed, 58 insertions(+), 382 deletions(-) diff --git a/test-tool/test_async_abort_simple.c b/test-tool/test_async_abort_simple.c index 3f3ff58..5add7ce 100644 --- a/test-tool/test_async_abort_simple.c +++ b/test-tool/test_async_abort_simple.c @@ -99,10 +99,7 @@ test_async_abort_simple(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - if (sd->iscsi_ctx == NULL) { - CU_PASS("[SKIPPED] Non-iSCSI"); - return; - } + CHECK_FOR_ISCSI(sd); if (maximum_transfer_length && (maximum_transfer_length < (int)(blocks_per_io))) { diff --git a/test-tool/test_async_lu_reset_simple.c b/test-tool/test_async_lu_reset_simple.c index 0a9b1cb..1b7943f 100644 --- a/test-tool/test_async_lu_reset_simple.c +++ b/test-tool/test_async_lu_reset_simple.c @@ -98,10 +98,7 @@ test_async_lu_reset_simple(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - if (sd->iscsi_ctx == NULL) { - CU_PASS("[SKIPPED] Non-iSCSI"); - return; - } + CHECK_FOR_ISCSI(sd); if (maximum_transfer_length && (maximum_transfer_length < (int)(blocks_per_io))) { diff --git a/test-tool/test_async_read.c b/test-tool/test_async_read.c index d2d7b72..447c8bd 100644 --- a/test-tool/test_async_read.c +++ b/test-tool/test_async_read.c @@ -62,19 +62,17 @@ test_async_read(void) struct tests_async_read_state state = { 0, 0, 0 }; const int blocks_per_io = 8; const int num_ios = 1000; - /* IOs in flight concurrently, so need a buffer large enough for all */ - unsigned char *buf = calloc(block_size * blocks_per_io, num_ios); - - CU_ASSERT_NOT_EQUAL(buf, NULL); - if (!buf) - goto out; + unsigned char *buf = NULL; CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - if (sd->iscsi_ctx == NULL) { - CU_PASS("[SKIPPED] Non-iSCSI"); + CHECK_FOR_ISCSI(sd); + + /* IOs in flight concurrently, so need a buffer large enough for all */ + buf = calloc(block_size * blocks_per_io, num_ios); + CU_ASSERT_NOT_EQUAL(buf, NULL); + if (!buf) goto out; - } if (maximum_transfer_length && (maximum_transfer_length < (blocks_per_io * num_ios))) { diff --git a/test-tool/test_async_write.c b/test-tool/test_async_write.c index f68dbb5..abf4289 100644 --- a/test-tool/test_async_write.c +++ b/test-tool/test_async_write.c @@ -66,10 +66,7 @@ test_async_write(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - if (sd->iscsi_ctx == NULL) { - CU_PASS("[SKIPPED] Non-iSCSI"); - return; - } + CHECK_FOR_ISCSI(sd); if (maximum_transfer_length && (maximum_transfer_length < (blocks_per_io * num_ios))) { diff --git a/test-tool/test_compareandwrite_invalid_dataout_size.c b/test-tool/test_compareandwrite_invalid_dataout_size.c index 9fcd739..fbb32a5 100644 --- a/test-tool/test_compareandwrite_invalid_dataout_size.c +++ b/test-tool/test_compareandwrite_invalid_dataout_size.c @@ -55,13 +55,7 @@ test_compareandwrite_invalid_dataout_size(void) CHECK_FOR_THIN_PROVISIONING; CHECK_FOR_LBPPB_GT_1; CHECK_FOR_SBC; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* override transport queue_pdu callback for PDU manipulation */ iscsi_drv_orig = *sd->iscsi_ctx->drv; diff --git a/test-tool/test_iscsi_cmdsn_toohigh.c b/test-tool/test_iscsi_cmdsn_toohigh.c index 0bffd52..175f015 100644 --- a/test-tool/test_iscsi_cmdsn_toohigh.c +++ b/test-tool/test_iscsi_cmdsn_toohigh.c @@ -55,13 +55,7 @@ void test_iscsi_cmdsn_toohigh(void) logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN"); logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN > MAXCMDSN must be silently ignored by the target"); logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == MAXCMDSN+1. Should be ignored by the target."); diff --git a/test-tool/test_iscsi_cmdsn_toolow.c b/test-tool/test_iscsi_cmdsn_toolow.c index d16b161..803e429 100644 --- a/test-tool/test_iscsi_cmdsn_toolow.c +++ b/test-tool/test_iscsi_cmdsn_toolow.c @@ -55,13 +55,7 @@ void test_iscsi_cmdsn_toolow(void) logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN"); logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN < EXPCMDSN must be silently ignored by the target"); logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN-1. Should be ignored by the target."); diff --git a/test-tool/test_iscsi_datasn_invalid.c b/test-tool/test_iscsi_datasn_invalid.c index 2698885..3a04b3c 100644 --- a/test-tool/test_iscsi_datasn_invalid.c +++ b/test-tool/test_iscsi_datasn_invalid.c @@ -62,18 +62,11 @@ void test_iscsi_datasn_invalid(void) int ret; CHECK_FOR_DATALOSS; + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test sending invalid iSCSI DataSN"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - logging(LOG_VERBOSE, "Send two Data-Out PDU's with DataSN==0. Should fail."); change_datasn = 1; diff --git a/test-tool/test_iscsi_nop_simple.c b/test-tool/test_iscsi_nop_simple.c index 3a5c9bc..b45ab30 100644 --- a/test-tool/test_iscsi_nop_simple.c +++ b/test-tool/test_iscsi_nop_simple.c @@ -83,13 +83,7 @@ test_iscsi_nop_simple(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test Nop Out Pings"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); memset(&state, 0, sizeof(state)); strncpy(state.nop_buf, "nopping", sizeof(state.nop_buf)); diff --git a/test-tool/test_iscsi_sendtargets.c b/test-tool/test_iscsi_sendtargets.c index 3607af8..1fe4d37 100644 --- a/test-tool/test_iscsi_sendtargets.c +++ b/test-tool/test_iscsi_sendtargets.c @@ -106,13 +106,7 @@ test_iscsi_sendtargets_simple(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test SendTargets in FFP"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); memset(&state, 0, sizeof(state)); ret = iscsi_discovery_async(sd->iscsi_ctx, @@ -172,13 +166,7 @@ test_iscsi_sendtargets_invalid(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test invalid SendTargets Text requests"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); memset(&state, 0, sizeof(state)); ret = test_iscsi_text_req_queue(sd->iscsi_ctx, diff --git a/test-tool/test_preventallow_2_itnexuses.c b/test-tool/test_preventallow_2_itnexuses.c index 98d8f4d..cc24631 100644 --- a/test-tool/test_preventallow_2_itnexuses.c +++ b/test-tool/test_preventallow_2_itnexuses.c @@ -33,18 +33,11 @@ test_preventallow_2_itnexuses(void) CHECK_FOR_SBC; CHECK_FOR_REMOVABLE; + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that PREVENT MEDIUM REMOVAL are seen on other nexuses as well"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PREVENTALLOW test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - logging(LOG_VERBOSE, "Set the PREVENT flag"); PREVENTALLOW(sd, 1); diff --git a/test-tool/test_preventallow_cold_reset.c b/test-tool/test_preventallow_cold_reset.c index f196219..18df00d 100644 --- a/test-tool/test_preventallow_cold_reset.c +++ b/test-tool/test_preventallow_cold_reset.c @@ -31,18 +31,11 @@ test_preventallow_cold_reset(void) CHECK_FOR_SBC; CHECK_FOR_REMOVABLE; + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PREVENTALLOW test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - logging(LOG_VERBOSE, "Set the PREVENT flag"); PREVENTALLOW(sd, 1); diff --git a/test-tool/test_preventallow_itnexus_loss.c b/test-tool/test_preventallow_itnexus_loss.c index e28297b..3d2aa5a 100644 --- a/test-tool/test_preventallow_itnexus_loss.c +++ b/test-tool/test_preventallow_itnexus_loss.c @@ -29,18 +29,11 @@ test_preventallow_itnexus_loss(void) { CHECK_FOR_SBC; CHECK_FOR_REMOVABLE; + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that IT-Nexus loss clears PREVENT MEDIUM REMOVAL"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PREVENTALLOW test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - logging(LOG_VERBOSE, "Set the PREVENT flag"); PREVENTALLOW(sd, 1); diff --git a/test-tool/test_preventallow_logout.c b/test-tool/test_preventallow_logout.c index a70b7ea..db48b7c 100644 --- a/test-tool/test_preventallow_logout.c +++ b/test-tool/test_preventallow_logout.c @@ -29,18 +29,11 @@ test_preventallow_logout(void) { CHECK_FOR_SBC; CHECK_FOR_REMOVABLE; + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that Logout loss clears PREVENT MEDIUM REMOVAL"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PREVENTALLOW test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - logging(LOG_VERBOSE, "Set the PREVENT flag"); PREVENTALLOW(sd, 1); diff --git a/test-tool/test_preventallow_lun_reset.c b/test-tool/test_preventallow_lun_reset.c index a1c0957..e3f7402 100644 --- a/test-tool/test_preventallow_lun_reset.c +++ b/test-tool/test_preventallow_lun_reset.c @@ -31,18 +31,11 @@ test_preventallow_lun_reset(void) CHECK_FOR_SBC; CHECK_FOR_REMOVABLE; + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PREVENTALLOW test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - logging(LOG_VERBOSE, "Set the PREVENT flag"); PREVENTALLOW(sd, 1); diff --git a/test-tool/test_preventallow_warm_reset.c b/test-tool/test_preventallow_warm_reset.c index c5ec74f..6dac257 100644 --- a/test-tool/test_preventallow_warm_reset.c +++ b/test-tool/test_preventallow_warm_reset.c @@ -31,18 +31,11 @@ test_preventallow_warm_reset(void) CHECK_FOR_SBC; CHECK_FOR_REMOVABLE; + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PREVENTALLOW test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - logging(LOG_VERBOSE, "Set the PREVENT flag"); PREVENTALLOW(sd, 1); diff --git a/test-tool/test_prout_preempt.c b/test-tool/test_prout_preempt.c index 32edd46..d4424c8 100644 --- a/test-tool/test_prout_preempt.c +++ b/test-tool/test_prout_preempt.c @@ -39,14 +39,7 @@ test_prout_preempt_rm_reg(void) struct scsi_persistent_reserve_in_read_keys *rk; CHECK_FOR_DATALOSS; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test Persistent Reserve IN PREEMPT works."); diff --git a/test-tool/test_prout_reserve_access.c b/test-tool/test_prout_reserve_access.c index 562362f..e52c160 100644 --- a/test-tool/test_prout_reserve_access.c +++ b/test-tool/test_prout_reserve_access.c @@ -123,13 +123,7 @@ test_prout_reserve_access_ea(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -147,13 +141,7 @@ test_prout_reserve_access_we(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -171,13 +159,7 @@ test_prout_reserve_access_earo(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -195,13 +177,7 @@ test_prout_reserve_access_wero(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -219,13 +195,7 @@ test_prout_reserve_access_eaar(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -243,13 +213,7 @@ test_prout_reserve_access_wear(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_prout_reserve_ownership.c b/test-tool/test_prout_reserve_ownership.c index 010a3b4..622df95 100644 --- a/test-tool/test_prout_reserve_ownership.c +++ b/test-tool/test_prout_reserve_ownership.c @@ -98,13 +98,7 @@ test_prout_reserve_ownership_ea(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -121,13 +115,7 @@ test_prout_reserve_ownership_we(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -144,13 +132,7 @@ test_prout_reserve_ownership_earo(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -167,13 +149,7 @@ test_prout_reserve_ownership_wero(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -190,13 +166,7 @@ test_prout_reserve_ownership_eaar(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -213,13 +183,7 @@ test_prout_reserve_ownership_wear(void) struct scsi_device *sd2; int ret; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This PERSISTENT RESERVE test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_read10_invalid.c b/test-tool/test_read10_invalid.c index 05ea7ce..0265e99 100644 --- a/test-tool/test_read10_invalid.c +++ b/test-tool/test_read10_invalid.c @@ -38,13 +38,7 @@ test_read10_invalid(void) logging(LOG_VERBOSE, "Test invalid READ10 commands"); logging(LOG_VERBOSE, "Block size is %zu", block_size); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This READ10 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* Try a read10 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); diff --git a/test-tool/test_read10_residuals.c b/test-tool/test_read10_residuals.c index 1ad6851..24eb1c5 100644 --- a/test-tool/test_read10_residuals.c +++ b/test-tool/test_read10_residuals.c @@ -40,13 +40,7 @@ test_read10_residuals(void) logging(LOG_VERBOSE, "Test READ10 commands with residuals"); logging(LOG_VERBOSE, "Block size is %zu", block_size); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This READ10 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* Try a read10 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); diff --git a/test-tool/test_read12_residuals.c b/test-tool/test_read12_residuals.c index 8ac9384..d239acd 100644 --- a/test-tool/test_read12_residuals.c +++ b/test-tool/test_read12_residuals.c @@ -36,13 +36,7 @@ test_read12_residuals(void) logging(LOG_VERBOSE, "Test READ12 commands with residuals"); logging(LOG_VERBOSE, "Block size is %zu", block_size); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This READ12 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL_FATAL(task); diff --git a/test-tool/test_read16_residuals.c b/test-tool/test_read16_residuals.c index 72fcbf7..5326bc4 100644 --- a/test-tool/test_read16_residuals.c +++ b/test-tool/test_read16_residuals.c @@ -36,13 +36,7 @@ test_read16_residuals(void) logging(LOG_VERBOSE, "Test READ16 commands with residuals"); logging(LOG_VERBOSE, "Block size is %zu", block_size); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This READ16 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL_FATAL(task); diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c index 89eeea1..1ed89ea 100644 --- a/test-tool/test_reserve6_2initiators.c +++ b/test-tool/test_reserve6_2initiators.c @@ -34,13 +34,7 @@ test_reserve6_2initiators(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This RESERVE6 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); RESERVE6(sd); diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c index 9a35d43..85da632 100644 --- a/test-tool/test_reserve6_itnexus_loss.c +++ b/test-tool/test_reserve6_itnexus_loss.c @@ -34,13 +34,7 @@ test_reserve6_itnexus_loss(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that RESERVE6 is released on it-nexus loss"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This RESERVE6 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); RESERVE6(sd); diff --git a/test-tool/test_reserve6_logout.c b/test-tool/test_reserve6_logout.c index ab6ff96..39396b9 100644 --- a/test-tool/test_reserve6_logout.c +++ b/test-tool/test_reserve6_logout.c @@ -34,13 +34,7 @@ test_reserve6_logout(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that RESERVE6 is released on logout"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This RESERVE6 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); RESERVE6(sd); diff --git a/test-tool/test_reserve6_lun_reset.c b/test-tool/test_reserve6_lun_reset.c index ef228ca..9b836e5 100644 --- a/test-tool/test_reserve6_lun_reset.c +++ b/test-tool/test_reserve6_lun_reset.c @@ -34,13 +34,7 @@ test_reserve6_lun_reset(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that RESERVE6 is released on lun reset"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This RESERVE6 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); RESERVE6(sd); diff --git a/test-tool/test_reserve6_target_cold_reset.c b/test-tool/test_reserve6_target_cold_reset.c index 4ab3d88..b24f9d2 100644 --- a/test-tool/test_reserve6_target_cold_reset.c +++ b/test-tool/test_reserve6_target_cold_reset.c @@ -34,13 +34,7 @@ test_reserve6_target_cold_reset(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that RESERVE6 is released on target cold reset"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This RESERVE6 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); RESERVE6(sd); diff --git a/test-tool/test_reserve6_target_warm_reset.c b/test-tool/test_reserve6_target_warm_reset.c index dbd0af8..e6de6e1 100644 --- a/test-tool/test_reserve6_target_warm_reset.c +++ b/test-tool/test_reserve6_target_warm_reset.c @@ -34,13 +34,7 @@ test_reserve6_target_warm_reset(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that RESERVE6 is released on target warm reset"); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This RESERVE6 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); RESERVE6(sd); diff --git a/test-tool/test_sanitize_block_erase_reserved.c b/test-tool/test_sanitize_block_erase_reserved.c index 4a0d2cb..0b11c22 100644 --- a/test-tool/test_sanitize_block_erase_reserved.c +++ b/test-tool/test_sanitize_block_erase_reserved.c @@ -57,13 +57,7 @@ void test_sanitize_block_erase_reserved(void) CHECK_FOR_SANITIZE; CHECK_FOR_DATALOSS; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* override transport queue_pdu callback for PDU manipulation */ iscsi_drv_orig = *sd->iscsi_ctx->drv; diff --git a/test-tool/test_sanitize_crypto_erase_reserved.c b/test-tool/test_sanitize_crypto_erase_reserved.c index 646cbea..2621b79 100644 --- a/test-tool/test_sanitize_crypto_erase_reserved.c +++ b/test-tool/test_sanitize_crypto_erase_reserved.c @@ -57,13 +57,7 @@ void test_sanitize_crypto_erase_reserved(void) CHECK_FOR_SANITIZE; CHECK_FOR_DATALOSS; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* override transport queue_pdu callback for PDU manipulation */ iscsi_drv_orig = *sd->iscsi_ctx->drv; diff --git a/test-tool/test_sanitize_overwrite_reserved.c b/test-tool/test_sanitize_overwrite_reserved.c index 91090b4..3df740a 100644 --- a/test-tool/test_sanitize_overwrite_reserved.c +++ b/test-tool/test_sanitize_overwrite_reserved.c @@ -68,13 +68,7 @@ void test_sanitize_overwrite_reserved(void) CHECK_FOR_SANITIZE; CHECK_FOR_DATALOSS; - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This test is " - "only supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* override transport queue_pdu callback for PDU manipulation */ iscsi_drv_orig = *sd->iscsi_ctx->drv; diff --git a/test-tool/test_sanitize_readonly.c b/test-tool/test_sanitize_readonly.c index 769ee0e..3e309b1 100644 --- a/test-tool/test_sanitize_readonly.c +++ b/test-tool/test_sanitize_readonly.c @@ -40,14 +40,7 @@ test_sanitize_readonly(void) CHECK_FOR_SANITIZE; CHECK_FOR_DATALOSS; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This SANITIZE test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); diff --git a/test-tool/test_sanitize_reservations.c b/test-tool/test_sanitize_reservations.c index b04a380..71d0d6a 100644 --- a/test-tool/test_sanitize_reservations.c +++ b/test-tool/test_sanitize_reservations.c @@ -40,14 +40,7 @@ test_sanitize_reservations(void) CHECK_FOR_SANITIZE; CHECK_FOR_DATALOSS; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This SANITIZE test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); diff --git a/test-tool/test_sanitize_reset.c b/test-tool/test_sanitize_reset.c index 89ec870..19d1fb5 100644 --- a/test-tool/test_sanitize_reset.c +++ b/test-tool/test_sanitize_reset.c @@ -45,14 +45,7 @@ test_sanitize_reset(void) CHECK_FOR_SANITIZE; CHECK_FOR_DATALOSS; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This SANITIZE test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); logging(LOG_VERBOSE, "Check that SANITIZE OVERWRITE will continue " "even after Task/Lun/Target/* reset."); diff --git a/test-tool/test_write10_residuals.c b/test-tool/test_write10_residuals.c index 7c2628f..911c39c 100644 --- a/test-tool/test_write10_residuals.c +++ b/test-tool/test_write10_residuals.c @@ -42,14 +42,7 @@ test_write10_residuals(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This WRITE10 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* Try a write10 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); diff --git a/test-tool/test_write12_residuals.c b/test-tool/test_write12_residuals.c index fef2511..02819ba 100644 --- a/test-tool/test_write12_residuals.c +++ b/test-tool/test_write12_residuals.c @@ -42,14 +42,7 @@ test_write12_residuals(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This WRITE12 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* Try a write12 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); diff --git a/test-tool/test_write16_residuals.c b/test-tool/test_write16_residuals.c index 2f2de94..7088cac 100644 --- a/test-tool/test_write16_residuals.c +++ b/test-tool/test_write16_residuals.c @@ -42,14 +42,7 @@ test_write16_residuals(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This WRITE16 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* Try a write16 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); diff --git a/test-tool/test_writeverify10_residuals.c b/test-tool/test_writeverify10_residuals.c index fbc6eef..7fa100f 100644 --- a/test-tool/test_writeverify10_residuals.c +++ b/test-tool/test_writeverify10_residuals.c @@ -42,14 +42,7 @@ test_writeverify10_residuals(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This WRITEVERIFY10 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* check if writeverify10 is supported */ WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, diff --git a/test-tool/test_writeverify12_residuals.c b/test-tool/test_writeverify12_residuals.c index c78c368..04b6992 100644 --- a/test-tool/test_writeverify12_residuals.c +++ b/test-tool/test_writeverify12_residuals.c @@ -42,14 +42,7 @@ test_writeverify12_residuals(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This WRITEVERIFY12 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* check if writeverify12 is supported */ WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, diff --git a/test-tool/test_writeverify16_residuals.c b/test-tool/test_writeverify16_residuals.c index 4d45ec8..95df7cb 100644 --- a/test-tool/test_writeverify16_residuals.c +++ b/test-tool/test_writeverify16_residuals.c @@ -42,27 +42,12 @@ test_writeverify16_residuals(void) CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] This WRITEVERIFY16 test is only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } + CHECK_FOR_ISCSI(sd); /* check if writeverify16 is supported */ WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 1, 0, NULL, EXPECT_STATUS_GOOD); - if (sd->iscsi_ctx == NULL) { - const char *err = "[SKIPPED] WRITEVERIFY16 tests are only " - "supported for iSCSI backends"; - logging(LOG_NORMAL, "%s", err); - CU_PASS(err); - return; - } - /* Try a writeverify16 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL_FATAL(task);