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

View File

@@ -209,6 +209,20 @@ do { \
CU_ASSERT_EQUAL(_r, 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(...) \
do { \
int _r; \

View File

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

View File

@@ -29,7 +29,7 @@
void
test_orwrite_beyond_eol(void)
{
int i, ret;
int i;
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -41,15 +41,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
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);
ORWRITE(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -58,11 +52,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(sd, 0x8000000000000000ULL,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, 0x8000000000000000ULL, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -71,11 +63,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(sd, -1,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, -1, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -84,10 +74,8 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(sd, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, num_blocks - 1, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -62,51 +62,29 @@ test_orwrite_dpofua(void)
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1");
memset(scratch, 0xa6, block_size);
if (dpofua) {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 0, 0, 0, scratch,
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);
ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 0, 0, 0, scratch,
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);
ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test ORWRITE with FUA==1");
if (dpofua) {
ret = orwrite(sd, 0, block_size,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
ret = orwrite(sd, 0, block_size,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1");
if (dpofua) {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "

View File

@@ -30,7 +30,7 @@
void
test_orwrite_simple(void)
{
int i, ret;
int i;
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -42,15 +42,9 @@ test_orwrite_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
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);
ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
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) {
break;
}
ret = orwrite(sd, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, num_blocks - i, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -55,15 +55,9 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
memset(buf, 0xa5, block_size * i);
ret = orwrite(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
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);
ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Read %d blocks back", i);
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);
memset(buf, 0x5a, block_size * i);
ret = orwrite(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Read %d blocks back", i);
read10(sd, NULL, 0, i * block_size,
@@ -107,10 +100,9 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
memset(buf, 0xa5, block_size * i);
ret = orwrite(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Read %d blocks back", i);
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);
memset(buf, 0x5a, block_size * i);
ret = orwrite(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
ORWRITE(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read16(sd, NULL, num_blocks - i, i * block_size,

View File

@@ -30,7 +30,7 @@
void
test_orwrite_wrprotect(void)
{
int i, ret;
int i;
/*
* Try out different non-zero values for WRPROTECT.
@@ -45,16 +45,9 @@ test_orwrite_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 = orwrite(sd, 0, block_size,
block_size, i, 0, 0, 0, 0, scratch,
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);
ORWRITE(sd, 0, block_size,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;
}