TESTS: update reportsupportedopcodes to new api

Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
This commit is contained in:
Ronnie Sahlberg
2014-09-17 18:00:10 -07:00
committed by Ronnie Sahlberg
parent 9be6ddaf09
commit f015ab095a
6 changed files with 52 additions and 100 deletions

View File

@@ -1674,89 +1674,29 @@ release6(struct iscsi_context *iscsi, int lun)
return res;
}
int report_supported_opcodes(struct iscsi_context *iscsi, int lun, int rctd, int options, int opcode, int sa, int alloc_len, struct scsi_task **save_task)
int report_supported_opcodes(struct iscsi_context *iscsi, struct scsi_task **out_task, int lun, int rctd, int options, int opcode, int sa, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
struct scsi_task *task;
int ret;
logging(LOG_VERBOSE, "Send REPORT_SUPPORTED_OPCODE RCTD:%d OPTIONS:%d "
"OPCODE:0x%02x SA:%d ALLOC_LEN:%d",
logging(LOG_VERBOSE, "Send REPORT_SUPPORTED_OPCODE (Expecting %s) "
"RCTD:%d OPTIONS:%d OPCODE:0x%02x SA:%d ALLOC_LEN:%d",
scsi_status_str(status),
rctd, options, opcode, sa, alloc_len);
task = iscsi_report_supported_opcodes_sync(iscsi, lun,
rctd, options, opcode, sa, alloc_len);
if (task == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to send "
"REPORT_SUPPORTED_OPCODES 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) {
logging(LOG_NORMAL, "[SKIPPED] REPORT_SUPPORTED_OPCODES is not "
"implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] REPORT_SUPPORTED_OPCODES "
"command: failed with sense. %s",
iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
task = scsi_cdb_report_supported_opcodes(rctd, options, opcode, sa,
alloc_len);
assert(task != NULL);
if (save_task != NULL) {
*save_task = task;
} else {
task = iscsi_scsi_command_sync(iscsi, lun, task, NULL);
ret = check_result("INQUIRY", iscsi, task, status, key, ascq, num_ascq);
if (out_task) {
*out_task = task;
} else if (task) {
scsi_free_scsi_task(task);
}
logging(LOG_VERBOSE, "[OK] REPORT_SUPPORTED_OPCODES returned SUCCESS.");
return 0;
}
int report_supported_opcodes_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int rctd, int options, int opcode, int sa, int alloc_len, struct scsi_task **save_task)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send REPORT_SUPPORTED_OPCODE (expecting INVALID_FIELD_IN_CDB) RCTD:%d OPTIONS:%d "
"OPCODE:0x%02x SA:%d ALLOC_LEN:%d",
rctd, options, opcode, sa, alloc_len);
task = iscsi_report_supported_opcodes_sync(iscsi, lun,
rctd, options, opcode, sa, alloc_len);
if (task == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to send "
"REPORT_SUPPORTED_OPCODES 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) {
logging(LOG_NORMAL, "[SKIPPED] REPORT_SUPPORTED_OPCODES is not "
"implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
logging(LOG_NORMAL, "[FAILED] REPORT_SUPPORTED_OPCODES should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB. Sense:%s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
if (save_task != NULL) {
*save_task = task;
} else {
scsi_free_scsi_task(task);
}
logging(LOG_VERBOSE, "[OK] REPORT_SUPPORTED_OPCODES returned "
"INVALID_FIELD_IN_CDB.");
return 0;
return ret;
}
int

View File

@@ -265,8 +265,7 @@ int read12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen,
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);
int readcapacity16(struct iscsi_context *iscsi, int lun, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int report_supported_opcodes(struct iscsi_context *iscsi, int lun, int rctd, int options, int opcode, int sa, int alloc_len, struct scsi_task **save_task);
int report_supported_opcodes_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int rctd, int options, int opcode, int sa, int alloc_len, struct scsi_task **save_task);
int report_supported_opcodes(struct iscsi_context *iscsi, struct scsi_task **save_task, int lun, int rctd, int options, int opcode, int sa, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int release6(struct iscsi_context *iscsi, int lun);
int reserve6(struct iscsi_context *iscsi, int lun);
int reserve6_conflict(struct iscsi_context *iscsi, int lun);

View File

@@ -39,9 +39,10 @@ test_report_supported_opcodes_one_command(void)
logging(LOG_VERBOSE, "Fetch list of all supported opcodes");
ret = report_supported_opcodes(iscsic, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535, &rso_task);
ret = report_supported_opcodes(iscsic, &rso_task, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPS_ALL,
0, 0, 65535,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented.");
@@ -67,22 +68,23 @@ test_report_supported_opcodes_one_command(void)
if (rsoc->descriptors[i].servactv) {
logging(LOG_VERBOSE, "This opcode has service actions. "
"Reporting Options 001b should fail");
ret = report_supported_opcodes_invalidfieldincdb(
iscsic, tgt_lun,
ret = report_supported_opcodes(iscsic, NULL, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535, NULL);
65535,
EXPECT_INVALID_FIELD_IN_CDB);
} else {
logging(LOG_VERBOSE, "This opcode does not have "
"service actions. Reporting Options 001b "
"should work");
ret = report_supported_opcodes(
iscsic, tgt_lun,
iscsic, NULL, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535, NULL);
65535,
EXPECT_STATUS_GOOD);
}
CU_ASSERT_EQUAL(ret, 0);
@@ -90,21 +92,23 @@ test_report_supported_opcodes_one_command(void)
logging(LOG_VERBOSE, "This opcode has service actions. "
"Reporting Options 002b should work");
ret = report_supported_opcodes(
iscsic, tgt_lun,
iscsic, NULL, tgt_lun,
0, SCSI_REPORT_SUPPORTING_SERVICEACTION,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535, NULL);
65535,
EXPECT_STATUS_GOOD);
} else {
logging(LOG_VERBOSE, "This opcode does not have "
"service actions. Reporting Options 002b "
"should fail");
ret = report_supported_opcodes_invalidfieldincdb(
iscsic, tgt_lun,
ret = report_supported_opcodes(
iscsic, NULL, tgt_lun,
0, SCSI_REPORT_SUPPORTING_SERVICEACTION,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535, NULL);
65535,
EXPECT_INVALID_FIELD_IN_CDB);
}
CU_ASSERT_EQUAL(ret, 0);
}
@@ -117,14 +121,15 @@ test_report_supported_opcodes_one_command(void)
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa);
ret = report_supported_opcodes(
iscsic, tgt_lun,
iscsic, &one_task, tgt_lun,
0,
rsoc->descriptors[i].servactv ?
SCSI_REPORT_SUPPORTING_SERVICEACTION :
SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535, &one_task);
65535,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
rsoc_one = scsi_datain_unmarshall(one_task);

View File

@@ -38,9 +38,11 @@ test_report_supported_opcodes_rctd(void)
logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
"without timeout descriptors");
ret = report_supported_opcodes(iscsic, tgt_lun,
ret = report_supported_opcodes(
iscsic, &rso_task, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535, &rso_task);
65535,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented.");
@@ -73,9 +75,11 @@ test_report_supported_opcodes_rctd(void)
logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
"with timeout descriptors");
ret = report_supported_opcodes(iscsic, tgt_lun,
ret = report_supported_opcodes(
iscsic, &rso_task, tgt_lun,
1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535, &rso_task);
65535,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) {
return;

View File

@@ -36,9 +36,11 @@ test_report_supported_opcodes_servactv(void)
logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag");
ret = report_supported_opcodes(iscsic, tgt_lun,
ret = report_supported_opcodes(
iscsic, &rso_task, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535, &rso_task);
65535,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented.");

View File

@@ -33,9 +33,11 @@ test_report_supported_opcodes_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test basic READ_SUPPORTED_OPCODES");
ret = report_supported_opcodes(iscsic, tgt_lun,
ret = report_supported_opcodes(
iscsic, NULL, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
1024, NULL);
1024,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented.");