From 0b5b724f17f679f16d7a3d5868be2abdd36d51ad Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 21 Feb 2016 08:57:26 -0800 Subject: [PATCH] Tests: Add helpers for WRITESAME Signed-off-by: Ronnie Sahlberg --- test-tool/iscsi-support.h | 28 ++++++ test-tool/test_writesame10_0blocks.c | 26 ++---- test-tool/test_writesame10_beyond_eol.c | 36 +++----- test-tool/test_writesame10_simple.c | 20 ++-- test-tool/test_writesame10_unmap.c | 70 ++++++-------- test-tool/test_writesame10_unmap_unaligned.c | 8 +- test-tool/test_writesame10_unmap_until_end.c | 16 ++-- test-tool/test_writesame10_wrprotect.c | 13 +-- test-tool/test_writesame16_0blocks.c | 27 ++---- test-tool/test_writesame16_beyond_eol.c | 37 +++----- test-tool/test_writesame16_simple.c | 21 ++--- test-tool/test_writesame16_unmap.c | 96 +++++++------------- test-tool/test_writesame16_unmap_unaligned.c | 13 +-- test-tool/test_writesame16_unmap_until_end.c | 21 ++--- test-tool/test_writesame16_wrprotect.c | 13 +-- 15 files changed, 169 insertions(+), 276 deletions(-) diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 56748e3..a51c87e 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -294,6 +294,34 @@ do { \ CU_ASSERT_EQUAL(_r, 0); \ } while (0); +#define WRITESAME10(...) \ + do { \ + int _r; \ + _r = writesame10(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "WRITESAME10. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + +#define WRITESAME16(...) \ + do { \ + int _r; \ + _r = writesame16(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "WRITESAME16. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + #define WRITEVERIFY10(...) \ do { \ int _r; \ diff --git a/test-tool/test_writesame10_0blocks.c b/test-tool/test_writesame10_0blocks.c index 20c65df..6783893 100644 --- a/test-tool/test_writesame10_0blocks.c +++ b/test-tool/test_writesame10_0blocks.c @@ -48,11 +48,9 @@ test_writesame10_0blocks(void) memset(scratch, 0, block_size); if (inq_bl->wsnz) { - ret = writesame10(sd, 0, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); + WRITESAME10(sd, 0, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks."); - CU_ASSERT_EQUAL(ret, 0); return; } @@ -71,22 +69,14 @@ test_writesame10_0blocks(void) } logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks one block past end-of-LUN"); - ret = writesame10(sd, num_blocks + 1, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITESAME10(sd, num_blocks + 1, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==2^31"); - ret = writesame10(sd, 0x80000000, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITESAME10(sd, 0x80000000, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==-1"); - ret = writesame10(sd, -1, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, -1, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_writesame10_beyond_eol.c b/test-tool/test_writesame10_beyond_eol.c index 89f7732..757a70b 100644 --- a/test-tool/test_writesame10_beyond_eol.c +++ b/test-tool/test_writesame10_beyond_eol.c @@ -29,7 +29,7 @@ void test_writesame10_beyond_eol(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -43,40 +43,28 @@ test_writesame10_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks one block beyond the end"); memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { - ret = writesame10(sd, num_blocks - i + 1, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - if (ret == -2) { - CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, num_blocks - i + 1, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==2^31"); for (i = 1; i <= 256; i++) { - ret = writesame10(sd, 0x80000000, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, 0x80000000, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { - ret = writesame10(sd, -1, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, -1, block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITESAME10 2-256 blocks all but one block beyond the end"); for (i = 2; i <= 256; i++) { - ret = writesame10(sd, num_blocks - 1, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, num_blocks - 1, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writesame10_simple.c b/test-tool/test_writesame10_simple.c index 3eafeb6..055c49e 100644 --- a/test-tool/test_writesame10_simple.c +++ b/test-tool/test_writesame10_simple.c @@ -30,7 +30,7 @@ void test_writesame10_simple(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -40,22 +40,14 @@ test_writesame10_simple(void) memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { - ret = writesame10(sd, 0, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, 0, block_size, i, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN"); for (i = 1; i <= 256; i++) { - ret = writesame10(sd, num_blocks - i, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, num_blocks - i, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); } - } diff --git a/test-tool/test_writesame10_unmap.c b/test-tool/test_writesame10_unmap.c index d348137..e98b9d8 100644 --- a/test-tool/test_writesame10_unmap.c +++ b/test-tool/test_writesame10_unmap.c @@ -30,7 +30,6 @@ void test_writesame10_unmap(void) { - int ret; unsigned int i; CHECK_FOR_DATALOSS; @@ -51,10 +50,8 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); memset(scratch, 0, block_size); - ret = writesame10(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " @@ -62,10 +59,10 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read10(sd, NULL, 0, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read10(sd, NULL, 0, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " @@ -85,10 +82,9 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); memset(scratch, 0, block_size); - ret = writesame10(sd, num_blocks - i, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, num_blocks - i, + block_size, i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " @@ -96,10 +92,10 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read10(sd, NULL, num_blocks - i, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read10(sd, NULL, num_blocks - i, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " @@ -109,28 +105,20 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Verify that WRITESAME10 ANCHOR==1 + UNMAP==0 is " "invalid"); - ret = writesame10(sd, 0, - block_size, 1, 1, 0, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - CU_ASSERT_EQUAL(ret, 0); - - + WRITESAME10(sd, 0, block_size, 1, 1, 0, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); if (inq_lbp->anc_sup) { logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0"); memset(scratch, 0, block_size); - ret = writesame10(sd, 0, - block_size, 1, 1, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); + WRITESAME10(sd, 0, block_size, 1, 1, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); } else { logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0 no " "ANC_SUP so expecting to fail"); - ret = writesame10(sd, 0, - block_size, 1, 1, 1, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); + WRITESAME10(sd, 0, block_size, 1, 1, 1, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } - CU_ASSERT_EQUAL(ret, 0); - if (inq_bl == NULL) { logging(LOG_VERBOSE, "[FAILED] WRITESAME10 works but " @@ -156,10 +144,8 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); memset(scratch, 0, block_size); - ret = writesame10(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " @@ -167,10 +153,10 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read10(sd, NULL, 0, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read10(sd, NULL, 0, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " @@ -182,9 +168,7 @@ test_writesame10_unmap(void) "INVALID_FIELD_IN_CDB."); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); - ret = writesame10(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } } diff --git a/test-tool/test_writesame10_unmap_unaligned.c b/test-tool/test_writesame10_unmap_unaligned.c index 65ea079..a631885 100644 --- a/test-tool/test_writesame10_unmap_unaligned.c +++ b/test-tool/test_writesame10_unmap_unaligned.c @@ -29,7 +29,7 @@ void test_writesame10_unmap_unaligned(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_THIN_PROVISIONING; @@ -42,9 +42,7 @@ test_writesame10_unmap_unaligned(void) memset(scratch, 0xa6, block_size); for (i = 1; i < lbppb; i++) { logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10 at LBA:%d", lbppb - i, i); - ret = writesame10(sd, i, - block_size, lbppb - i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, i, block_size, lbppb - i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_writesame10_unmap_until_end.c b/test-tool/test_writesame10_unmap_until_end.c index 540971b..51f3637 100644 --- a/test-tool/test_writesame10_unmap_until_end.c +++ b/test-tool/test_writesame10_unmap_until_end.c @@ -29,7 +29,6 @@ void test_writesame10_unmap_until_end(void) { - int ret; unsigned int i; CHECK_FOR_DATALOSS; @@ -53,10 +52,9 @@ test_writesame10_unmap_until_end(void) EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); - ret = writesame10(sd, num_blocks - i, - block_size, 0, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, num_blocks - i, + block_size, 0, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " @@ -64,10 +62,10 @@ test_writesame10_unmap_until_end(void) logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read10(sd, NULL, num_blocks - i, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read10(sd, NULL, num_blocks - i, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " diff --git a/test-tool/test_writesame10_wrprotect.c b/test-tool/test_writesame10_wrprotect.c index bf54f5c..3a7c30b 100644 --- a/test-tool/test_writesame10_wrprotect.c +++ b/test-tool/test_writesame10_wrprotect.c @@ -30,7 +30,7 @@ void test_writesame10_wrprotect(void) { - int i, ret; + int i; /* * Try out different non-zero values for WRPROTECT. @@ -45,15 +45,8 @@ test_writesame10_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 = writesame10(sd, 0, - block_size, 1, 0, 0, i, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 is not implemented."); - CU_PASS("WRITESAME10 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME10(sd, 0, block_size, 1, 0, 0, i, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } return; } diff --git a/test-tool/test_writesame16_0blocks.c b/test-tool/test_writesame16_0blocks.c index d2d7618..28c74c5 100644 --- a/test-tool/test_writesame16_0blocks.c +++ b/test-tool/test_writesame16_0blocks.c @@ -43,11 +43,9 @@ test_writesame16_0blocks(void) memset(scratch, 0, block_size); if (inq_bl->wsnz) { - ret = writesame16(sd, 0, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); + WRITESAME16(sd, 0, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 does not support 0-blocks."); - CU_ASSERT_EQUAL(ret, 0); return; } @@ -66,22 +64,15 @@ test_writesame16_0blocks(void) } logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks one block past end-of-LUN"); - ret = writesame16(sd, num_blocks + 1, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITESAME16(sd, num_blocks + 1, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==2^63"); - ret = writesame16(sd, 0x8000000000000000ULL, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + WRITESAME16(sd, 0x8000000000000000ULL, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==-1"); - ret = writesame16(sd, -1, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, -1, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } diff --git a/test-tool/test_writesame16_beyond_eol.c b/test-tool/test_writesame16_beyond_eol.c index a3fa9a4..82ea042 100644 --- a/test-tool/test_writesame16_beyond_eol.c +++ b/test-tool/test_writesame16_beyond_eol.c @@ -29,7 +29,7 @@ void test_writesame16_beyond_eol(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -38,41 +38,28 @@ test_writesame16_beyond_eol(void) logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks one block beyond the end"); memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { - ret = writesame16(sd, num_blocks - i + 1, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, num_blocks - i + 1, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==2^63"); for (i = 1; i <= 256; i++) { - ret = writesame16(sd, 0x8000000000000000ULL, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0x8000000000000000ULL, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==-1"); for (i = 1; i <= 256; i++) { - ret = writesame16(sd, -1, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, -1, block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } - logging(LOG_VERBOSE, "Test WRITESAME16 2-256 blocks all but one block beyond the end"); for (i = 2; i <= 256; i++) { - ret = writesame16(sd, num_blocks - 1, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, num_blocks - 1, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } } diff --git a/test-tool/test_writesame16_simple.c b/test-tool/test_writesame16_simple.c index 65b3c55..d0cbfab 100644 --- a/test-tool/test_writesame16_simple.c +++ b/test-tool/test_writesame16_simple.c @@ -30,7 +30,7 @@ void test_writesame16_simple(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -40,23 +40,14 @@ test_writesame16_simple(void) memset(scratch, 0, block_size); for (i = 1; i <= 256; i++) { - ret = writesame16(sd, 0, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0, block_size, i, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); } logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN"); for (i = 1; i <= 256; i++) { - ret = writesame16(sd, num_blocks - i, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, num_blocks - i, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); } - } diff --git a/test-tool/test_writesame16_unmap.c b/test-tool/test_writesame16_unmap.c index 05adf46..e510ea3 100644 --- a/test-tool/test_writesame16_unmap.c +++ b/test-tool/test_writesame16_unmap.c @@ -29,7 +29,6 @@ void test_writesame16_unmap(void) { - int ret; unsigned int i; CHECK_FOR_DATALOSS; @@ -48,25 +47,18 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); memset(scratch, 0, block_size); - ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " "blocks back and verify they are all zero"); logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read16(sd, NULL, 0, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read16(sd, NULL, 0, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " @@ -85,20 +77,19 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); memset(scratch, 0, block_size); - ret = writesame16(sd, num_blocks - i, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, num_blocks - i, + block_size, i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " "blocks back and verify they are all zero"); logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read16(sd, NULL, num_blocks - i, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read16(sd, NULL, num_blocks - i, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " @@ -107,29 +98,20 @@ test_writesame16_unmap(void) } logging(LOG_VERBOSE, "Verify that WRITESAME16 ANCHOR==1 + UNMAP==0 is invalid"); - ret = writesame16(sd, 0, - block_size, 1, 1, 0, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - CU_ASSERT_EQUAL(ret, 0); - - + WRITESAME16(sd, 0, block_size, 1, 1, 0, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); if (inq_lbp->anc_sup) { logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0"); memset(scratch, 0, block_size); - ret = writesame16(sd, 0, - block_size, 1, 1, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); + WRITESAME16(sd, 0, block_size, 1, 1, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); } else { logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0 no ANC_SUP so expecting to fail"); - ret = writesame16(sd, 0, - block_size, 1, 1, 1, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); + WRITESAME16(sd, 0, block_size, 1, 1, 1, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } - CU_ASSERT_EQUAL(ret, 0); - - if (inq_bl == NULL) { logging(LOG_VERBOSE, "[FAILED] WRITESAME16 works but " "BlockLimits VPD is missing."); @@ -154,10 +136,8 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); memset(scratch, 0, block_size); - ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " @@ -165,10 +145,10 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read16(sd, NULL, 0, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read16(sd, NULL, 0, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " @@ -180,10 +160,8 @@ test_writesame16_unmap(void) "INVALID_FIELD_IN_CDB."); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); - ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } @@ -203,10 +181,8 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); memset(scratch, 0, block_size); - ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " @@ -214,10 +190,10 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read16(sd, NULL, 0, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read16(sd, NULL, 0, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " @@ -229,9 +205,7 @@ test_writesame16_unmap(void) "INVALID_FIELD_IN_CDB."); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); - ret = writesame16(sd, 0, - block_size, i, 0, 1, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } } diff --git a/test-tool/test_writesame16_unmap_unaligned.c b/test-tool/test_writesame16_unmap_unaligned.c index 8975eca..a94977e 100644 --- a/test-tool/test_writesame16_unmap_unaligned.c +++ b/test-tool/test_writesame16_unmap_unaligned.c @@ -29,7 +29,7 @@ void test_writesame16_unmap_unaligned(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_THIN_PROVISIONING; @@ -42,14 +42,7 @@ test_writesame16_unmap_unaligned(void) for (i = 1; i < lbppb; i++) { logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16 at LBA:%d", lbppb - i, i); - ret = writesame16(sd, i, 0, lbppb - i, - 0, 1, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, i, 0, lbppb - i, 0, 1, 0, 0, NULL, + EXPECT_STATUS_GOOD); } } diff --git a/test-tool/test_writesame16_unmap_until_end.c b/test-tool/test_writesame16_unmap_until_end.c index 32b24ba..c598361 100644 --- a/test-tool/test_writesame16_unmap_until_end.c +++ b/test-tool/test_writesame16_unmap_until_end.c @@ -30,7 +30,6 @@ void test_writesame16_unmap_until_end(void) { - int ret; unsigned int i; CHECK_FOR_DATALOSS; @@ -56,15 +55,9 @@ test_writesame16_unmap_until_end(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); memset(scratch, 0, block_size); - ret = writesame16(sd, num_blocks - i, - block_size, 0, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, num_blocks - i, + block_size, 0, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (rc16->lbprz) { logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped " @@ -72,10 +65,10 @@ test_writesame16_unmap_until_end(void) logging(LOG_VERBOSE, "Read %d blocks and verify they " "are now zero", i); - ret = read16(sd, NULL, num_blocks - i, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); + read16(sd, NULL, num_blocks - i, + i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT(all_zeroes(scratch, i * block_size)); } else { logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " diff --git a/test-tool/test_writesame16_wrprotect.c b/test-tool/test_writesame16_wrprotect.c index f18e0bb..c11796f 100644 --- a/test-tool/test_writesame16_wrprotect.c +++ b/test-tool/test_writesame16_wrprotect.c @@ -30,7 +30,7 @@ void test_writesame16_wrprotect(void) { - int i, ret; + int i; /* * Try out different non-zero values for WRPROTECT. @@ -45,15 +45,8 @@ test_writesame16_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 = writesame16(sd, 0, - block_size, 1, 0, 0, i, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented."); - CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITESAME16(sd, 0, block_size, 1, 0, 0, i, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } return; }