diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index d406e40..28ac06c 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -181,6 +181,48 @@ do { \ } \ } while (0); +#define WRITEVERIFY10(...) \ + do { \ + int _r; \ + _r = writeverify10(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "WRITEVERIFY10. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + +#define WRITEVERIFY12(...) \ + do { \ + int _r; \ + _r = writeverify12(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "WRITEVERIFY12. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + +#define WRITEVERIFY16(...) \ + do { \ + int _r; \ + _r = writeverify16(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "WRITEVERIFY16. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + extern struct scsi_inquiry_standard *inq; extern struct scsi_inquiry_logical_block_provisioning *inq_lbp; extern struct scsi_inquiry_block_device_characteristics *inq_bdc; diff --git a/test-tool/test_writeverify10_0blocks.c b/test-tool/test_writeverify10_0blocks.c index 08c44c4..2cdb054 100644 --- a/test-tool/test_writeverify10_0blocks.c +++ b/test-tool/test_writeverify10_0blocks.c @@ -27,8 +27,6 @@ void test_writeverify10_0blocks(void) { - int ret; - CHECK_FOR_DATALOSS; if (num_blocks >= 0x80000000) { @@ -38,33 +36,18 @@ test_writeverify10_0blocks(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==0"); - ret = writeverify10(sd, 0, 0, block_size, - 0, 0, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented."); - CU_PASS("WRITEVERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks one block past end-of-LUN"); - ret = writeverify10(sd, num_blocks + 1, 0, - block_size, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITEVERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==2^31"); - ret = writeverify10(sd, 0x80000000, 0, - block_size, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITEVERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==-1"); - ret = writeverify10(sd, -1, 0, block_size, - 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, -1, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_writeverify10_beyond_eol.c b/test-tool/test_writeverify10_beyond_eol.c index dbb1d9f..6e1186a 100644 --- a/test-tool/test_writeverify10_beyond_eol.c +++ b/test-tool/test_writeverify10_beyond_eol.c @@ -29,7 +29,7 @@ void test_writeverify10_beyond_eol(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -46,50 +46,38 @@ test_writeverify10_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify10(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented."); - CU_PASS("WRITEVERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, num_blocks + 1 - i, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==2^31"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify10(sd, 0x80000000, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, 0x80000000, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify10(sd, -1, i * block_size, - block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, -1, i * block_size, + block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY10 2-256 blocks all but one block beyond the end"); for (i = 2; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify10(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, num_blocks - 1, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writeverify10_dpo.c b/test-tool/test_writeverify10_dpo.c index 85676be..155d057 100644 --- a/test-tool/test_writeverify10_dpo.c +++ b/test-tool/test_writeverify10_dpo.c @@ -66,25 +66,13 @@ test_writeverify10_dpo(void) logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1"); if (dpofua) { - ret = writeverify10(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented."); - CU_PASS("WRITEVERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, 0, block_size, + block_size, 0, 1, 0, 0, buf, + EXPECT_STATUS_GOOD); } else { - ret = writeverify10(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented."); - CU_PASS("WRITEVERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, 0, block_size, + block_size, 0, 1, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " diff --git a/test-tool/test_writeverify10_flags.c b/test-tool/test_writeverify10_flags.c index 03be5d5..476a979 100644 --- a/test-tool/test_writeverify10_flags.c +++ b/test-tool/test_writeverify10_flags.c @@ -30,7 +30,6 @@ void test_writeverify10_flags(void) { - int ret; unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; @@ -41,13 +40,6 @@ test_writeverify10_flags(void) logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1"); memset(buf, 0xa6, block_size); - ret = writeverify10(sd, 0, - block_size, block_size, 0, 0, 1, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented."); - CU_PASS("WRITEVERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, buf, + EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_writeverify10_residuals.c b/test-tool/test_writeverify10_residuals.c index 1229938..5110c08 100644 --- a/test-tool/test_writeverify10_residuals.c +++ b/test-tool/test_writeverify10_residuals.c @@ -53,13 +53,8 @@ test_writeverify10_residuals(void) } /* check if writeverify10 is supported */ - ret = writeverify10(sd, 0, 0, - block_size, 0, 0, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - CU_PASS("[SKIPPED] Target does not support WRITEVERIFY10. Skipping test"); - return; - } + WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_STATUS_GOOD); /* Try a writeverify10 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); diff --git a/test-tool/test_writeverify10_simple.c b/test-tool/test_writeverify10_simple.c index a786267..adbca05 100644 --- a/test-tool/test_writeverify10_simple.c +++ b/test-tool/test_writeverify10_simple.c @@ -30,7 +30,7 @@ void test_writeverify10_simple(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -42,15 +42,9 @@ test_writeverify10_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify10(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITEVERIFY10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, 0, i * block_size, + block_size, 0, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the end of the LUN"); @@ -58,10 +52,8 @@ test_writeverify10_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } - } diff --git a/test-tool/test_writeverify10_wrprotect.c b/test-tool/test_writeverify10_wrprotect.c index e2a1c0d..bf99def 100644 --- a/test-tool/test_writeverify10_wrprotect.c +++ b/test-tool/test_writeverify10_wrprotect.c @@ -30,7 +30,7 @@ void test_writeverify10_wrprotect(void) { - int i, ret; + int i; unsigned char *buf = alloca(block_size); /* @@ -46,16 +46,9 @@ test_writeverify10_wrprotect(void) 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(sd, 0, - block_size, block_size, - i, 0, 0, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented."); - CU_PASS("WRITEVERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY10(sd, 0, block_size, block_size, + i, 0, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } return; } diff --git a/test-tool/test_writeverify12_0blocks.c b/test-tool/test_writeverify12_0blocks.c index 97cc573..cae5ec4 100644 --- a/test-tool/test_writeverify12_0blocks.c +++ b/test-tool/test_writeverify12_0blocks.c @@ -27,8 +27,6 @@ void test_writeverify12_0blocks(void) { - int ret; - CHECK_FOR_DATALOSS; if (num_blocks >= 0x80000000) { @@ -38,33 +36,18 @@ test_writeverify12_0blocks(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==0"); - ret = writeverify12(sd, 0, 0, block_size, - 0, 0, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented."); - CU_PASS("WRITEVERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks one block past end-of-LUN"); - ret = writeverify12(sd, num_blocks + 1, 0, - block_size, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITEVERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==2^31"); - ret = writeverify12(sd, 0x80000000, 0, - block_size, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITEVERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==-1"); - ret = writeverify12(sd, -1, 0, block_size, - 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, -1, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_writeverify12_beyond_eol.c b/test-tool/test_writeverify12_beyond_eol.c index 4fb1613..aa90e9c 100644 --- a/test-tool/test_writeverify12_beyond_eol.c +++ b/test-tool/test_writeverify12_beyond_eol.c @@ -29,7 +29,7 @@ void test_writeverify12_beyond_eol(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -46,50 +46,38 @@ test_writeverify12_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify12(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented."); - CU_PASS("WRITEVERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, num_blocks + 1 - i, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==2^31"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify12(sd, 0x80000000, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, 0x80000000, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify12(sd, -1, i * block_size, - block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, -1, i * block_size, + block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY12 2-256 blocks all but one block beyond the end"); for (i = 2; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify12(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, num_blocks - 1, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writeverify12_dpo.c b/test-tool/test_writeverify12_dpo.c index a6fadfd..d7047d3 100644 --- a/test-tool/test_writeverify12_dpo.c +++ b/test-tool/test_writeverify12_dpo.c @@ -66,25 +66,13 @@ test_writeverify12_dpo(void) logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1"); if (dpofua) { - ret = writeverify12(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented."); - CU_PASS("WRITEVERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, 0, block_size, + block_size, 0, 1, 0, 0, buf, + EXPECT_STATUS_GOOD); } else { - ret = writeverify12(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented."); - CU_PASS("WRITEVERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, 0, block_size, + block_size, 0, 1, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " diff --git a/test-tool/test_writeverify12_flags.c b/test-tool/test_writeverify12_flags.c index 3635a88..60b28fc 100644 --- a/test-tool/test_writeverify12_flags.c +++ b/test-tool/test_writeverify12_flags.c @@ -30,7 +30,6 @@ void test_writeverify12_flags(void) { - int ret; unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; @@ -41,13 +40,6 @@ test_writeverify12_flags(void) logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1"); memset(buf, 0xa6, block_size); - ret = writeverify12(sd, 0, - block_size, block_size, 0, 0, 1, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented."); - CU_PASS("WRITEVERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, buf, + EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_writeverify12_residuals.c b/test-tool/test_writeverify12_residuals.c index b0beb61..e7f797c 100644 --- a/test-tool/test_writeverify12_residuals.c +++ b/test-tool/test_writeverify12_residuals.c @@ -53,13 +53,8 @@ test_writeverify12_residuals(void) } /* check if writeverify12 is supported */ - ret = writeverify12(sd, 0, 0, - block_size, 0, 0, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - CU_PASS("[SKIPPED] Target does not support WRITEVERIFY12. Skipping test"); - return; - } + WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_STATUS_GOOD); /* Try a writeverify12 of 1 block but xferlength == 0 */ task = malloc(sizeof(struct scsi_task)); diff --git a/test-tool/test_writeverify12_simple.c b/test-tool/test_writeverify12_simple.c index db8d33d..3e4447f 100644 --- a/test-tool/test_writeverify12_simple.c +++ b/test-tool/test_writeverify12_simple.c @@ -30,7 +30,7 @@ void test_writeverify12_simple(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -42,15 +42,9 @@ test_writeverify12_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify12(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented."); - CU_PASS("WRITEVERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, 0, i * block_size, + block_size, 0, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN"); @@ -58,10 +52,8 @@ test_writeverify12_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = writeverify12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } - } diff --git a/test-tool/test_writeverify12_wrprotect.c b/test-tool/test_writeverify12_wrprotect.c index 80f5e36..ce88c1a 100644 --- a/test-tool/test_writeverify12_wrprotect.c +++ b/test-tool/test_writeverify12_wrprotect.c @@ -30,7 +30,7 @@ void test_writeverify12_wrprotect(void) { - int i, ret; + int i; unsigned char *buf = alloca(block_size); /* @@ -46,16 +46,9 @@ test_writeverify12_wrprotect(void) 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(sd, 0, - block_size, block_size, - i, 0, 0, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented."); - CU_PASS("WRITEVERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY12(sd, 0, block_size, block_size, + i, 0, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } return; } diff --git a/test-tool/test_writeverify16_0blocks.c b/test-tool/test_writeverify16_0blocks.c index 78fbf76..de186e7 100644 --- a/test-tool/test_writeverify16_0blocks.c +++ b/test-tool/test_writeverify16_0blocks.c @@ -27,40 +27,24 @@ void test_writeverify16_0blocks(void) { - int ret; - CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==0"); - ret = writeverify16(sd, 0, - 0, block_size, 0, 0, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("WRITEVERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks one block past end-of-LUN"); - ret = writeverify16(sd, num_blocks + 1, - 0, block_size, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITEVERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==2^63"); - ret = writeverify16(sd, 0x8000000000000000ULL, - 0, block_size, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITEVERIFY16(sd, 0x8000000000000000ULL, + 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==-1"); - ret = writeverify16(sd, -1, - 0, block_size, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, -1, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_writeverify16_beyond_eol.c b/test-tool/test_writeverify16_beyond_eol.c index 45e9bd3..84dd3ce 100644 --- a/test-tool/test_writeverify16_beyond_eol.c +++ b/test-tool/test_writeverify16_beyond_eol.c @@ -29,7 +29,7 @@ void test_writeverify16_beyond_eol(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -42,54 +42,38 @@ test_writeverify16_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = writeverify16(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("WRITEVERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, num_blocks + 1 - i, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==2^63"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = writeverify16(sd, 0x8000000000000000ULL, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, 0x8000000000000000ULL, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = writeverify16(sd, -1, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, -1, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITEVERIFY16 2-256 blocks all but one block beyond the end"); for (i = 2; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = writeverify16(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, num_blocks - 1, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writeverify16_dpo.c b/test-tool/test_writeverify16_dpo.c index b944e7b..f995149 100644 --- a/test-tool/test_writeverify16_dpo.c +++ b/test-tool/test_writeverify16_dpo.c @@ -67,25 +67,13 @@ test_writeverify16_dpo(void) logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1"); memset(buf, 0xa6, block_size); if (dpofua) { - ret = writeverify16(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("WRITEVERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, 0, block_size, + block_size, 0, 1, 0, 0, buf, + EXPECT_STATUS_GOOD); } else { - ret = writeverify16(sd, 0, block_size, - block_size, 0, 1, 0, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("WRITEVERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, 0, block_size, + block_size, 0, 1, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } diff --git a/test-tool/test_writeverify16_flags.c b/test-tool/test_writeverify16_flags.c index e07dbde..7fe01b2 100644 --- a/test-tool/test_writeverify16_flags.c +++ b/test-tool/test_writeverify16_flags.c @@ -30,7 +30,6 @@ void test_writeverify16_flags(void) { - int ret; unsigned char *buf = alloca(block_size); CHECK_FOR_DATALOSS; @@ -41,13 +40,6 @@ test_writeverify16_flags(void) logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1"); memset(buf, 0xa6, block_size); - ret = writeverify16(sd, 0, - block_size, block_size, 0, 0, 1, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("WRITEVERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, buf, + EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_writeverify16_residuals.c b/test-tool/test_writeverify16_residuals.c index 128dcab..3d646ba 100644 --- a/test-tool/test_writeverify16_residuals.c +++ b/test-tool/test_writeverify16_residuals.c @@ -53,14 +53,8 @@ test_writeverify16_residuals(void) } /* check if writeverify16 is supported */ - ret = writeverify16(sd, 0, 0, - block_size, 0, 0, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITEVERIFY16. Skipping test"); - return; - } + WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL, + EXPECT_STATUS_GOOD); if (sd->iscsi_ctx == NULL) { const char *err = "[SKIPPED] WRITEVERIFY16 tests are only " diff --git a/test-tool/test_writeverify16_simple.c b/test-tool/test_writeverify16_simple.c index ed29336..4c879ba 100644 --- a/test-tool/test_writeverify16_simple.c +++ b/test-tool/test_writeverify16_simple.c @@ -30,7 +30,7 @@ void test_writeverify16_simple(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -43,16 +43,9 @@ test_writeverify16_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = writeverify16(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("WRITEVERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, 0, i * block_size, + block_size, 0, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the end of the LUN"); @@ -60,11 +53,8 @@ test_writeverify16_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = writeverify16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } - } diff --git a/test-tool/test_writeverify16_wrprotect.c b/test-tool/test_writeverify16_wrprotect.c index 9133711..6836b91 100644 --- a/test-tool/test_writeverify16_wrprotect.c +++ b/test-tool/test_writeverify16_wrprotect.c @@ -31,10 +31,9 @@ void test_writeverify16_wrprotect(void) { - int i, ret; + int i; unsigned char *buf = alloca(block_size); - /* * Try out different non-zero values for WRPROTECT. */ @@ -48,16 +47,9 @@ test_writeverify16_wrprotect(void) 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(sd, 0, - block_size, block_size, - i, 0, 0, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented."); - CU_PASS("WRITEVERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITEVERIFY16(sd, 0, block_size, block_size, + i, 0, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } return; }