TESTS: Add RESERVE6/RELEASE6 tests

This commit is contained in:
Ronnie Sahlberg
2013-03-21 19:41:32 -07:00
parent d5c5fb83af
commit 6c0fd5cfa3
8 changed files with 246 additions and 1 deletions
+89
View File
@@ -2533,6 +2533,95 @@ readcapacity16_nomedium(struct iscsi_context *iscsi, int lun, int alloc_len)
return 0;
}
int
release6(struct iscsi_context *iscsi, int lun)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send RELEASE6");
task = iscsi_release6_sync(iscsi, lun);
if (task == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to send RELEASE6 command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] RELEASE6 command: "
"failed with sense. %s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] RELEASE6 returned SUCCESS.");
return 0;
}
int
reserve6(struct iscsi_context *iscsi, int lun)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send RESERVE6");
task = iscsi_reserve6_sync(iscsi, lun);
if (task == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to send RESERVE6 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] RESERVE6 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] RESERVE6 command: "
"failed with sense. %s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] RESERVE6 returned SUCCESS.");
return 0;
}
int
reserve6_conflict(struct iscsi_context *iscsi, int lun)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send RESERVE6 (Expecting RESERVATION_CONFLICT)");
task = iscsi_reserve6_sync(iscsi, lun);
if (task == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to send RESERVE6 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] RESERVE6 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) {
logging(LOG_NORMAL, "[FAILED] RESERVE6 command: "
"should have failed with RESERVATION_CONFLICT");
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] RESERVE6 returned RESERVATION_CONFLICT.");
return 0;
}
int
unmap(struct iscsi_context *iscsi, int lun, int anchor, struct unmap_list *list, int list_len)
{