From b4e4649ae52bd9021944682e6caf61ad3cf67ee4 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sat, 20 Feb 2016 20:00:45 -0800 Subject: [PATCH] Tests: Add helper macros for Verify* Signed-off-by: Ronnie Sahlberg --- test-tool/iscsi-support.h | 42 +++++++++++++++++++++++ test-tool/test_verify10_0blocks.c | 31 ++++------------- test-tool/test_verify10_beyond_eol.c | 36 +++++++------------ test-tool/test_verify10_dpo.c | 22 +++--------- test-tool/test_verify10_flags.c | 15 ++------ test-tool/test_verify10_mismatch.c | 17 +++------ test-tool/test_verify10_mismatch_no_cmp.c | 18 +++------- test-tool/test_verify10_simple.c | 18 +++------- test-tool/test_verify10_vrprotect.c | 12 ++----- test-tool/test_verify12_0blocks.c | 31 ++++------------- test-tool/test_verify12_beyond_eol.c | 38 +++++++------------- test-tool/test_verify12_dpo.c | 22 +++--------- test-tool/test_verify12_flags.c | 11 ++---- test-tool/test_verify12_mismatch.c | 18 +++------- test-tool/test_verify12_mismatch_no_cmp.c | 18 +++------- test-tool/test_verify12_simple.c | 18 +++------- test-tool/test_verify12_vrprotect.c | 12 +++---- test-tool/test_verify16_0blocks.c | 31 ++++------------- test-tool/test_verify16_beyond_eol.c | 42 +++++++---------------- test-tool/test_verify16_dpo.c | 22 +++--------- test-tool/test_verify16_flags.c | 13 ++----- test-tool/test_verify16_mismatch.c | 18 +++------- test-tool/test_verify16_mismatch_no_cmp.c | 18 +++------- test-tool/test_verify16_simple.c | 19 ++++------ test-tool/test_verify16_vrprotect.c | 13 +++---- 25 files changed, 174 insertions(+), 381 deletions(-) diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index c26a1e9..6b1c161 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -181,6 +181,48 @@ do { \ } \ } while (0); +#define VERIFY10(...) \ + do { \ + int _r; \ + _r = verify10(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] VERIFY10 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "VERIFY10. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + +#define VERIFY12(...) \ + do { \ + int _r; \ + _r = verify12(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] VERIFY12 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "VERIFY12. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + +#define VERIFY16(...) \ + do { \ + int _r; \ + _r = verify16(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] VERIFY16 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "VERIFY16. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + #define WRITE10(...) \ do { \ int _r; \ diff --git a/test-tool/test_verify10_0blocks.c b/test-tool/test_verify10_0blocks.c index 3813b27..cfdf24b 100644 --- a/test-tool/test_verify10_0blocks.c +++ b/test-tool/test_verify10_0blocks.c @@ -27,37 +27,18 @@ void test_verify10_0blocks(void) { - int ret; - logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==0"); - ret = verify10(sd, 0, 0, block_size, - 0, 0, 1, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test VERIFY10 0-blocks one block past end-of-LUN"); - ret = verify10(sd, num_blocks + 1, 0, - block_size, 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + VERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==2^31"); - ret = verify10(sd, 0x80000000, 0, - block_size, 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + VERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==-1"); - ret = verify10(sd, -1, 0, block_size, - 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, -1, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_verify10_beyond_eol.c b/test-tool/test_verify10_beyond_eol.c index 6c006e5..59ae3c3 100644 --- a/test-tool/test_verify10_beyond_eol.c +++ b/test-tool/test_verify10_beyond_eol.c @@ -29,7 +29,7 @@ void test_verify10_beyond_eol(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); if (num_blocks >= 0x80000000) { @@ -44,39 +44,28 @@ test_verify10_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = verify10(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, num_blocks + 1 - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==2^31"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = verify10(sd, 0x80000000, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, 0x80000000, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = verify10(sd, -1, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, -1, i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } @@ -85,9 +74,8 @@ test_verify10_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = verify10(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, num_blocks - 1, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_verify10_dpo.c b/test-tool/test_verify10_dpo.c index c910899..aa3e073 100644 --- a/test-tool/test_verify10_dpo.c +++ b/test-tool/test_verify10_dpo.c @@ -66,25 +66,11 @@ test_verify10_dpo(void) logging(LOG_VERBOSE, "Test VERIFY10 with DPO==1"); if (dpofua) { - ret = verify10(sd, 0, block_size, - block_size, 0, 1, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("VERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, buf, + EXPECT_STATUS_GOOD); } else { - ret = verify10(sd, 0, block_size, - block_size, 0, 1, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("VERIFY10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " diff --git a/test-tool/test_verify10_flags.c b/test-tool/test_verify10_flags.c index eaa6dea..97c7598 100644 --- a/test-tool/test_verify10_flags.c +++ b/test-tool/test_verify10_flags.c @@ -30,7 +30,7 @@ void test_verify10_flags(void) { int ret; - unsigned char *buf = malloc(block_size); + unsigned char *buf = alloca(block_size); logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY10 flags"); @@ -42,15 +42,6 @@ test_verify10_flags(void) logging(LOG_VERBOSE, "Test VERIFY10 with BYTCHK==1"); - ret = verify10(sd, 0, block_size, - block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test"); - free(buf); - return; - } - CU_ASSERT_EQUAL(ret, 0); - free(buf); + VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_verify10_mismatch.c b/test-tool/test_verify10_mismatch.c index 48bff71..90ff600 100644 --- a/test-tool/test_verify10_mismatch.c +++ b/test-tool/test_verify10_mismatch.c @@ -50,14 +50,8 @@ test_verify10_mismatch(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify10(sd, 0, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_MISCOMPARE); - if (ret == -2) { - CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + EXPECT_MISCOMPARE); } logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN"); @@ -76,9 +70,8 @@ test_verify10_mismatch(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_MISCOMPARE); - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_MISCOMPARE); } } diff --git a/test-tool/test_verify10_mismatch_no_cmp.c b/test-tool/test_verify10_mismatch_no_cmp.c index b5bfbc6..0faa3c0 100644 --- a/test-tool/test_verify10_mismatch_no_cmp.c +++ b/test-tool/test_verify10_mismatch_no_cmp.c @@ -50,15 +50,8 @@ test_verify10_mismatch_no_cmp(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify10(sd, 0, i * block_size, - block_size, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK of 1-256 blocks at the end of the LUN"); @@ -77,9 +70,8 @@ test_verify10_mismatch_no_cmp(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify10_simple.c b/test-tool/test_verify10_simple.c index e8e6504..9f28166 100644 --- a/test-tool/test_verify10_simple.c +++ b/test-tool/test_verify10_simple.c @@ -44,15 +44,8 @@ test_verify10_simple(void) EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - ret = verify10(sd, 0, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN"); @@ -65,9 +58,8 @@ test_verify10_simple(void) EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - ret = verify10(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify10_vrprotect.c b/test-tool/test_verify10_vrprotect.c index 2c76011..e7aec87 100644 --- a/test-tool/test_verify10_vrprotect.c +++ b/test-tool/test_verify10_vrprotect.c @@ -46,15 +46,9 @@ test_verify10_vrprotect(void) EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - ret = verify10(sd, 0, block_size, - block_size, i, 0, 1, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY10(sd, 0, block_size, + block_size, i, 0, 1, buf, + EXPECT_INVALID_FIELD_IN_CDB); } return; } diff --git a/test-tool/test_verify12_0blocks.c b/test-tool/test_verify12_0blocks.c index 8b106af..c196f71 100644 --- a/test-tool/test_verify12_0blocks.c +++ b/test-tool/test_verify12_0blocks.c @@ -27,37 +27,18 @@ void test_verify12_0blocks(void) { - int ret; - logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==0"); - ret = verify12(sd, 0, 0, block_size, - 0, 0, 1, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test VERIFY12 0-blocks one block past end-of-LUN"); - ret = verify12(sd, num_blocks + 1, 0, - block_size, 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + VERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==2^31"); - ret = verify12(sd, 0x80000000, 0, - block_size, 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + VERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==-1"); - ret = verify12(sd, -1, 0, block_size, - 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, -1, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_verify12_beyond_eol.c b/test-tool/test_verify12_beyond_eol.c index 51a9d24..1b13ffa 100644 --- a/test-tool/test_verify12_beyond_eol.c +++ b/test-tool/test_verify12_beyond_eol.c @@ -29,7 +29,7 @@ void test_verify12_beyond_eol(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); if (num_blocks >= 0x80000000) { @@ -44,50 +44,38 @@ test_verify12_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = verify12(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, num_blocks + 1 - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==2^31"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = verify12(sd, 0x80000000, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, 0x80000000, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = verify12(sd, -1, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, -1, i * block_size, + block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY12 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 = verify12(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, num_blocks - 1, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_verify12_dpo.c b/test-tool/test_verify12_dpo.c index 19d08ad..9bde476 100644 --- a/test-tool/test_verify12_dpo.c +++ b/test-tool/test_verify12_dpo.c @@ -66,25 +66,11 @@ test_verify12_dpo(void) logging(LOG_VERBOSE, "Test VERIFY12 with DPO==1"); if (dpofua) { - ret = verify12(sd, 0, block_size, - block_size, 0, 1, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("VERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, buf, + EXPECT_STATUS_GOOD); } else { - ret = verify12(sd, 0, block_size, - block_size, 0, 1, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("VERIFY12 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " diff --git a/test-tool/test_verify12_flags.c b/test-tool/test_verify12_flags.c index 987c3ec..c2f00e6 100644 --- a/test-tool/test_verify12_flags.c +++ b/test-tool/test_verify12_flags.c @@ -43,13 +43,6 @@ test_verify12_flags(void) logging(LOG_VERBOSE, "Test VERIFY12 with BYTCHK==1"); - ret = verify12(sd, 0, block_size, - block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_verify12_mismatch.c b/test-tool/test_verify12_mismatch.c index cdbd54d..8703e6e 100644 --- a/test-tool/test_verify12_mismatch.c +++ b/test-tool/test_verify12_mismatch.c @@ -49,15 +49,8 @@ test_verify12_mismatch(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify12(sd, 0, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_MISCOMPARE); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + EXPECT_MISCOMPARE); } logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN"); @@ -76,9 +69,8 @@ test_verify12_mismatch(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_MISCOMPARE); - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_MISCOMPARE); } } diff --git a/test-tool/test_verify12_mismatch_no_cmp.c b/test-tool/test_verify12_mismatch_no_cmp.c index 1e0c91b..a2d8126 100644 --- a/test-tool/test_verify12_mismatch_no_cmp.c +++ b/test-tool/test_verify12_mismatch_no_cmp.c @@ -49,15 +49,8 @@ test_verify12_mismatch_no_cmp(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify12(sd, 0, i * block_size, - block_size, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK of 1-256 blocks at the end of the LUN"); @@ -76,9 +69,8 @@ test_verify12_mismatch_no_cmp(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify12_simple.c b/test-tool/test_verify12_simple.c index c01b080..64c8824 100644 --- a/test-tool/test_verify12_simple.c +++ b/test-tool/test_verify12_simple.c @@ -44,15 +44,8 @@ test_verify12_simple(void) EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - ret = verify12(sd, 0, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN"); @@ -65,9 +58,8 @@ test_verify12_simple(void) EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - ret = verify12(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + VERIFY12(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify12_vrprotect.c b/test-tool/test_verify12_vrprotect.c index f252676..d68ee43 100644 --- a/test-tool/test_verify12_vrprotect.c +++ b/test-tool/test_verify12_vrprotect.c @@ -45,15 +45,11 @@ test_verify12_vrprotect(void) ret = read10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD); - ret = verify12(sd, 0, block_size, - block_size, i, 0, 1, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test"); - return; - } CU_ASSERT_EQUAL(ret, 0); + + VERIFY12(sd, 0, block_size, + block_size, i, 0, 1, buf, + EXPECT_INVALID_FIELD_IN_CDB); } return; } diff --git a/test-tool/test_verify16_0blocks.c b/test-tool/test_verify16_0blocks.c index b640818..aa056d6 100644 --- a/test-tool/test_verify16_0blocks.c +++ b/test-tool/test_verify16_0blocks.c @@ -27,37 +27,18 @@ void test_verify16_0blocks(void) { - int ret; - logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==0"); - ret = verify16(sd, 0, 0, block_size, - 0, 0, 1, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test VERIFY16 0-blocks one block past end-of-LUN"); - ret = verify16(sd, num_blocks + 1, 0, - block_size, 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + VERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==2^63"); - ret = verify16(sd, 0x8000000000000000ULL, 0, - block_size, 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + VERIFY16(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==-1"); - ret = verify16(sd, -1, 0, block_size, - 0, 0, 1, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, -1, 0, block_size, 0, 0, 1, NULL, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_verify16_beyond_eol.c b/test-tool/test_verify16_beyond_eol.c index f3465e7..72e095c 100644 --- a/test-tool/test_verify16_beyond_eol.c +++ b/test-tool/test_verify16_beyond_eol.c @@ -29,7 +29,7 @@ void test_verify16_beyond_eol(void) { - int i, ret; + int i; unsigned char *buf = alloca(256 * block_size); @@ -40,55 +40,37 @@ test_verify16_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = verify16(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, num_blocks + 1 - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==2^63"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = verify16(sd, 0x8000000000000000ULL, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, 0x8000000000000000ULL, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = verify16(sd, -1, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, -1, i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test VERIFY16 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 = verify16(sd, num_blocks - 1, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_LBA_OOB); - - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, num_blocks - 1, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_verify16_dpo.c b/test-tool/test_verify16_dpo.c index 58a3c98..568ad11 100644 --- a/test-tool/test_verify16_dpo.c +++ b/test-tool/test_verify16_dpo.c @@ -66,25 +66,11 @@ test_verify16_dpo(void) logging(LOG_VERBOSE, "Test VERIFY16 with DPO==1"); if (dpofua) { - ret = verify16(sd, 0, block_size, - block_size, 0, 1, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("VERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, buf, + EXPECT_STATUS_GOOD); } else { - ret = verify16(sd, 0, block_size, - block_size, 0, 1, 0, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("VERIFY16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); } logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " diff --git a/test-tool/test_verify16_flags.c b/test-tool/test_verify16_flags.c index 7a3d8cf..df91fbb 100644 --- a/test-tool/test_verify16_flags.c +++ b/test-tool/test_verify16_flags.c @@ -39,16 +39,9 @@ test_verify16_flags(void) ret = read16(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD); - + CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test VERIFY16 with BYTCHK==1"); - ret = verify16(sd, 0, block_size, - block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_verify16_mismatch.c b/test-tool/test_verify16_mismatch.c index fc28be1..01ceaa7 100644 --- a/test-tool/test_verify16_mismatch.c +++ b/test-tool/test_verify16_mismatch.c @@ -50,15 +50,8 @@ test_verify16_mismatch(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify16(sd, 0, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_MISCOMPARE); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 1, buf, + EXPECT_MISCOMPARE); } logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN"); @@ -78,9 +71,8 @@ test_verify16_mismatch(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_MISCOMPARE); - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_MISCOMPARE); } } diff --git a/test-tool/test_verify16_mismatch_no_cmp.c b/test-tool/test_verify16_mismatch_no_cmp.c index 402cf9a..e6b3df1 100644 --- a/test-tool/test_verify16_mismatch_no_cmp.c +++ b/test-tool/test_verify16_mismatch_no_cmp.c @@ -50,15 +50,8 @@ test_verify16_mismatch_no_cmp(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify16(sd, 0, i * block_size, - block_size, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK of 1-256 blocks at the end of the LUN"); @@ -78,9 +71,8 @@ test_verify16_mismatch_no_cmp(void) buf[offset] ^= 'X'; logging(LOG_VERBOSE, "Flip some bits in the data"); - ret = verify16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify16_simple.c b/test-tool/test_verify16_simple.c index 1dd46be..659f6ee 100644 --- a/test-tool/test_verify16_simple.c +++ b/test-tool/test_verify16_simple.c @@ -42,15 +42,9 @@ test_verify16_simple(void) ret = read10(sd, NULL, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD); - ret = verify16(sd, 0, i * block_size, - block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, 0, i * block_size, + block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN"); @@ -64,9 +58,8 @@ test_verify16_simple(void) EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - ret = verify16(sd, num_blocks - i, - i * block_size, block_size, 0, 0, 1, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + VERIFY16(sd, num_blocks - i, + i * block_size, block_size, 0, 0, 1, buf, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_verify16_vrprotect.c b/test-tool/test_verify16_vrprotect.c index 641bb4e..7676597 100644 --- a/test-tool/test_verify16_vrprotect.c +++ b/test-tool/test_verify16_vrprotect.c @@ -33,7 +33,6 @@ test_verify16_vrprotect(void) int i, ret; unsigned char *buf = alloca(block_size); - logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test VERIFY16 with non-zero VRPROTECT"); @@ -45,15 +44,11 @@ test_verify16_vrprotect(void) ret = read16(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD); - ret = verify16(sd, 0, block_size, - block_size, i, 0, 1, buf, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); - return; - } CU_ASSERT_EQUAL(ret, 0); + + VERIFY16(sd, 0, block_size, + block_size, i, 0, 1, buf, + EXPECT_INVALID_FIELD_IN_CDB); } return; }