diff --git a/test-tool/0160_readcapacity16_simple.c b/test-tool/0160_readcapacity16_simple.c index 90be354..a62e24c 100644 --- a/test-tool/0160_readcapacity16_simple.c +++ b/test-tool/0160_readcapacity16_simple.c @@ -23,7 +23,7 @@ int T0160_readcapacity16_simple(const char *initiator, const char *url) { struct iscsi_context *iscsi; - struct scsi_readcapacity16 *rc16; + struct scsi_readcapacity16 *rc; struct scsi_task *task; int ret, lun; @@ -59,8 +59,8 @@ int T0160_readcapacity16_simple(const char *initiator, const char *url) scsi_free_scsi_task(task); goto finished; } - rc16 = scsi_datain_unmarshall(task); - if (rc16 == NULL) { + rc = scsi_datain_unmarshall(task); + if (rc == NULL) { printf("[FAILED]\n"); printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); ret = -1; diff --git a/test-tool/0170_unmap_simple.c b/test-tool/0170_unmap_simple.c index 0a5ef11..830209e 100644 --- a/test-tool/0170_unmap_simple.c +++ b/test-tool/0170_unmap_simple.c @@ -42,7 +42,7 @@ int T0170_unmap_simple(const char *initiator, const char *url) return -1; } - if (lbpme == 0){ + if (rc16 == NULL || rc16->lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; goto finished; diff --git a/test-tool/0171_unmap_zero.c b/test-tool/0171_unmap_zero.c index a8b11a7..8649349 100644 --- a/test-tool/0171_unmap_zero.c +++ b/test-tool/0171_unmap_zero.c @@ -44,7 +44,7 @@ int T0171_unmap_zero(const char *initiator, const char *url) return -1; } - if (lbpme == 0){ + if (rc16 == NULL || rc16->lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; goto finished; diff --git a/test-tool/0180_writesame10_unmap.c b/test-tool/0180_writesame10_unmap.c index 1f26330..bc8e213 100644 --- a/test-tool/0180_writesame10_unmap.c +++ b/test-tool/0180_writesame10_unmap.c @@ -49,7 +49,7 @@ int T0180_writesame10_unmap(const char *initiator, const char *url) ret = 0; - if (lbpme == 0){ + if (rc16 == NULL || rc16->lbpme == 0){ printf("Logical unit is fully provisioned. All commands should fail with check condition.\n"); } diff --git a/test-tool/0181_writesame10_unmap_unaligned.c b/test-tool/0181_writesame10_unmap_unaligned.c index 2e50621..692a076 100644 --- a/test-tool/0181_writesame10_unmap_unaligned.c +++ b/test-tool/0181_writesame10_unmap_unaligned.c @@ -41,7 +41,7 @@ int T0181_writesame10_unmap_unaligned(const char *initiator, const char *url) return -1; } - if (lbpme == 0){ + if (rc16 == NULL || rc16->lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; goto finished; diff --git a/test-tool/0190_writesame16_unmap.c b/test-tool/0190_writesame16_unmap.c index ad78aeb..889e740 100644 --- a/test-tool/0190_writesame16_unmap.c +++ b/test-tool/0190_writesame16_unmap.c @@ -49,7 +49,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url) ret = 0; - if (lbpme == 0) { + if (rc16 == NULL || rc16->lbpme == 0){ printf("LBPME not set. Skip test for CPD page 0xB2 (logical block provisioning)\n"); goto finished; } diff --git a/test-tool/0191_writesame16_unmap_unaligned.c b/test-tool/0191_writesame16_unmap_unaligned.c index 583c991..bcb8bdd 100644 --- a/test-tool/0191_writesame16_unmap_unaligned.c +++ b/test-tool/0191_writesame16_unmap_unaligned.c @@ -41,7 +41,7 @@ int T0191_writesame16_unmap_unaligned(const char *initiator, const char *url) return -1; } - if (lbpme == 0){ + if (rc16 == NULL || rc16->lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; goto finished; diff --git a/test-tool/0260_get_lba_status_simple.c b/test-tool/0260_get_lba_status_simple.c index 4144959..8606cb7 100644 --- a/test-tool/0260_get_lba_status_simple.c +++ b/test-tool/0260_get_lba_status_simple.c @@ -42,7 +42,7 @@ int T0260_get_lba_status_simple(const char *initiator, const char *url) return -1; } - if (lbpme == 0){ + if (rc16 == NULL || rc16->lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; goto finished; diff --git a/test-tool/0264_get_lba_status_beyondeol.c b/test-tool/0264_get_lba_status_beyondeol.c index e0c7432..9fe74ed 100644 --- a/test-tool/0264_get_lba_status_beyondeol.c +++ b/test-tool/0264_get_lba_status_beyondeol.c @@ -41,7 +41,7 @@ int T0264_get_lba_status_beyondeol(const char *initiator, const char *url) return -1; } - if (lbpme == 0){ + if (rc16 == NULL || rc16->lbpme == 0){ printf("Logical unit is fully provisioned. Skipping test\n"); ret = -2; goto finished; diff --git a/test-tool/0300_readonly.c b/test-tool/0300_readonly.c index 6e11bbf..e2b0bb3 100644 --- a/test-tool/0300_readonly.c +++ b/test-tool/0300_readonly.c @@ -259,7 +259,7 @@ int T0300_readonly(const char *initiator, const char *url) /* UNMAP one block at lba 0 */ printf("WRITESAME10 to UNMAP LUN 0 ... "); - if (lbpme == 0) { + if (rc16 == NULL || rc16->lbpme == 0){ printf("LUN is not thin-provisioned. [SKIPPED]\n"); goto finished; } @@ -295,10 +295,6 @@ int T0300_readonly(const char *initiator, const char *url) /* UNMAP one block at lba 0 */ printf("WRITESAME16 to UNMAP LUN 0 ... "); - if (lbpme == 0) { - printf("LUN is not thin-provisioned. [SKIPPED]\n"); - goto finished; - } task = iscsi_writesame16_sync(iscsi, lun, 0, data, block_size, 1, @@ -331,10 +327,6 @@ int T0300_readonly(const char *initiator, const char *url) /* UNMAP one block at lba 0 */ printf("UNMAP LUN 0 ... "); - if (lbpme == 0) { - printf("LUN is not thin-provisioned. [SKIPPED]\n"); - goto finished; - } list[0].lba = 0; list[0].num = 1; task = iscsi_unmap_sync(iscsi, lun, 0, 0, &list[0], 1); diff --git a/test-tool/0390_mandatory_opcodes_sbc.c b/test-tool/0390_mandatory_opcodes_sbc.c index a8d31e7..14798d5 100644 --- a/test-tool/0390_mandatory_opcodes_sbc.c +++ b/test-tool/0390_mandatory_opcodes_sbc.c @@ -208,7 +208,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test UNMAP ... "); - if (lbpme == 0) { + if (rc16 == NULL || rc16->lbpme == 0){ printf("[LBPME == 0, SKIPPING TEST]\n"); } else { task = iscsi_unmap_sync(iscsi, lun, 0, 0, NULL, 0); @@ -246,7 +246,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test WRITE SAME16 ... "); - if (lbpme == 0) { + if (rc16 == NULL || rc16->lbpme == 0){ printf("[LBPME == 0, SKIPPING TEST]\n"); } else { task = iscsi_writesame16_sync(iscsi, lun, 0, diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index a4b937f..a546853 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -47,17 +47,16 @@ const char *initiatorname2 = const char *tgt_url; struct scsi_inquiry_standard *inq; +struct scsi_readcapacity16 *rc16; size_t block_size; uint64_t num_blocks; -int lbpme; int lbppb; -int lbpme; enum scsi_inquiry_peripheral_device_type device_type; int data_loss; +int anc_sup; int lbpws10; int lbpws; -int anc_sup; int readonly; int sbc3_support; int maximum_transfer_length; diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index d5f82aa..292a919 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -77,7 +77,7 @@ do { \ #define CHECK_FOR_THIN_PROVISIONING \ do { \ - if (lbpme == 0) { \ + if (rc16 == NULL || rc16->lbpme == 0) { \ logging(LOG_VERBOSE, "[SKIPPED] Logical unit is fully" \ " provisioned. Skipping test"); \ CU_PASS("[SKIPPED] Logical unit is fully provisioned." \ @@ -129,16 +129,15 @@ do { \ } while (0); extern struct scsi_inquiry_standard *inq; +extern struct scsi_readcapacity16 *rc16; extern size_t block_size; extern uint64_t num_blocks; -extern int lbpme; extern int lbppb; -extern int lbpme; extern int data_loss; +extern int anc_sup; extern int lbpws10; extern int lbpws; -extern int anc_sup; extern int readonly; extern int sbc3_support; extern int maximum_transfer_length; diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index bc38f4c..6cee7bb 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -857,8 +857,8 @@ main(int argc, char *argv[]) CU_ErrorAction error_action = CUEA_IGNORE; int res; struct scsi_readcapacity10 *rc10; - struct scsi_readcapacity16 *rc16; struct scsi_task *inq_task; + struct scsi_task *rc16_task; int full_size; int is_usb; static struct option long_opts[] = { @@ -992,29 +992,25 @@ main(int argc, char *argv[]) num_blocks = rc10->lba + 1; scsi_free_scsi_task(task); - task = iscsi_readcapacity16_sync(iscsic, lun); - if (task == NULL) { + rc16_task = iscsi_readcapacity16_sync(iscsic, lun); + if (rc16_task == NULL) { printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsic)); iscsi_destroy_context(iscsic); return -1; } - if (task->status == SCSI_STATUS_GOOD) { - rc16 = scsi_datain_unmarshall(task); + if (rc16_task->status == SCSI_STATUS_GOOD) { + rc16 = scsi_datain_unmarshall(rc16_task); if (rc16 == NULL) { printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsic)); - scsi_free_scsi_task(task); + scsi_free_scsi_task(rc16_task); iscsi_destroy_context(iscsic); return -1; } block_size = rc16->block_length; num_blocks = rc16->returned_lba + 1; - lbpme = rc16->lbpme; lbppb = 1 << rc16->lbppbe; - lbpme = rc16->lbpme; - - scsi_free_scsi_task(task); } inq_task = iscsi_inquiry_sync(iscsic, lun, 0, 0, 64); @@ -1049,7 +1045,7 @@ main(int argc, char *argv[]) } /* if thin provisioned we also need to read the VPD page for it */ - if (lbpme != 0) { + if (rc16 && rc16->lbpme != 0){ struct scsi_inquiry_logical_block_provisioning *inq_lbp; task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64); @@ -1146,6 +1142,7 @@ main(int argc, char *argv[]) free(discard_const(tgt_url)); scsi_free_scsi_task(inq_task); + scsi_free_scsi_task(rc16_task); return 0; } diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index 16e6669..dcf32a4 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -315,8 +315,8 @@ int main(int argc, char *argv[]) struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_task *inq_task; + struct scsi_task *rc16_task; struct scsi_readcapacity10 *rc10; - struct scsi_readcapacity16 *rc16; int full_size; int c; @@ -437,27 +437,23 @@ int main(int argc, char *argv[]) num_blocks = rc10->lba; scsi_free_scsi_task(task); - task = iscsi_readcapacity16_sync(iscsi, lun); - if (task == NULL) { + rc16_task = iscsi_readcapacity16_sync(iscsi, lun); + if (rc16_task == NULL) { printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); iscsi_destroy_context(iscsi); return -1; } - if (task->status == SCSI_STATUS_GOOD) { - rc16 = scsi_datain_unmarshall(task); + if (rc16_task->status == SCSI_STATUS_GOOD) { + rc16 = scsi_datain_unmarshall(rc16_task); if (rc16 == NULL) { printf("failed to unmarshall READCAPACITY16 data. %s\n", iscsi_get_error(iscsi)); - scsi_free_scsi_task(task); + scsi_free_scsi_task(rc16_task); iscsi_destroy_context(iscsi); return -1; } block_size = rc16->block_length; num_blocks = rc16->returned_lba; - lbpme = rc16->lbpme; lbppb = 1 << rc16->lbppbe; - lbpme = rc16->lbpme; - - scsi_free_scsi_task(task); } @@ -519,6 +515,7 @@ int main(int argc, char *argv[]) } scsi_free_scsi_task(inq_task); + scsi_free_scsi_task(rc16_task); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/test_orwrite_wrprotect.c b/test-tool/test_orwrite_wrprotect.c index ed41ea4..a1a9d49 100644 --- a/test-tool/test_orwrite_wrprotect.c +++ b/test-tool/test_orwrite_wrprotect.c @@ -32,19 +32,17 @@ test_orwrite_wrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; - CHECK_FOR_SBC; - /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test ORWRITE with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = orwrite_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -56,5 +54,8 @@ test_orwrite_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_read10_rdprotect.c b/test-tool/test_read10_rdprotect.c index d503d75..77f475d 100644 --- a/test-tool/test_read10_rdprotect.c +++ b/test-tool/test_read10_rdprotect.c @@ -33,22 +33,22 @@ test_read10_rdprotect(void) /* * Try out different non-zero values for RDPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ10 with non-zero RDPROTECT"); CHECK_FOR_SBC; - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read10_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, i, 0, 0, 0, 0, NULL); CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_read12_rdprotect.c b/test-tool/test_read12_rdprotect.c index 2b49532..6f9709c 100644 --- a/test-tool/test_read12_rdprotect.c +++ b/test-tool/test_read12_rdprotect.c @@ -32,17 +32,14 @@ test_read12_rdprotect(void) /* * Try out different non-zero values for RDPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ12 with non-zero RDPROTECT"); CHECK_FOR_SBC; - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read12_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -54,5 +51,8 @@ test_read12_rdprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_read16_rdprotect.c b/test-tool/test_read16_rdprotect.c index 1ab4d80..0abeee6 100644 --- a/test-tool/test_read16_rdprotect.c +++ b/test-tool/test_read16_rdprotect.c @@ -30,18 +30,16 @@ test_read16_rdprotect(void) { int i, ret; - CHECK_FOR_SBC; - /* * Try out different non-zero values for RDPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ16 with non-zero RDPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read16_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -53,5 +51,7 @@ test_read16_rdprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_verify10_vrprotect.c b/test-tool/test_verify10_vrprotect.c index ba3021b..be256f3 100644 --- a/test-tool/test_verify10_vrprotect.c +++ b/test-tool/test_verify10_vrprotect.c @@ -35,10 +35,11 @@ test_verify10_vrprotect(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 with non-zero VRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read10(iscsic, tgt_lun, 0, block_size, block_size, 0, 0, 0, 0, 0, buf); @@ -53,5 +54,8 @@ test_verify10_vrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_verify12_vrprotect.c b/test-tool/test_verify12_vrprotect.c index c3f3ca1..bf18a86 100644 --- a/test-tool/test_verify12_vrprotect.c +++ b/test-tool/test_verify12_vrprotect.c @@ -34,10 +34,11 @@ test_verify12_vrprotect(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 with non-zero VRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read10(iscsic, tgt_lun, 0, block_size, @@ -52,5 +53,8 @@ test_verify12_vrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_verify16_vrprotect.c b/test-tool/test_verify16_vrprotect.c index ad4d9fb..e1dcd03 100644 --- a/test-tool/test_verify16_vrprotect.c +++ b/test-tool/test_verify16_vrprotect.c @@ -35,10 +35,11 @@ test_verify16_vrprotect(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 with non-zero VRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = read16(iscsic, tgt_lun, 0, block_size, block_size, 0, 0, 0, 0, 0, buf); @@ -52,5 +53,8 @@ test_verify16_vrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_write10_wrprotect.c b/test-tool/test_write10_wrprotect.c index a87b29d..293bd00 100644 --- a/test-tool/test_write10_wrprotect.c +++ b/test-tool/test_write10_wrprotect.c @@ -32,18 +32,17 @@ test_write10_wrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; - /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE10 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = write10_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -55,5 +54,8 @@ test_write10_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_write12_wrprotect.c b/test-tool/test_write12_wrprotect.c index 3e61ae0..4c48950 100644 --- a/test-tool/test_write12_wrprotect.c +++ b/test-tool/test_write12_wrprotect.c @@ -32,18 +32,18 @@ test_write12_wrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE12 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = write12_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -55,5 +55,8 @@ test_write12_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_write16_wrprotect.c b/test-tool/test_write16_wrprotect.c index a75a787..30df63a 100644 --- a/test-tool/test_write16_wrprotect.c +++ b/test-tool/test_write16_wrprotect.c @@ -32,19 +32,17 @@ test_write16_wrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; - CHECK_FOR_SBC; - /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITE16 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = write16_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -56,5 +54,8 @@ test_write16_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_writesame10_wrprotect.c b/test-tool/test_writesame10_wrprotect.c index dbe2acd..7cd560d 100644 --- a/test-tool/test_writesame10_wrprotect.c +++ b/test-tool/test_writesame10_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -29,22 +30,19 @@ void test_writesame10_wrprotect(void) { int i, ret; - unsigned char *buf; + unsigned char *buf = alloca(block_size); + + /* + * Try out different non-zero values for WRPROTECT. + */ + logging(LOG_VERBOSE, LOG_BLANK_LINE); + logging(LOG_VERBOSE, "Test WRITESAME10 with non-zero WRPROTECT"); CHECK_FOR_DATALOSS; CHECK_FOR_SBC; - /* - * Try out different non-zero values for WRPROTECT. - * They should all fail. - */ - logging(LOG_VERBOSE, LOG_BLANK_LINE); - logging(LOG_VERBOSE, "Test WRITESAME10 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); - buf = malloc(block_size); + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writesame10_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, 1, @@ -56,6 +54,8 @@ test_writesame10_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } - free(buf); + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_writesame16_wrprotect.c b/test-tool/test_writesame16_wrprotect.c index 01fd7f0..a36a28b 100644 --- a/test-tool/test_writesame16_wrprotect.c +++ b/test-tool/test_writesame16_wrprotect.c @@ -32,19 +32,17 @@ test_writesame16_wrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; - CHECK_FOR_SBC; - /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME16 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writesame16_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, 1, @@ -56,5 +54,8 @@ test_writesame16_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_writeverify10_wrprotect.c b/test-tool/test_writeverify10_wrprotect.c index 92f5923..9cfe7ff 100644 --- a/test-tool/test_writeverify10_wrprotect.c +++ b/test-tool/test_writeverify10_wrprotect.c @@ -32,18 +32,17 @@ test_writeverify10_wrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; - /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY10 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writeverify10_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -55,5 +54,8 @@ test_writeverify10_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_writeverify12_wrprotect.c b/test-tool/test_writeverify12_wrprotect.c index bceabac..8779aa3 100644 --- a/test-tool/test_writeverify12_wrprotect.c +++ b/test-tool/test_writeverify12_wrprotect.c @@ -32,18 +32,17 @@ test_writeverify12_wrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; - /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY12 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writeverify12_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -55,5 +54,8 @@ test_writeverify12_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); } diff --git a/test-tool/test_writeverify16_wrprotect.c b/test-tool/test_writeverify16_wrprotect.c index 0b2bbb2..c8090a3 100644 --- a/test-tool/test_writeverify16_wrprotect.c +++ b/test-tool/test_writeverify16_wrprotect.c @@ -34,19 +34,17 @@ test_writeverify16_wrprotect(void) unsigned char *buf = alloca(block_size); - CHECK_FOR_DATALOSS; - CHECK_FOR_SBC; - /* * Try out different non-zero values for WRPROTECT. - * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY16 with non-zero WRPROTECT"); - if (inq->protect) { - logging(LOG_VERBOSE, "No tests for devices that support protection information yet."); - } else { - logging(LOG_VERBOSE, "Device does not support protection information. All commands should fail."); + + CHECK_FOR_DATALOSS; + CHECK_FOR_SBC; + + if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { + logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); for (i = 1; i < 8; i++) { ret = writeverify16_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, @@ -58,5 +56,8 @@ test_writeverify16_wrprotect(void) } CU_ASSERT_EQUAL(ret, 0); } + return; } + + logging(LOG_NORMAL, "No tests for devices that support protection information yet."); }