TESTS: update inquiry to new api
Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
398f03205d
commit
9be6ddaf09
@@ -2264,69 +2264,28 @@ writeverify16(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
}
|
||||
|
||||
int
|
||||
inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize, struct scsi_task **save_task)
|
||||
inquiry(struct iscsi_context *iscsi, struct scsi_task **out_task, int lun, int evpd, int page_code, int maxsize, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
int ret;
|
||||
|
||||
logging(LOG_VERBOSE, "Send INQUIRY evpd:%d page_code:%02x alloc_len:%d",
|
||||
logging(LOG_VERBOSE, "Send INQUIRY (Expecting %s) evpd:%d "
|
||||
"page_code:%02x alloc_len:%d",
|
||||
scsi_status_str(status),
|
||||
evpd, page_code, maxsize);
|
||||
task = iscsi_inquiry_sync(iscsi, lun, evpd, page_code, maxsize);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send INQUIRY command: "
|
||||
"%s", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] INQUIRY command: failed with "
|
||||
"sense. %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (save_task != NULL) {
|
||||
*save_task = task;
|
||||
} else {
|
||||
task = scsi_cdb_inquiry(evpd, page_code, maxsize);
|
||||
assert(task != NULL);
|
||||
|
||||
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] INQUIRY returned SUCCESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
inquiry_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send INQUIRY (Expecting INVALID_FIELD_IN_CDB) evpd:%d page_code:%02x alloc_len:%d",
|
||||
evpd, page_code, maxsize);
|
||||
task = iscsi_inquiry_sync(iscsi, lun, evpd, page_code, maxsize);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send INQUIRY command: "
|
||||
"%s", iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] INQUIRY successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
|
||||
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_INVALID_FIELD_IN_CDB) {
|
||||
logging(LOG_NORMAL, "[FAILED] INQUIRY failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"INVALID_FIELD_IN_CDB. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] INQUIRY returned ILLEGAL_REQUEST/INVALID_FIELD_IB_CDB.");
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct scsi_command_descriptor *
|
||||
|
||||
@@ -252,8 +252,7 @@ int verify_read_works(struct iscsi_context *iscsi, int lun, unsigned char *buf);
|
||||
int verify_write_works(struct iscsi_context *iscsi, int lun, unsigned char *buf);
|
||||
int verify_read_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf);
|
||||
int verify_write_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf);
|
||||
int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize, struct scsi_task **save_task);
|
||||
int inquiry_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize);
|
||||
int inquiry(struct iscsi_context *iscsi, struct scsi_task **task, int lun, int evpd, int page_code, int maxsize, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||
int compareandwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||
int get_lba_status(struct iscsi_context *iscsi, struct scsi_task **task, int lun, uint64_t lba, uint32_t len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||
int orwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||
|
||||
@@ -34,14 +34,14 @@ test_inquiry_alloc_length(void)
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test of the INQUIRY allocation length");
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page with alloc length from 5-255");
|
||||
for (i = 5; i < 256 ; i++) {
|
||||
if (task != NULL) {
|
||||
scsi_free_scsi_task(task);
|
||||
task = NULL;
|
||||
}
|
||||
ret = inquiry(iscsic, tgt_lun, 0, 0, i, &task);
|
||||
ret = inquiry(iscsic, &task, tgt_lun, 0, 0, i,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data when reading with alloc length 255");
|
||||
@@ -83,11 +83,13 @@ test_inquiry_alloc_length(void)
|
||||
|
||||
logging(LOG_VERBOSE, "Version is SPC-3 or later. Read INQUIRY data using 16-bit allocation length");
|
||||
logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 511 (low order byte is 0xff)");
|
||||
ret = inquiry(iscsic, tgt_lun, 0, 0, 511, &task);
|
||||
ret = inquiry(iscsic, &task, tgt_lun, 0, 0, 511,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 512 (low order byte is 0x00)");
|
||||
ret = inquiry(iscsic, tgt_lun, 0, 0, 512, &task2);
|
||||
ret = inquiry(iscsic, &task2, tgt_lun, 0, 0, 512,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "INQUIRY data should be the same when allocation length is 511 and 512 bytes");
|
||||
|
||||
@@ -39,9 +39,9 @@ test_inquiry_block_limits(void)
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
logging(LOG_VERBOSE, "Block device. Verify that we can read Block Limits VPD");
|
||||
ret = inquiry(iscsic, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS,
|
||||
64, &bl_task);
|
||||
ret = inquiry(iscsic, &bl_task, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 64,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
if (ret != 0) {
|
||||
logging(LOG_NORMAL, "[FAILURE] failed to send inquiry.");
|
||||
@@ -107,9 +107,9 @@ test_inquiry_block_limits(void)
|
||||
* MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT
|
||||
*/
|
||||
logging(LOG_VERBOSE, "Try reading the logical block provisioning VPD");
|
||||
ret = inquiry(iscsic, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
|
||||
64, &lbp_task);
|
||||
ret = inquiry(iscsic, &lbp_task, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64,
|
||||
EXPECT_STATUS_GOOD);
|
||||
if (ret == 0) {
|
||||
lbp = scsi_datain_unmarshall(lbp_task);
|
||||
if (lbp == NULL) {
|
||||
|
||||
@@ -33,6 +33,7 @@ test_inquiry_evpd(void)
|
||||
logging(LOG_VERBOSE, "Test of the INQUIRY EVPD bit");
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that INQUIRY with EVPD==0 and PC!=0 is an error");
|
||||
ret = inquiry_invalidfieldincdb(iscsic, tgt_lun, 0, 1, 256);
|
||||
ret = inquiry(iscsic, NULL, tgt_lun, 0, 1, 256,
|
||||
EXPECT_INVALID_FIELD_IN_CDB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ test_inquiry_mandatory_vpd_sbc(void)
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "SUPPORTED_VPD_PAGES is mandatory for SBC devices. Verify we can read it.");
|
||||
ret = inquiry(iscsic, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES,
|
||||
255, NULL);
|
||||
ret = inquiry(iscsic, NULL, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "DEVICE_IDENTIFICATION is mandatory for SBC devices. Verify we can read it.");
|
||||
ret = inquiry(iscsic, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION,
|
||||
255, NULL);
|
||||
ret = inquiry(iscsic, NULL, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 255,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ test_inquiry_standard(void)
|
||||
|
||||
logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page");
|
||||
/* 260 bytes is the maximum possible size of the standard vpd */
|
||||
ret = inquiry(iscsic, tgt_lun, 0, 0, 260, &task);
|
||||
ret = inquiry(iscsic, &task, tgt_lun, 0, 0, 260,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data");
|
||||
|
||||
@@ -34,9 +34,9 @@ test_inquiry_supported_vpd(void)
|
||||
logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages");
|
||||
|
||||
logging(LOG_VERBOSE, "Verify we can read the SUPPORTED VPD page");
|
||||
ret = inquiry(iscsic, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES,
|
||||
255, &task);
|
||||
ret = inquiry(iscsic, &task, tgt_lun,
|
||||
1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify we got at least 4 bytes of data");
|
||||
@@ -56,9 +56,8 @@ test_inquiry_supported_vpd(void)
|
||||
logging(LOG_VERBOSE, "Verify we can read page 0x%02x",
|
||||
sup_inq->pages[i]);
|
||||
|
||||
ret = inquiry(iscsic, tgt_lun,
|
||||
1, sup_inq->pages[i],
|
||||
255, NULL);
|
||||
ret = inquiry(iscsic, NULL, tgt_lun, 1, sup_inq->pages[i], 255,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ test_mandatory_sbc(void)
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
logging(LOG_VERBOSE, "Test INQUIRY.");
|
||||
ret = inquiry(iscsic, tgt_lun, 0, 0, 255, NULL);
|
||||
ret = inquiry(iscsic, NULL, tgt_lun, 0, 0, 255,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test READCAPACITY10.");
|
||||
|
||||
@@ -105,7 +105,8 @@ test_sanitize_reset(void)
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that INQUIRY is still allowed while "
|
||||
"SANITIZE is in progress");
|
||||
ret = inquiry(iscsic, tgt_lun, 0, 0, 255, NULL);
|
||||
ret = inquiry(iscsic, NULL, tgt_lun, 0, 0, 255,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user