TESTS update all read16 tests to fail/skip on illegal opcode depending on whether the device claims support for it or not (mandatory in sbc-3, optional prior)
This commit is contained in:
@@ -2226,6 +2226,18 @@ read16(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
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);
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 is not available but the device claims SBC-3 support.");
|
||||
return -1;
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented and SBC-3 is not claimed.");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 command: "
|
||||
"failed with sense. %s", iscsi_get_error(iscsi));
|
||||
@@ -2263,6 +2275,18 @@ read16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
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);
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 is not available but the device claims SBC-3 support.");
|
||||
return -1;
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented and SBC-3 is not claimed.");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
|
||||
@@ -2310,6 +2334,18 @@ read16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
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);
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 is not available but the device claims SBC-3 support.");
|
||||
return -1;
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented and SBC-3 is not claimed.");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE");
|
||||
@@ -2356,6 +2392,18 @@ read16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba,
|
||||
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);
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 is not available but the device claims SBC-3 support.");
|
||||
return -1;
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented and SBC-3 is not claimed.");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READ16 successful but should "
|
||||
"have failed with NOT_READY/MEDIUM_NOT_PRESENT*");
|
||||
@@ -2469,9 +2517,14 @@ readcapacity16(struct iscsi_context *iscsi, int lun, int alloc_len)
|
||||
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] READCAPACITY16 is not implemented on target");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support.");
|
||||
return -1;
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented and SBC-3 is not claimed.");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 command: "
|
||||
@@ -2508,9 +2561,14 @@ readcapacity16_nomedium(struct iscsi_context *iscsi, int lun, int alloc_len)
|
||||
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] READCAPACITY16 is not implemented on target");
|
||||
scsi_free_scsi_task(task);
|
||||
return -2;
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support.");
|
||||
return -1;
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented and SBC-3 is not claimed.");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 command successful. But should have failed with NOT_READY/MEDIUM_NOT_PRESENT*");
|
||||
|
||||
@@ -34,6 +34,11 @@ test_read16_0blocks(void)
|
||||
logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==0");
|
||||
ret = read16(iscsic, tgt_lun, 0, 0, block_size,
|
||||
0, 0, 0, 0, 0, NULL);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test READ16 0-blocks one block past end-of-LUN");
|
||||
|
||||
@@ -37,6 +37,11 @@ test_read16_beyond_eol(void)
|
||||
ret = read16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, NULL);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,11 @@ test_read16_flags(void)
|
||||
ret = read16(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 1, 0, 0, 0, NULL);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,11 @@ test_read16_rdprotect(void)
|
||||
ret = read16_invalidfieldincdb(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
i, 0, 0, 0, 0, NULL);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,13 @@ test_read16_residuals(void)
|
||||
CU_ASSERT_PTR_NOT_NULL(task_ret);
|
||||
CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
|
||||
|
||||
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] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
|
||||
|
||||
@@ -38,6 +38,12 @@ test_read16_simple(void)
|
||||
for (i = 1; i <= 256; i++) {
|
||||
ret = read16(iscsic, tgt_lun, 0, i * block_size,
|
||||
block_size, 0, 0, 0, 0, 0, NULL);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
@@ -46,6 +52,7 @@ test_read16_simple(void)
|
||||
for (i = 1; i <= 256; i++) {
|
||||
ret = read16(iscsic, tgt_lun, num_blocks - i,
|
||||
i * block_size, block_size, 0, 0, 0, 0, 0, NULL);
|
||||
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,15 +37,10 @@ test_readcapacity16_alloclen(void)
|
||||
for (i = 0; i < 16; i++) {
|
||||
ret = readcapacity16(iscsic, tgt_lun, i);
|
||||
if (ret == -2) {
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support.");
|
||||
CU_FAIL("READCAPACITY16 failed but the device claims SBC-3 support.");
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READCAPACITY16 is not implemented and no SBC-3 support claimed.");
|
||||
}
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,14 +37,9 @@ test_readcapacity16_simple(void)
|
||||
|
||||
ret = readcapacity16(iscsic, tgt_lun, 16);
|
||||
if (ret == -2) {
|
||||
if (sbc3_support) {
|
||||
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support.");
|
||||
CU_FAIL("READCAPACITY16 failed but the device claims SBC-3 support.");
|
||||
} else {
|
||||
logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READCAPACITY16 is not implemented and no SBC-3 support claimed.");
|
||||
}
|
||||
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
|
||||
CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user