Tests: helpers for READ6
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -223,6 +223,20 @@ do { \
|
|||||||
CU_ASSERT_EQUAL(_r, 0); \
|
CU_ASSERT_EQUAL(_r, 0); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
#define READ6(...) \
|
||||||
|
do { \
|
||||||
|
int _r; \
|
||||||
|
_r = read6(__VA_ARGS__); \
|
||||||
|
if (_r == -2) { \
|
||||||
|
logging(LOG_NORMAL, "[SKIPPED] READ6 " \
|
||||||
|
"is not implemented."); \
|
||||||
|
CU_PASS("[SKIPPED] Target does not support " \
|
||||||
|
"READ6. Skipping test"); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
CU_ASSERT_EQUAL(_r, 0); \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
#define READ10(...) \
|
#define READ10(...) \
|
||||||
do { \
|
do { \
|
||||||
int _r; \
|
int _r; \
|
||||||
|
|||||||
@@ -28,35 +28,25 @@
|
|||||||
void
|
void
|
||||||
test_read6_beyond_eol(void)
|
test_read6_beyond_eol(void)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i;
|
||||||
|
|
||||||
if (num_blocks > 0x1fffff) {
|
if (num_blocks > 0x1fffff) {
|
||||||
CU_PASS("LUN is too big for read-beyond-eol tests with READ6. Skipping test.\n");
|
CU_PASS("LUN is too big for read-beyond-eol tests with READ6. Skipping test.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end");
|
logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end");
|
||||||
for (i = 1; i <= 255 && i + 0U <= num_blocks + 1; i++) {
|
for (i = 1; i <= 255 && i + 0U <= num_blocks + 1; i++) {
|
||||||
ret = read6(sd, NULL, num_blocks + 1 - i,
|
READ6(sd, NULL, num_blocks + 1 - i,
|
||||||
i * block_size, block_size, NULL,
|
i * block_size, block_size, NULL,
|
||||||
EXPECT_LBA_OOB);
|
EXPECT_LBA_OOB);
|
||||||
if (ret == -2) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
|
|
||||||
CU_PASS("READ6 is not implemented.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff");
|
logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff");
|
||||||
for (i = 1; i <= 255; i++) {
|
for (i = 1; i <= 255; i++) {
|
||||||
ret = read6(sd, NULL, 0x1fffff,
|
READ6(sd, NULL, 0x1fffff, i * block_size, block_size, NULL,
|
||||||
i * block_size, block_size, NULL,
|
EXPECT_LBA_OOB);
|
||||||
EXPECT_LBA_OOB);
|
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_blocks == 0) {
|
if (num_blocks == 0) {
|
||||||
@@ -66,9 +56,8 @@ test_read6_beyond_eol(void)
|
|||||||
|
|
||||||
logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end");
|
logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end");
|
||||||
for (i = 2; i <= 255; i++) {
|
for (i = 2; i <= 255; i++) {
|
||||||
ret = read6(sd, NULL, num_blocks - 1,
|
READ6(sd, NULL, num_blocks - 1,
|
||||||
i * block_size, block_size, NULL,
|
i * block_size, block_size, NULL,
|
||||||
EXPECT_LBA_OOB);
|
EXPECT_LBA_OOB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,7 @@
|
|||||||
void
|
void
|
||||||
test_read6_simple(void)
|
test_read6_simple(void)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN");
|
logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN");
|
||||||
@@ -38,19 +37,10 @@ test_read6_simple(void)
|
|||||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
READ6(sd, NULL, 0, i * block_size, block_size, NULL,
|
||||||
ret = read6(sd, NULL, 0, i * block_size,
|
EXPECT_STATUS_GOOD);
|
||||||
block_size, NULL,
|
|
||||||
EXPECT_STATUS_GOOD);
|
|
||||||
if (ret == -2) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
|
|
||||||
CU_PASS("READ6 is not implemented.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the end of the LUN");
|
logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the end of the LUN");
|
||||||
if (num_blocks > 0x200000) {
|
if (num_blocks > 0x200000) {
|
||||||
CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n");
|
CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n");
|
||||||
@@ -59,22 +49,19 @@ test_read6_simple(void)
|
|||||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
READ6(sd, NULL, num_blocks - i,
|
||||||
ret = read6(sd, NULL, num_blocks - i,
|
i * block_size, block_size, NULL,
|
||||||
i * block_size, block_size, NULL,
|
EXPECT_STATUS_GOOD);
|
||||||
EXPECT_STATUS_GOOD);
|
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 256 is converted to 0 when the CDB is marshalled by the helper */
|
/* 256 is converted to 0 when the CDB is marshalled by the helper */
|
||||||
if (maximum_transfer_length >= 256) {
|
if (maximum_transfer_length >= 256) {
|
||||||
logging(LOG_VERBOSE, "Transfer length == 0 means we want to "
|
logging(LOG_VERBOSE, "Transfer length == 0 means we want to "
|
||||||
"transfer 256 blocks");
|
"transfer 256 blocks");
|
||||||
ret = read6(sd, &task, 0,
|
READ6(sd, &task, 0,
|
||||||
256 * block_size, block_size, NULL,
|
256 * block_size, block_size, NULL,
|
||||||
EXPECT_STATUS_GOOD);
|
EXPECT_STATUS_GOOD);
|
||||||
if (task->status != SCSI_STATUS_GOOD) {
|
if (task->status != SCSI_STATUS_GOOD) {
|
||||||
logging(LOG_NORMAL, "[FAILED] READ6 command: "
|
logging(LOG_NORMAL, "[FAILED] READ6 command: "
|
||||||
"failed with sense. %s", sd->error_str );
|
"failed with sense. %s", sd->error_str );
|
||||||
|
|||||||
Reference in New Issue
Block a user