TESTS: read12 is optional, should make test skip, not fail

This commit is contained in:
Ronnie Sahlberg
2013-04-27 07:43:24 -07:00
parent 227489d32b
commit c866787dcb
8 changed files with 61 additions and 2 deletions

View File

@@ -2076,6 +2076,13 @@ read12(struct iscsi_context *iscsi, int lun, uint32_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);
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
return -2;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] READ12 command: "
"failed with sense. %s", iscsi_get_error(iscsi));
@@ -2113,6 +2120,13 @@ read12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_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);
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
return -2;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] READ12 successful but should "
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
@@ -2160,6 +2174,13 @@ read12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_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);
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
return -2;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] READ12 successful but should "
"have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE");
@@ -2206,6 +2227,13 @@ read12_nomedium(struct iscsi_context *iscsi, int lun, uint32_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);
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
return -2;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] READ12 successful but should "
"have failed with NOT_READY/MEDIUM_NOT_PRESENT*");

View File

@@ -32,6 +32,11 @@ test_read12_0blocks(void)
logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==0");
ret = read12(iscsic, tgt_lun, 0, 0, block_size,
0, 0, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
if (num_blocks > 0x80000000) {

View File

@@ -40,6 +40,11 @@ test_read12_beyond_eol(void)
ret = read12_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] READ12 is not implemented.");
CU_PASS("READ12 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -44,6 +44,11 @@ test_read12_flags(void)
ret = read12(iscsic, tgt_lun, 0,
block_size, block_size,
0, 1, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -46,6 +46,11 @@ test_read12_rdprotect(void)
ret = read12_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
i, 0, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -59,6 +59,13 @@ test_read12_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] READ12 is not implemented on this target.");
CU_PASS("READ12 is not implemented.");
return;
}
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s",

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -37,6 +36,11 @@ test_read12_simple(void)
for (i = 1; i <= 256; i++) {
ret = read12(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -48,7 +48,7 @@ test_writeverify10_simple(void)
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the end of the LUN");
logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);