TESTS: Add helpers for testunitready. Change 0000 and 0360 to use new testunitready helpers
This commit is contained in:
@@ -33,9 +33,9 @@ int T0360_startstopunit_simple(const char *initiator, const char *url, int data_
|
||||
printf("===================\n");
|
||||
if (show_info) {
|
||||
printf("Test basic STARTSTOPUNIT functionality.\n");
|
||||
printf("1, Verify we can eject the media with IMMED==1\n");
|
||||
printf("1, Verify we can eject removable the media with IMMED==1\n");
|
||||
printf("2, Verify we can load the media back again with IMMED==1\n");
|
||||
printf("3, Verify we can eject the media with IMMED==0\n");
|
||||
printf("3, Verify we can eject removable the media with IMMED==0\n");
|
||||
printf("4, Verify we can load the media back again with IMMED==0\n");
|
||||
printf("\n");
|
||||
return 0;
|
||||
@@ -96,50 +96,32 @@ int T0360_startstopunit_simple(const char *initiator, const char *url, int data_
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test2;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test2;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
task = iscsi_testunitready_sync(iscsi, lun);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test2;
|
||||
}
|
||||
if (removable) {
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_NOT_READY
|
||||
|| (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT
|
||||
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN
|
||||
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) {
|
||||
printf("[FAILED]\n");
|
||||
printf("TESTUNITREADY after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n");
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test2;
|
||||
}
|
||||
} else {
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("TESTUNITREADY command: failed with sense after STARTSTOPUNIT %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test2;
|
||||
}
|
||||
goto finished;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
if (removable) {
|
||||
printf("Medium is removable. Check with TESTUNITREADY that was removed.\n");
|
||||
ret = testunitready_nomedium(iscsi, lun);
|
||||
if (ret != 0) {
|
||||
goto finished;
|
||||
}
|
||||
} else {
|
||||
printf("Medium is not removable. Check with TESTUNITREADY that medium is still present.\n");
|
||||
ret = testunitready(iscsi, lun);
|
||||
if (ret != 0) {
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
|
||||
test2:
|
||||
|
||||
printf("STARTSTOPUNIT try to mount the media again with IMMED==1 ... ");
|
||||
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
|
||||
@@ -147,36 +129,24 @@ test2:
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test3;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test3;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
task = iscsi_testunitready_sync(iscsi, lun);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test3;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("TESTUNITREADY command: failed with sense after STARTSTOPUNIT %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test3;
|
||||
goto finished;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
printf("Check with TESTUNITREADY that the medium is present.\n");
|
||||
ret = testunitready(iscsi, lun);
|
||||
if (ret != 0) {
|
||||
goto finished;
|
||||
}
|
||||
|
||||
test3:
|
||||
|
||||
printf("STARTSTOPUNIT try to eject the media with IMMED==0 ... ");
|
||||
task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 0, 1, 0);
|
||||
@@ -184,50 +154,32 @@ test3:
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test4;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test4;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
task = iscsi_testunitready_sync(iscsi, lun);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test4;
|
||||
}
|
||||
if (removable) {
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_NOT_READY
|
||||
|| (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT
|
||||
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN
|
||||
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) {
|
||||
printf("[FAILED]\n");
|
||||
printf("TESTUNITREADY after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n");
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test4;
|
||||
}
|
||||
} else {
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("TESTUNITREADY command: failed with sense after STARTSTOPUNIT %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test4;
|
||||
}
|
||||
goto finished;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
if (removable) {
|
||||
printf("Medium is removable. Check with TESTUNITREADY that was removed.\n");
|
||||
ret = testunitready_nomedium(iscsi, lun);
|
||||
if (ret != 0) {
|
||||
goto finished;
|
||||
}
|
||||
} else {
|
||||
printf("Medium is not removable. Check with TESTUNITREADY that medium is still present.\n");
|
||||
ret = testunitready(iscsi, lun);
|
||||
if (ret != 0) {
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
|
||||
test4:
|
||||
|
||||
printf("STARTSTOPUNIT try to mount the media again with IMMED==0 ... ");
|
||||
task = iscsi_startstopunit_sync(iscsi, lun, 0, 0, 0, 0, 1, 1);
|
||||
@@ -235,36 +187,25 @@ test4:
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test5;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test5;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
task = iscsi_testunitready_sync(iscsi, lun);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test5;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("TESTUNITREADY command: failed with sense after STARTSTOPUNIT %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test5;
|
||||
goto finished;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
|
||||
test5:
|
||||
printf("Check with TESTUNITREADY that the medium is present.\n");
|
||||
ret = testunitready(iscsi, lun);
|
||||
if (ret != 0) {
|
||||
goto finished;
|
||||
}
|
||||
|
||||
|
||||
finished:
|
||||
iscsi_logout_sync(iscsi);
|
||||
|
||||
Reference in New Issue
Block a user