Tests: Add helper macros for Verify*

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-02-20 20:00:45 -08:00
parent eba1ac059a
commit b4e4649ae5
25 changed files with 174 additions and 381 deletions

View File

@@ -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; \

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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 "

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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 "

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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 "

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}