TESTS: update read6 to new api
Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
3ee3964332
commit
1c14b9b911
@@ -1835,90 +1835,30 @@ 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)
|
||||
uint32_t datalen, int blocksize,
|
||||
unsigned char *data,
|
||||
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
int ret;
|
||||
|
||||
logging(LOG_VERBOSE, "Send READ6 LBA:%d blocks:%d",
|
||||
logging(LOG_VERBOSE, "Send READ6 (Expecting %s) LBA:%d blocks:%d",
|
||||
scsi_status_str(status),
|
||||
lba, datalen / blocksize);
|
||||
|
||||
task = iscsi_read6_sync(iscsi, lun, lba, datalen, blocksize);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send READ6 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_CHECK_CONDITION
|
||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
||||
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
|
||||
return -2;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ6 command: "
|
||||
"failed with sense. %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
task = scsi_cdb_read6(lba, datalen, blocksize);
|
||||
assert(task != NULL);
|
||||
|
||||
if (data != NULL) {
|
||||
task = iscsi_scsi_command_sync(iscsi, lun, task, NULL);
|
||||
|
||||
ret = check_result("READ6", iscsi, task, status, key, ascq, num_ascq);
|
||||
if (data) {
|
||||
memcpy(data, task->datain.data, task->datain.size);
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] READ6 returned SUCCESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
read6_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send READ6 (Expecting LBA_OUT_OF_RANGE) "
|
||||
"LBA:%d blocks:%d",
|
||||
lba, datalen / blocksize);
|
||||
|
||||
task = iscsi_read6_sync(iscsi, lun, lba, datalen, blocksize);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send READ6 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_CHECK_CONDITION
|
||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
||||
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
|
||||
if (task) {
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
|
||||
return -2;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ6 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ6 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (data != NULL) {
|
||||
memcpy(data, task->datain.data, task->datain.size);
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] READ6 returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct scsi_task*
|
||||
|
||||
@@ -264,8 +264,7 @@ int orwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen
|
||||
int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||
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 read6_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data);
|
||||
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 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);
|
||||
|
||||
@@ -38,9 +38,9 @@ test_read6_beyond_eol(void)
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end");
|
||||
for (i = 1; i <= 255; i++) {
|
||||
ret = read6_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
|
||||
i * block_size, block_size,
|
||||
NULL);
|
||||
ret = read6(iscsic, tgt_lun, num_blocks + 1 - i,
|
||||
i * block_size, block_size, NULL,
|
||||
EXPECT_LBA_OOB);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
|
||||
CU_PASS("READ6 is not implemented.");
|
||||
@@ -52,18 +52,18 @@ test_read6_beyond_eol(void)
|
||||
|
||||
logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff");
|
||||
for (i = 1; i <= 255; i++) {
|
||||
ret = read6_lbaoutofrange(iscsic, tgt_lun, 0x1fffff,
|
||||
i * block_size, block_size,
|
||||
NULL);
|
||||
ret = read6(iscsic, tgt_lun, 0x1fffff,
|
||||
i * block_size, block_size, NULL,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end");
|
||||
for (i = 2; i <= 255; i++) {
|
||||
ret = read6_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
|
||||
i * block_size, block_size,
|
||||
NULL);
|
||||
ret = read6(iscsic, tgt_lun, num_blocks - 1,
|
||||
i * block_size, block_size, NULL,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ test_read6_simple(void)
|
||||
logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN");
|
||||
for (i = 1; i <= 255; i++) {
|
||||
ret = read6(iscsic, tgt_lun, 0, i * block_size,
|
||||
block_size, NULL);
|
||||
block_size, NULL,
|
||||
EXPECT_STATUS_GOOD);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
|
||||
CU_PASS("READ6 is not implemented.");
|
||||
@@ -51,7 +52,8 @@ test_read6_simple(void)
|
||||
} else {
|
||||
for (i = 1; i <= 255; i++) {
|
||||
ret = read6(iscsic, tgt_lun, num_blocks - i,
|
||||
i * block_size, block_size, NULL);
|
||||
i * block_size, block_size, NULL,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user