From 45d87238e2324c4ecda3dec03a87d339894c54f8 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sat, 27 Sep 2014 08:58:24 -0700 Subject: [PATCH] TESTS: Flag a whole bunch of tests as not supported on non-iSCSI backends Signed-off-by: Ronnie Sahlberg --- test-tool/iscsi-support.c | 6 +- test-tool/iscsi-support.h | 2 +- test-tool/test_iscsi_cmdsn_toohigh.c | 8 +++ test-tool/test_iscsi_cmdsn_toolow.c | 8 +++ test-tool/test_iscsi_datasn_invalid.c | 7 ++ test-tool/test_preventallow_2_itnexuses.c | 8 +++ test-tool/test_preventallow_cold_reset.c | 8 +++ test-tool/test_preventallow_itnexus_loss.c | 8 +++ test-tool/test_preventallow_logout.c | 8 +++ test-tool/test_preventallow_lun_reset.c | 8 +++ test-tool/test_preventallow_warm_reset.c | 8 +++ test-tool/test_prout_reserve_access.c | 78 +++++++++++++++++++-- test-tool/test_prout_reserve_ownership.c | 78 +++++++++++++++++++-- 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_read6_beyond_eol.c | 6 +- test-tool/test_read6_simple.c | 11 +-- test-tool/test_reserve6_2initiators.c | 7 ++ test-tool/test_reserve6_itnexus_loss.c | 7 ++ test-tool/test_reserve6_logout.c | 7 ++ test-tool/test_reserve6_lun_reset.c | 7 ++ test-tool/test_reserve6_target_cold_reset.c | 7 ++ test-tool/test_reserve6_target_warm_reset.c | 7 ++ test-tool/test_sanitize_block_erase.c | 2 +- test-tool/test_sanitize_readonly.c | 8 +++ test-tool/test_sanitize_reservations.c | 8 +++ test-tool/test_sanitize_reset.c | 8 +++ test-tool/test_write10_residuals.c | 8 +++ test-tool/test_write12_residuals.c | 8 +++ test-tool/test_write16_residuals.c | 8 +++ test-tool/test_writeverify10_residuals.c | 8 +++ test-tool/test_writeverify12_residuals.c | 8 +++ test-tool/test_writeverify16_residuals.c | 16 +++++ 35 files changed, 384 insertions(+), 24 deletions(-) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index bfd4356..7296e9f 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -1653,7 +1653,7 @@ preventallow(struct scsi_device *sdev, int prevent) } int -read6(struct scsi_device *sdev, uint32_t lba, +read6(struct scsi_device *sdev, struct scsi_task **out_task, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq) @@ -1674,7 +1674,9 @@ read6(struct scsi_device *sdev, uint32_t lba, if (data && task) { memcpy(data, task->datain.data, task->datain.size); } - if (task) { + if (out_task) { + *out_task = task; + } else if (task) { scsi_free_scsi_task(task); } return ret; diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 8739601..91feb0a 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -277,7 +277,7 @@ int orwrite(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocks int prefetch10(struct scsi_device *sdev, uint32_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq); int prefetch16(struct scsi_device *sdev, uint64_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq); int preventallow(struct scsi_device *sdev, int prevent); -int read6(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq); +int read6(struct scsi_device *sdev, struct scsi_task **task, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq); int read10(struct scsi_device *sdev, struct scsi_task **task, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq); int read12(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq); int read16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq); diff --git a/test-tool/test_iscsi_cmdsn_toohigh.c b/test-tool/test_iscsi_cmdsn_toohigh.c index 013716a..eb7aa53 100644 --- a/test-tool/test_iscsi_cmdsn_toohigh.c +++ b/test-tool/test_iscsi_cmdsn_toohigh.c @@ -51,6 +51,14 @@ 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; + } + 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 0372f5f..c9cbc40 100644 --- a/test-tool/test_iscsi_cmdsn_toolow.c +++ b/test-tool/test_iscsi_cmdsn_toolow.c @@ -51,6 +51,14 @@ 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; + } + 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 7d7d7b9..f16d5ec 100644 --- a/test-tool/test_iscsi_datasn_invalid.c +++ b/test-tool/test_iscsi_datasn_invalid.c @@ -65,6 +65,13 @@ void test_iscsi_datasn_invalid(void) 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 2 DATAIN with DATASN==0. Should fail."); change_datasn = 1; diff --git a/test-tool/test_preventallow_2_itnexuses.c b/test-tool/test_preventallow_2_itnexuses.c index a14854c..a957fe3 100644 --- a/test-tool/test_preventallow_2_itnexuses.c +++ b/test-tool/test_preventallow_2_itnexuses.c @@ -36,6 +36,14 @@ test_preventallow_2_itnexuses(void) 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"); ret = preventallow(sd, 1); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_preventallow_cold_reset.c b/test-tool/test_preventallow_cold_reset.c index 5ccf5fa..a604b2e 100644 --- a/test-tool/test_preventallow_cold_reset.c +++ b/test-tool/test_preventallow_cold_reset.c @@ -35,6 +35,14 @@ test_preventallow_cold_reset(void) 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"); ret = preventallow(sd, 1); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_preventallow_itnexus_loss.c b/test-tool/test_preventallow_itnexus_loss.c index ac4ccb4..38b8d0f 100644 --- a/test-tool/test_preventallow_itnexus_loss.c +++ b/test-tool/test_preventallow_itnexus_loss.c @@ -35,6 +35,14 @@ test_preventallow_itnexus_loss(void) 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"); ret = preventallow(sd, 1); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_preventallow_logout.c b/test-tool/test_preventallow_logout.c index d92238a..e78baed 100644 --- a/test-tool/test_preventallow_logout.c +++ b/test-tool/test_preventallow_logout.c @@ -35,6 +35,14 @@ test_preventallow_logout(void) 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"); ret = preventallow(sd, 1); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_preventallow_lun_reset.c b/test-tool/test_preventallow_lun_reset.c index 7efb2b8..f7c0502 100644 --- a/test-tool/test_preventallow_lun_reset.c +++ b/test-tool/test_preventallow_lun_reset.c @@ -35,6 +35,14 @@ test_preventallow_lun_reset(void) 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"); ret = preventallow(sd, 1); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_preventallow_warm_reset.c b/test-tool/test_preventallow_warm_reset.c index 87c68f8..42604d1 100644 --- a/test-tool/test_preventallow_warm_reset.c +++ b/test-tool/test_preventallow_warm_reset.c @@ -35,6 +35,14 @@ test_preventallow_warm_reset(void) 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"); ret = preventallow(sd, 1); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_prout_reserve_access.c b/test-tool/test_prout_reserve_access.c index ff39f89..c3c5ce3 100644 --- a/test-tool/test_prout_reserve_access.c +++ b/test-tool/test_prout_reserve_access.c @@ -124,7 +124,18 @@ test_prout_reserve_access_ea(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -140,7 +151,18 @@ test_prout_reserve_access_we(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -156,7 +178,18 @@ test_prout_reserve_access_earo(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -172,7 +205,18 @@ test_prout_reserve_access_wero(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -188,7 +232,18 @@ test_prout_reserve_access_eaar(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -204,7 +259,18 @@ test_prout_reserve_access_wear(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; diff --git a/test-tool/test_prout_reserve_ownership.c b/test-tool/test_prout_reserve_ownership.c index d57e600..54c7638 100644 --- a/test-tool/test_prout_reserve_ownership.c +++ b/test-tool/test_prout_reserve_ownership.c @@ -98,7 +98,18 @@ test_prout_reserve_ownership_ea(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -113,7 +124,18 @@ test_prout_reserve_ownership_we(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -128,7 +150,18 @@ test_prout_reserve_ownership_earo(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -143,7 +176,18 @@ test_prout_reserve_ownership_wero(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -158,7 +202,18 @@ test_prout_reserve_ownership_eaar(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; @@ -173,7 +228,18 @@ test_prout_reserve_ownership_wear(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + 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; + } + + memset(&sd2, 0, sizeof(sd2)); + sd2.iscsi_url = sd->iscsi_url; + sd2.iscsi_lun = sd->iscsi_lun; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); return; diff --git a/test-tool/test_read10_invalid.c b/test-tool/test_read10_invalid.c index 4dfed15..40e55c2 100644 --- a/test-tool/test_read10_invalid.c +++ b/test-tool/test_read10_invalid.c @@ -39,6 +39,14 @@ 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; + } + /* Try a read10 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL(task); diff --git a/test-tool/test_read10_residuals.c b/test-tool/test_read10_residuals.c index bb89c15..f546efa 100644 --- a/test-tool/test_read10_residuals.c +++ b/test-tool/test_read10_residuals.c @@ -40,6 +40,14 @@ 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; + } + /* Try a read10 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL(task); diff --git a/test-tool/test_read12_residuals.c b/test-tool/test_read12_residuals.c index e359075..1deddc0 100644 --- a/test-tool/test_read12_residuals.c +++ b/test-tool/test_read12_residuals.c @@ -36,6 +36,14 @@ 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; + } + task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL(task); diff --git a/test-tool/test_read16_residuals.c b/test-tool/test_read16_residuals.c index a914754..125b662 100644 --- a/test-tool/test_read16_residuals.c +++ b/test-tool/test_read16_residuals.c @@ -36,6 +36,14 @@ 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; + } + task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL(task); diff --git a/test-tool/test_read6_beyond_eol.c b/test-tool/test_read6_beyond_eol.c index eecf32f..b0020ef 100644 --- a/test-tool/test_read6_beyond_eol.c +++ b/test-tool/test_read6_beyond_eol.c @@ -38,7 +38,7 @@ test_read6_beyond_eol(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end"); for (i = 1; i <= 255; i++) { - ret = read6(sd, num_blocks + 1 - i, + ret = read6(sd, NULL, num_blocks + 1 - i, i * block_size, block_size, NULL, EXPECT_LBA_OOB); if (ret == -2) { @@ -52,7 +52,7 @@ test_read6_beyond_eol(void) logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff"); for (i = 1; i <= 255; i++) { - ret = read6(sd, 0x1fffff, + ret = read6(sd, NULL, 0x1fffff, i * block_size, block_size, NULL, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); @@ -61,7 +61,7 @@ test_read6_beyond_eol(void) logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end"); for (i = 2; i <= 255; i++) { - ret = read6(sd, num_blocks - 1, + ret = read6(sd, NULL, num_blocks - 1, i * block_size, block_size, NULL, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_read6_simple.c b/test-tool/test_read6_simple.c index f9d1d95..eb98a9f 100644 --- a/test-tool/test_read6_simple.c +++ b/test-tool/test_read6_simple.c @@ -34,7 +34,7 @@ test_read6_simple(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN"); for (i = 1; i <= 255; i++) { - ret = read6(sd, 0, i * block_size, + ret = read6(sd, NULL, 0, i * block_size, block_size, NULL, EXPECT_STATUS_GOOD); if (ret == -2) { @@ -51,7 +51,7 @@ test_read6_simple(void) CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n"); } else { for (i = 1; i <= 255; i++) { - ret = read6(sd, num_blocks - i, + ret = read6(sd, NULL, num_blocks - i, i * block_size, block_size, NULL, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); @@ -64,11 +64,12 @@ test_read6_simple(void) logging(LOG_VERBOSE, "Test sending a READ6 with transfer length == 0 " "(meaning 256 blocks)"); /* 256 is converted to 0 when the CDB is marshalled by the helper */ - task = iscsi_read6_sync(sd->iscsi_ctx, sd->iscsi_lun, 0, - 256 * block_size, block_size); + ret = read6(sd, &task, 0, + 256 * block_size, block_size, NULL, + EXPECT_STATUS_GOOD); if (task->status != SCSI_STATUS_GOOD) { logging(LOG_NORMAL, "[FAILED] READ6 command: " - "failed with sense. %s", iscsi_get_error(sd->iscsi_ctx)); + "failed with sense. %s", sd->error_str ); } CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c index 4a4e733..b95ebf0 100644 --- a/test-tool/test_reserve6_2initiators.c +++ b/test-tool/test_reserve6_2initiators.c @@ -34,6 +34,13 @@ 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; + } logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); ret = reserve6(sd); diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c index adfa771..0555f18 100644 --- a/test-tool/test_reserve6_itnexus_loss.c +++ b/test-tool/test_reserve6_itnexus_loss.c @@ -34,6 +34,13 @@ 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; + } logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); ret = reserve6(sd); diff --git a/test-tool/test_reserve6_logout.c b/test-tool/test_reserve6_logout.c index 85193f1..5feacba 100644 --- a/test-tool/test_reserve6_logout.c +++ b/test-tool/test_reserve6_logout.c @@ -34,6 +34,13 @@ 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; + } logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); ret = reserve6(sd); diff --git a/test-tool/test_reserve6_lun_reset.c b/test-tool/test_reserve6_lun_reset.c index 110d710..9175056 100644 --- a/test-tool/test_reserve6_lun_reset.c +++ b/test-tool/test_reserve6_lun_reset.c @@ -34,6 +34,13 @@ 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; + } logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); ret = reserve6(sd); diff --git a/test-tool/test_reserve6_target_cold_reset.c b/test-tool/test_reserve6_target_cold_reset.c index 8a76ef7..9b98168 100644 --- a/test-tool/test_reserve6_target_cold_reset.c +++ b/test-tool/test_reserve6_target_cold_reset.c @@ -34,6 +34,13 @@ 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; + } logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); ret = reserve6(sd); diff --git a/test-tool/test_reserve6_target_warm_reset.c b/test-tool/test_reserve6_target_warm_reset.c index 078d393..cf31e84 100644 --- a/test-tool/test_reserve6_target_warm_reset.c +++ b/test-tool/test_reserve6_target_warm_reset.c @@ -34,6 +34,13 @@ 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; + } logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); ret = reserve6(sd); diff --git a/test-tool/test_sanitize_block_erase.c b/test-tool/test_sanitize_block_erase.c index 1cb6d77..33dde5c 100644 --- a/test-tool/test_sanitize_block_erase.c +++ b/test-tool/test_sanitize_block_erase.c @@ -121,7 +121,7 @@ check_unmap(void) if (task_ret->status != SCSI_STATUS_GOOD) { logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping " "from the target. Sense: %s", - iscsi_get_error(sd->iscsi_ctx)); + sd->error_str); CU_FAIL("[FAILED] Failed to read LBA mapping " "from the target."); scsi_free_scsi_task(task_ret); diff --git a/test-tool/test_sanitize_readonly.c b/test-tool/test_sanitize_readonly.c index f526a26..5577338 100644 --- a/test-tool/test_sanitize_readonly.c +++ b/test-tool/test_sanitize_readonly.c @@ -40,6 +40,14 @@ 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; + } + logging(LOG_VERBOSE, "Create a second connection to the target"); memset(&sd2, 0, sizeof(sd2)); sd2.iscsi_url = sd->iscsi_url; diff --git a/test-tool/test_sanitize_reservations.c b/test-tool/test_sanitize_reservations.c index 262dd65..9a272a6 100644 --- a/test-tool/test_sanitize_reservations.c +++ b/test-tool/test_sanitize_reservations.c @@ -40,6 +40,14 @@ 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; + } + logging(LOG_VERBOSE, "Create a second connection to the target"); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); if (sd2.iscsi_ctx == NULL) { diff --git a/test-tool/test_sanitize_reset.c b/test-tool/test_sanitize_reset.c index f2bd11b..604d112 100644 --- a/test-tool/test_sanitize_reset.c +++ b/test-tool/test_sanitize_reset.c @@ -46,6 +46,14 @@ 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; + } + logging(LOG_VERBOSE, "Check that SANITIZE OVERWRITE will continue " "even after Task/Lun/Target/* reset."); cd = get_command_descriptor(SCSI_OPCODE_SANITIZE, diff --git a/test-tool/test_write10_residuals.c b/test-tool/test_write10_residuals.c index 07f8931..7c68d47 100644 --- a/test-tool/test_write10_residuals.c +++ b/test-tool/test_write10_residuals.c @@ -43,6 +43,14 @@ 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; + } + /* Try a write10 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL(task); diff --git a/test-tool/test_write12_residuals.c b/test-tool/test_write12_residuals.c index 036f5df..854b840 100644 --- a/test-tool/test_write12_residuals.c +++ b/test-tool/test_write12_residuals.c @@ -43,6 +43,14 @@ 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; + } + /* Try a write12 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL(task); diff --git a/test-tool/test_write16_residuals.c b/test-tool/test_write16_residuals.c index 6a6b46b..6860994 100644 --- a/test-tool/test_write16_residuals.c +++ b/test-tool/test_write16_residuals.c @@ -43,6 +43,14 @@ 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; + } + /* Try a write16 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); CU_ASSERT_PTR_NOT_NULL(task); diff --git a/test-tool/test_writeverify10_residuals.c b/test-tool/test_writeverify10_residuals.c index 6c8069a..287ec85 100644 --- a/test-tool/test_writeverify10_residuals.c +++ b/test-tool/test_writeverify10_residuals.c @@ -43,6 +43,14 @@ 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 if writeverify10 is supported */ ret = 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 ffe91f7..879bbf8 100644 --- a/test-tool/test_writeverify12_residuals.c +++ b/test-tool/test_writeverify12_residuals.c @@ -43,6 +43,14 @@ 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 if writeverify12 is supported */ ret = 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 bc264cc..72f84a8 100644 --- a/test-tool/test_writeverify16_residuals.c +++ b/test-tool/test_writeverify16_residuals.c @@ -43,6 +43,14 @@ 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 if writeverify16 is supported */ ret = writeverify16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, @@ -53,6 +61,14 @@ test_writeverify16_residuals(void) return; } + 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(task);