TESTS: remove the read10_task helper

Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
This commit is contained in:
Ronnie Sahlberg
2014-09-17 15:59:17 -07:00
committed by Ronnie Sahlberg
parent 9e75b10103
commit 832d88797a
25 changed files with 55 additions and 80 deletions

View File

@@ -1497,37 +1497,9 @@ read6(struct iscsi_context *iscsi, int lun, uint32_t lba,
return ret;
}
struct scsi_task*
read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
uint32_t datalen, int blocksize, int rdprotect,
int dpo, int fua, int fua_nv, int group,
unsigned char *data)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send READ10 LBA:%d blocks:%d rdprotect:%d "
"dpo:%d fua:%d fua_nv:%d group:%d",
lba, datalen / blocksize, rdprotect,
dpo, fua, fua_nv, group);
task = iscsi_read10_sync(iscsi, lun, lba, datalen, blocksize,
rdprotect, dpo, fua, fua_nv, group);
if (task == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to send READ10 command: %s",
iscsi_get_error(iscsi));
return NULL;
}
if (data != NULL) {
memcpy(data, task->datain.data, task->datain.size);
}
logging(LOG_VERBOSE, "[OK] READ10 returned SUCCESS.");
return task;
}
int
read10(struct iscsi_context *iscsi, int lun, uint32_t lba,
read10(struct iscsi_context *iscsi, struct scsi_task **out_task,
int lun, uint32_t lba,
uint32_t datalen, int blocksize, int rdprotect,
int dpo, int fua, int fua_nv, int group,
unsigned char *data,
@@ -1552,7 +1524,9 @@ read10(struct iscsi_context *iscsi, int lun, uint32_t lba,
if (data) {
memcpy(data, task->datain.data, task->datain.size);
}
if (task) {
if (out_task) {
*out_task = task;
} else if (task) {
scsi_free_scsi_task(task);
}
return ret;

View File

@@ -260,8 +260,7 @@ int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_block
int prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int preventallow(struct iscsi_context *iscsi, int lun, int prevent);
int read6(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
struct scsi_task *read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int read10(struct iscsi_context *iscsi, struct scsi_task **task, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int read12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int read16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int readcapacity10(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi, int status, enum scsi_sense_key key, int *ascq, int num_ascq);

View File

@@ -53,7 +53,7 @@ test_mandatory_sbc(void)
}
logging(LOG_VERBOSE, "Test READ10.");
ret = read10(iscsic, tgt_lun, 0, block_size, block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -73,7 +73,7 @@ test_nomedia_sbc(void)
}
logging(LOG_VERBOSE, "Test READ10 when medium is ejected.");
ret = read10(iscsic, tgt_lun, 0, block_size, block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -65,7 +65,7 @@ test_orwrite_verify(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -82,7 +82,7 @@ test_orwrite_verify(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -30,7 +30,7 @@ test_read10_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==0");
ret = read10(iscsic, tgt_lun, 0, 0, block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, 0, block_size,
0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -41,21 +41,21 @@ test_read10_0blocks(void)
}
logging(LOG_VERBOSE, "Test READ10 0-blocks one block past end-of-LUN");
ret = read10(iscsic, tgt_lun, num_blocks + 1, 0,
ret = read10(iscsic, NULL, tgt_lun, num_blocks + 1, 0,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==2^31");
ret = read10(iscsic, tgt_lun, 0x80000000, 0, block_size,
ret = read10(iscsic, NULL, tgt_lun, 0x80000000, 0, block_size,
0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==-1");
ret = read10(iscsic, tgt_lun, -1, 0, block_size,
ret = read10(iscsic, NULL, tgt_lun, -1, 0, block_size,
0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -40,7 +40,7 @@ test_read10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks + 1 - i,
ret = read10(iscsic, NULL,tgt_lun, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
@@ -52,7 +52,7 @@ test_read10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0x80000000,
ret = read10(iscsic, NULL, tgt_lun, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
@@ -64,7 +64,7 @@ test_read10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, -1, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
@@ -76,7 +76,7 @@ test_read10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - 1,
ret = read10(iscsic, NULL, tgt_lun, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -36,35 +36,35 @@ test_read10_flags(void)
CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Test READ10 with DPO==1");
ret = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
block_size, block_size, 0, 1, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with FUA==1 FUA_NV==0");
ret = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
block_size, block_size, 0, 0, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with FUA==1 FUA_NV==1");
ret = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
block_size, block_size, 0, 0, 1, 1, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with FUA==0 FUA_NV==1");
ret = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
block_size, block_size, 0, 0, 0, 1, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with DPO==1 FUA==1 FUA_NV==1");
ret = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
block_size, block_size, 0, 1, 1, 1, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -42,7 +42,7 @@ test_read10_rdprotect(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 = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
block_size, block_size,
i, 0, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);

View File

@@ -37,7 +37,7 @@ test_read10_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL,tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -49,7 +49,7 @@ test_read10_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
ret = read10(iscsic, NULL, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -30,11 +30,12 @@
static void
check_wabereq(void)
{
struct scsi_task *task_ret;
struct scsi_task *task_ret = NULL;
logging(LOG_VERBOSE, "Read one block from LBA 0");
task_ret = read10_task(iscsic, tgt_lun, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL);
read10(iscsic, &task_ret, tgt_lun, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);

View File

@@ -30,11 +30,12 @@
static void
check_wacereq(void)
{
struct scsi_task *task_ret;
struct scsi_task *task_ret = NULL;
logging(LOG_VERBOSE, "Read one block from LBA 0");
task_ret = read10_task(iscsic, tgt_lun, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL);
read10(iscsic, &task_ret, tgt_lun, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);

View File

@@ -68,7 +68,7 @@ test_unmap_simple(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read blocks 0-%d", i);
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -102,7 +102,7 @@ test_unmap_simple(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read blocks 0-%d", i);
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -34,7 +34,7 @@ test_verify10_flags(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 flags");
ret = read10(iscsic, tgt_lun, 0, block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -40,7 +40,7 @@ test_verify10_mismatch(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -66,7 +66,7 @@ test_verify10_mismatch(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
ret = read10(iscsic, NULL, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -40,7 +40,7 @@ test_verify10_mismatch_no_cmp(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -67,7 +67,7 @@ test_verify10_mismatch_no_cmp(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
ret = read10(iscsic, NULL, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -38,7 +38,7 @@ test_verify10_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -59,7 +59,7 @@ test_verify10_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
ret = read10(iscsic, NULL, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -40,7 +40,7 @@ test_verify10_vrprotect(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 = read10(iscsic, tgt_lun, 0, block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -38,7 +38,7 @@ test_verify12_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -41,7 +41,7 @@ test_verify12_vrprotect(void)
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = read10(iscsic, tgt_lun, 0, block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
ret = verify12(iscsic, tgt_lun, 0, block_size,

View File

@@ -38,7 +38,7 @@ test_verify16_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
ret = verify16(iscsic, tgt_lun, 0, i * block_size,

View File

@@ -289,7 +289,7 @@ test_write10_residuals(void)
task = NULL;
logging(LOG_VERBOSE, "Read the two blocks");
ret = read10(iscsic, tgt_lun, 0, 2* block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, 2* block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -365,7 +365,7 @@ test_write10_residuals(void)
task = NULL;
logging(LOG_VERBOSE, "Read the two blocks");
ret = read10(iscsic, tgt_lun, 0, 2* block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, 2* block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -62,7 +62,7 @@ test_writesame10_unmap(void)
logging(LOG_VERBOSE, "Read %d blocks and verify they "
"are now zero", i);
ret = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
@@ -101,7 +101,7 @@ test_writesame10_unmap(void)
logging(LOG_VERBOSE, "Read %d blocks and verify they "
"are now zero", i);
ret = read10(iscsic, tgt_lun, num_blocks - i,
ret = read10(iscsic, NULL, tgt_lun, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
@@ -177,7 +177,7 @@ test_writesame10_unmap(void)
logging(LOG_VERBOSE, "Read %d blocks and verify they "
"are now zero", i);
ret = read10(iscsic, tgt_lun, 0,
ret = read10(iscsic, NULL, tgt_lun, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);

View File

@@ -64,7 +64,7 @@ test_writesame10_unmap_until_end(void)
logging(LOG_VERBOSE, "Read %d blocks and verify they "
"are now zero", i);
ret = read10(iscsic, tgt_lun, num_blocks - i,
ret = read10(iscsic, NULL, tgt_lun, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);

View File

@@ -294,7 +294,7 @@ test_writeverify10_residuals(void)
task = NULL;
logging(LOG_VERBOSE, "Read the two blocks");
ret = read10(iscsic, tgt_lun, 0, 2* block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, 2* block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -370,7 +370,7 @@ test_writeverify10_residuals(void)
task = NULL;
logging(LOG_VERBOSE, "Read the two blocks");
ret = read10(iscsic, tgt_lun, 0, 2* block_size,
ret = read10(iscsic, NULL, tgt_lun, 0, 2* block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);