Tests: Create helper macros for the WriteVerify* commands

By creating a helper macros for WriteVerify we can save a lot of boilerplate
code.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-02-20 19:05:15 -08:00
parent 72cfdbb5f1
commit bd29dab95b
22 changed files with 169 additions and 341 deletions

View File

@@ -181,6 +181,48 @@ do { \
} \ } \
} while (0); } 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_standard *inq;
extern struct scsi_inquiry_logical_block_provisioning *inq_lbp; extern struct scsi_inquiry_logical_block_provisioning *inq_lbp;
extern struct scsi_inquiry_block_device_characteristics *inq_bdc; extern struct scsi_inquiry_block_device_characteristics *inq_bdc;

View File

@@ -27,8 +27,6 @@
void void
test_writeverify10_0blocks(void) test_writeverify10_0blocks(void)
{ {
int ret;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
if (num_blocks >= 0x80000000) { if (num_blocks >= 0x80000000) {
@@ -38,33 +36,18 @@ test_writeverify10_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==0");
ret = writeverify10(sd, 0, 0, block_size, WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
0, 0, 0, 0, NULL, EXPECT_STATUS_GOOD);
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);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks one block past end-of-LUN");
ret = writeverify10(sd, num_blocks + 1, 0, WRITEVERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
block_size, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==2^31");
ret = writeverify10(sd, 0x80000000, 0, WRITEVERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL,
block_size, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==-1");
ret = writeverify10(sd, -1, 0, block_size, WRITEVERIFY10(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -29,7 +29,7 @@
void void
test_writeverify10_beyond_eol(void) test_writeverify10_beyond_eol(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(256 * block_size); unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -46,50 +46,38 @@ test_writeverify10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify10(sd, num_blocks + 1 - i, WRITEVERIFY10(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); 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);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify10(sd, 0x80000000, WRITEVERIFY10(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==-1"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify10(sd, -1, i * block_size, WRITEVERIFY10(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY10 2-256 blocks all but one block beyond the end"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) { for (i = 2; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify10(sd, num_blocks - 1, WRITEVERIFY10(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -66,25 +66,13 @@ test_writeverify10_dpo(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1");
if (dpofua) { if (dpofua) {
ret = writeverify10(sd, 0, block_size, WRITEVERIFY10(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf, block_size, 0, 1, 0, 0, buf,
EXPECT_STATUS_GOOD); 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);
} else { } else {
ret = writeverify10(sd, 0, block_size, WRITEVERIFY10(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf, block_size, 0, 1, 0, 0, buf,
EXPECT_INVALID_FIELD_IN_CDB); 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);
} }
logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "

View File

@@ -30,7 +30,6 @@
void void
test_writeverify10_flags(void) test_writeverify10_flags(void)
{ {
int ret;
unsigned char *buf = alloca(block_size); unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -41,13 +40,6 @@ test_writeverify10_flags(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1");
memset(buf, 0xa6, block_size); memset(buf, 0xa6, block_size);
ret = writeverify10(sd, 0, WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, buf,
block_size, block_size, 0, 0, 1, 0, buf, EXPECT_STATUS_GOOD);
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);
} }

View File

@@ -53,13 +53,8 @@ test_writeverify10_residuals(void)
} }
/* check if writeverify10 is supported */ /* check if writeverify10 is supported */
ret = writeverify10(sd, 0, 0, WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
block_size, 0, 0, 0, 0, NULL, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support WRITEVERIFY10. Skipping test");
return;
}
/* Try a writeverify10 of 1 block but xferlength == 0 */ /* Try a writeverify10 of 1 block but xferlength == 0 */
task = malloc(sizeof(struct scsi_task)); task = malloc(sizeof(struct scsi_task));

View File

@@ -30,7 +30,7 @@
void void
test_writeverify10_simple(void) test_writeverify10_simple(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(256 * block_size); unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -42,15 +42,9 @@ test_writeverify10_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify10(sd, 0, i * block_size, WRITEVERIFY10(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); 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);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the end of the LUN"); 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) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify10(sd, num_blocks - i, WRITEVERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -30,7 +30,7 @@
void void
test_writeverify10_wrprotect(void) test_writeverify10_wrprotect(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(block_size); unsigned char *buf = alloca(block_size);
/* /*
@@ -46,16 +46,9 @@ test_writeverify10_wrprotect(void)
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
ret = writeverify10(sd, 0, WRITEVERIFY10(sd, 0, block_size, block_size,
block_size, block_size, i, 0, 0, 0, buf,
i, 0, 0, 0, buf, EXPECT_INVALID_FIELD_IN_CDB);
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);
} }
return; return;
} }

View File

@@ -27,8 +27,6 @@
void void
test_writeverify12_0blocks(void) test_writeverify12_0blocks(void)
{ {
int ret;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
if (num_blocks >= 0x80000000) { if (num_blocks >= 0x80000000) {
@@ -38,33 +36,18 @@ test_writeverify12_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==0");
ret = writeverify12(sd, 0, 0, block_size, WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
0, 0, 0, 0, NULL, EXPECT_STATUS_GOOD);
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);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks one block past end-of-LUN");
ret = writeverify12(sd, num_blocks + 1, 0, WRITEVERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
block_size, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==2^31");
ret = writeverify12(sd, 0x80000000, 0, WRITEVERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL,
block_size, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==-1");
ret = writeverify12(sd, -1, 0, block_size, WRITEVERIFY12(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -29,7 +29,7 @@
void void
test_writeverify12_beyond_eol(void) test_writeverify12_beyond_eol(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(256 * block_size); unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -46,50 +46,38 @@ test_writeverify12_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify12(sd, num_blocks + 1 - i, WRITEVERIFY12(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); 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);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify12(sd, 0x80000000, WRITEVERIFY12(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==-1"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify12(sd, -1, i * block_size, WRITEVERIFY12(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY12 2-256 blocks all but one block beyond the end"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) { for (i = 2; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify12(sd, num_blocks - 1, WRITEVERIFY12(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -66,25 +66,13 @@ test_writeverify12_dpo(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1");
if (dpofua) { if (dpofua) {
ret = writeverify12(sd, 0, block_size, WRITEVERIFY12(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf, block_size, 0, 1, 0, 0, buf,
EXPECT_STATUS_GOOD); 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);
} else { } else {
ret = writeverify12(sd, 0, block_size, WRITEVERIFY12(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf, block_size, 0, 1, 0, 0, buf,
EXPECT_INVALID_FIELD_IN_CDB); 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);
} }
logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "

View File

@@ -30,7 +30,6 @@
void void
test_writeverify12_flags(void) test_writeverify12_flags(void)
{ {
int ret;
unsigned char *buf = alloca(block_size); unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -41,13 +40,6 @@ test_writeverify12_flags(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1");
memset(buf, 0xa6, block_size); memset(buf, 0xa6, block_size);
ret = writeverify12(sd, 0, WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, buf,
block_size, block_size, 0, 0, 1, 0, buf, EXPECT_STATUS_GOOD);
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);
} }

View File

@@ -53,13 +53,8 @@ test_writeverify12_residuals(void)
} }
/* check if writeverify12 is supported */ /* check if writeverify12 is supported */
ret = writeverify12(sd, 0, 0, WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
block_size, 0, 0, 0, 0, NULL, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support WRITEVERIFY12. Skipping test");
return;
}
/* Try a writeverify12 of 1 block but xferlength == 0 */ /* Try a writeverify12 of 1 block but xferlength == 0 */
task = malloc(sizeof(struct scsi_task)); task = malloc(sizeof(struct scsi_task));

View File

@@ -30,7 +30,7 @@
void void
test_writeverify12_simple(void) test_writeverify12_simple(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(256 * block_size); unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -42,15 +42,9 @@ test_writeverify12_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify12(sd, 0, i * block_size, WRITEVERIFY12(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); 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);
} }
logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN"); 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) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = writeverify12(sd, num_blocks - i, WRITEVERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf, i * block_size, block_size, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -30,7 +30,7 @@
void void
test_writeverify12_wrprotect(void) test_writeverify12_wrprotect(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(block_size); unsigned char *buf = alloca(block_size);
/* /*
@@ -46,16 +46,9 @@ test_writeverify12_wrprotect(void)
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
ret = writeverify12(sd, 0, WRITEVERIFY12(sd, 0, block_size, block_size,
block_size, block_size, i, 0, 0, 0, buf,
i, 0, 0, 0, buf, EXPECT_INVALID_FIELD_IN_CDB);
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);
} }
return; return;
} }

View File

@@ -27,40 +27,24 @@
void void
test_writeverify16_0blocks(void) test_writeverify16_0blocks(void)
{ {
int ret;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
CHECK_FOR_SBC; CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==0");
ret = writeverify16(sd, 0, WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
0, block_size, 0, 0, 0, 0, NULL, EXPECT_STATUS_GOOD);
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);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks one block past end-of-LUN");
ret = writeverify16(sd, num_blocks + 1, WRITEVERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
0, block_size, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==2^63");
ret = writeverify16(sd, 0x8000000000000000ULL, WRITEVERIFY16(sd, 0x8000000000000000ULL,
0, block_size, 0, 0, 0, 0, NULL, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==-1");
ret = writeverify16(sd, -1, WRITEVERIFY16(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
0, block_size, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -29,7 +29,7 @@
void void
test_writeverify16_beyond_eol(void) test_writeverify16_beyond_eol(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(256 * block_size); unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -42,54 +42,38 @@ test_writeverify16_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
WRITEVERIFY16(sd, num_blocks + 1 - i,
ret = writeverify16(sd, num_blocks + 1 - i, i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, buf, EXPECT_LBA_OOB);
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);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
WRITEVERIFY16(sd, 0x8000000000000000ULL,
ret = writeverify16(sd, 0x8000000000000000ULL, i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, buf, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==-1"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
WRITEVERIFY16(sd, -1,
ret = writeverify16(sd, -1, i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, buf, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY16 2-256 blocks all but one block beyond the end"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) { for (i = 2; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
WRITEVERIFY16(sd, num_blocks - 1,
ret = writeverify16(sd, num_blocks - 1, i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, buf, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -67,25 +67,13 @@ test_writeverify16_dpo(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1");
memset(buf, 0xa6, block_size); memset(buf, 0xa6, block_size);
if (dpofua) { if (dpofua) {
ret = writeverify16(sd, 0, block_size, WRITEVERIFY16(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf, block_size, 0, 1, 0, 0, buf,
EXPECT_STATUS_GOOD); 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);
} else { } else {
ret = writeverify16(sd, 0, block_size, WRITEVERIFY16(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf, block_size, 0, 1, 0, 0, buf,
EXPECT_INVALID_FIELD_IN_CDB); 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);
} }

View File

@@ -30,7 +30,6 @@
void void
test_writeverify16_flags(void) test_writeverify16_flags(void)
{ {
int ret;
unsigned char *buf = alloca(block_size); unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -41,13 +40,6 @@ test_writeverify16_flags(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1");
memset(buf, 0xa6, block_size); memset(buf, 0xa6, block_size);
ret = writeverify16(sd, 0, WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, buf,
block_size, block_size, 0, 0, 1, 0, buf, EXPECT_STATUS_GOOD);
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);
} }

View File

@@ -53,14 +53,8 @@ test_writeverify16_residuals(void)
} }
/* check if writeverify16 is supported */ /* check if writeverify16 is supported */
ret = writeverify16(sd, 0, 0, WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
block_size, 0, 0, 0, 0, NULL, EXPECT_STATUS_GOOD);
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;
}
if (sd->iscsi_ctx == NULL) { if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] WRITEVERIFY16 tests are only " const char *err = "[SKIPPED] WRITEVERIFY16 tests are only "

View File

@@ -30,7 +30,7 @@
void void
test_writeverify16_simple(void) test_writeverify16_simple(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(256 * block_size); unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
@@ -43,16 +43,9 @@ test_writeverify16_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
WRITEVERIFY16(sd, 0, i * block_size,
ret = writeverify16(sd, 0, i * block_size, block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD);
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);
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the end of the LUN"); 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) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
WRITEVERIFY16(sd, num_blocks - i,
ret = writeverify16(sd, num_blocks - i, i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -31,10 +31,9 @@
void void
test_writeverify16_wrprotect(void) test_writeverify16_wrprotect(void)
{ {
int i, ret; int i;
unsigned char *buf = alloca(block_size); unsigned char *buf = alloca(block_size);
/* /*
* Try out different non-zero values for WRPROTECT. * Try out different non-zero values for WRPROTECT.
*/ */
@@ -48,16 +47,9 @@ test_writeverify16_wrprotect(void)
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
ret = writeverify16(sd, 0, WRITEVERIFY16(sd, 0, block_size, block_size,
block_size, block_size, i, 0, 0, 0, buf,
i, 0, 0, 0, buf, EXPECT_INVALID_FIELD_IN_CDB);
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);
} }
return; return;
} }