test-tool: Change write residuals tests overwrite check according to FCP-4
According to FCP-4 there are several possibilities for target to react on incorrect data length field value in CDB: a) process the command normally except that data beyond the FCP_DL count shall not be requested or transferred; b) transfer no data and return CHECK CONDITION status with the sense key set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD IN COMMAND INFORMATION UNIT; Add check to support the second one and accept no data write.
This commit is contained in:
@@ -36,6 +36,7 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
struct iscsi_data data;
|
||||
struct scsi_task *task_ret;
|
||||
int ok;
|
||||
int scsi_status;
|
||||
unsigned int xfer_len_byte = 8;
|
||||
unsigned int i;
|
||||
unsigned int scsi_opcode_write = SCSI_OPCODE_WRITE10;
|
||||
@@ -105,11 +106,14 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] WRITE%zu is not implemented.", tdata->cdb_size);
|
||||
command_is_implemented = false;
|
||||
scsi_free_scsi_task(task);
|
||||
task = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that target returns SUCCESS or INVALID "
|
||||
"FIELD IN INFORMATION UNIT");
|
||||
scsi_status = task->status;
|
||||
ok = task->status == SCSI_STATUS_GOOD ||
|
||||
(task->status == SCSI_STATUS_CHECK_CONDITION &&
|
||||
task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
|
||||
@@ -158,6 +162,26 @@ write_residuals_test(const struct residuals_test_data *tdata)
|
||||
break;
|
||||
}
|
||||
|
||||
/* According to FCP target could transfer no data and return
|
||||
CHECK CONDITION status with the sense key set to
|
||||
ILLEGAL REQUEST and the additional sense code set to
|
||||
INVALID FIELD IN COMMAND INFORMATION UNIT; this check prevent
|
||||
false assert*/
|
||||
|
||||
if (scsi_status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_VERBOSE, "Verify that blocks were NOT "
|
||||
"overwritten and still contain 'a'");
|
||||
for (i = 0; i < 2 * block_size; i++) {
|
||||
if (scratch[i] != 'a') {
|
||||
logging(LOG_NORMAL, "Blocks were overwritten "
|
||||
"and no longer contain 'a'");
|
||||
CU_FAIL("Blocks were incorrectly overwritten");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
|
||||
for (i = 0; i < block_size; i++) {
|
||||
if (scratch[i] != 'b') {
|
||||
|
||||
Reference in New Issue
Block a user