Tests: Add helpers for ORWRITE

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-02-21 10:11:45 -08:00
parent 69f4dc76ca
commit 0a814db48f
7 changed files with 70 additions and 132 deletions
+14
View File
@@ -209,6 +209,20 @@ do { \
CU_ASSERT_EQUAL(_r, 0); \ CU_ASSERT_EQUAL(_r, 0); \
} while (0); } while (0);
#define ORWRITE(...) \
do { \
int _r; \
_r = orwrite(__VA_ARGS__); \
if (_r == -2) { \
logging(LOG_NORMAL, "[SKIPPED] ORWRITE " \
"is not implemented."); \
CU_PASS("[SKIPPED] Target does not support " \
"ORWRITE. Skipping test"); \
return; \
} \
CU_ASSERT_EQUAL(_r, 0); \
} while (0);
#define RECEIVE_COPY_RESULTS(...) \ #define RECEIVE_COPY_RESULTS(...) \
do { \ do { \
int _r; \ int _r; \
+8 -25
View File
@@ -27,40 +27,23 @@
void void
test_orwrite_0blocks(void) test_orwrite_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 ORWRITE 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==0");
ret = orwrite(sd, 0, ORWRITE(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, block_size, 0, 0, 0, 0, 0, NULL, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks one block past end-of-LUN");
ret = orwrite(sd, num_blocks + 1, ORWRITE(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, block_size, 0, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==2^63");
ret = orwrite(sd, 0x8000000000000000ULL, ORWRITE(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, block_size, 0, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==-1");
ret = orwrite(sd, -1, ORWRITE(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, block_size, 0, 0, 0, 0, 0, NULL, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
+13 -25
View File
@@ -29,7 +29,7 @@
void void
test_orwrite_beyond_eol(void) test_orwrite_beyond_eol(void)
{ {
int i, ret; int i;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
CHECK_FOR_SBC; CHECK_FOR_SBC;
@@ -41,15 +41,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(sd, num_blocks + 1 - i, ORWRITE(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch, i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB); EXPECT_LBA_OOB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
} }
@@ -58,11 +52,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(sd, 0x8000000000000000ULL, ORWRITE(sd, 0x8000000000000000ULL, i * block_size, block_size,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
@@ -71,11 +63,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(sd, -1, ORWRITE(sd, -1, i * block_size, block_size,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
@@ -84,10 +74,8 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(sd, num_blocks - 1, ORWRITE(sd, num_blocks - 1, i * block_size, block_size,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
0, 0, 0, 0, 0, scratch, EXPECT_LBA_OOB);
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
} }
} }
+12 -34
View File
@@ -62,51 +62,29 @@ test_orwrite_dpofua(void)
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1"); logging(LOG_VERBOSE, "Test ORWRITE with DPO==1");
memset(scratch, 0xa6, block_size); memset(scratch, 0xa6, block_size);
if (dpofua) { if (dpofua) {
ret = orwrite(sd, 0, block_size, ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
block_size, 0, 1, 0, 0, 0, scratch, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
} else { } else {
ret = orwrite(sd, 0, block_size, ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
block_size, 0, 1, 0, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB);
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test ORWRITE with FUA==1"); logging(LOG_VERBOSE, "Test ORWRITE with FUA==1");
if (dpofua) { if (dpofua) {
ret = orwrite(sd, 0, block_size, ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
block_size, 0, 0, 1, 0, 0, scratch, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else { } else {
ret = orwrite(sd, 0, block_size, ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
block_size, 0, 0, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB);
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1"); logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1");
if (dpofua) { if (dpofua) {
ret = orwrite(sd, 0, block_size, ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
block_size, 0, 1, 1, 0, 0, scratch, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else { } else {
ret = orwrite(sd, 0, block_size, ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
block_size, 0, 1, 1, 0, 0, scratch, EXPECT_INVALID_FIELD_IN_CDB);
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+7 -16
View File
@@ -30,7 +30,7 @@
void void
test_orwrite_simple(void) test_orwrite_simple(void)
{ {
int i, ret; int i;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
CHECK_FOR_SBC; CHECK_FOR_SBC;
@@ -42,15 +42,9 @@ test_orwrite_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(sd, 0, i * block_size, ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN"); logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN");
@@ -58,11 +52,8 @@ test_orwrite_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(sd, num_blocks - i, ORWRITE(sd, num_blocks - i, i * block_size, block_size,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
} }
+12 -21
View File
@@ -55,15 +55,9 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
memset(buf, 0xa5, block_size * i); memset(buf, 0xa5, block_size * i);
ret = orwrite(sd, 0, i * block_size, ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read10(sd, NULL, 0, i * block_size, ret = read10(sd, NULL, 0, i * block_size,
@@ -77,10 +71,9 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
memset(buf, 0x5a, block_size * i); memset(buf, 0x5a, block_size * i);
ret = orwrite(sd, 0, i * block_size, ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
read10(sd, NULL, 0, i * block_size, read10(sd, NULL, 0, i * block_size,
@@ -107,10 +100,9 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
memset(buf, 0xa5, block_size * i); memset(buf, 0xa5, block_size * i);
ret = orwrite(sd, num_blocks - i, i * block_size, ORWRITE(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read16(sd, NULL, num_blocks - i, i * block_size, ret = read16(sd, NULL, num_blocks - i, i * block_size,
@@ -124,10 +116,9 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
memset(buf, 0x5a, block_size * i); memset(buf, 0x5a, block_size * i);
ret = orwrite(sd, num_blocks - i, i * block_size, ORWRITE(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read16(sd, NULL, num_blocks - i, i * block_size, ret = read16(sd, NULL, num_blocks - i, i * block_size,
+4 -11
View File
@@ -30,7 +30,7 @@
void void
test_orwrite_wrprotect(void) test_orwrite_wrprotect(void)
{ {
int i, ret; int i;
/* /*
* Try out different non-zero values for WRPROTECT. * Try out different non-zero values for WRPROTECT.
@@ -45,16 +45,9 @@ test_orwrite_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 = orwrite(sd, 0, block_size, ORWRITE(sd, 0, block_size,
block_size, i, 0, 0, 0, 0, scratch, block_size, i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
} }
return; return;
} }