TESTS: Convert 0361 and 0362 to use testunitready helpers

This commit is contained in:
Ronnie Sahlberg
2012-12-23 21:02:43 -08:00
parent b9c516147a
commit 69dbf8c727
2 changed files with 65 additions and 169 deletions

View File

@@ -86,83 +86,58 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url, int data_
} else {
printf("Media is not removable. STARTSTOPUNIT should fail\n");
}
printf("Try to eject media with PC != 0 ... ");
for (i = 1; i < 16; i++) {
printf("Try to eject media with PC == %d ... ", i);
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, i, 0, 1, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
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++;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
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++;
goto test2;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("TESTUNITREADY command: failed with sense after STARTSTOPUNIT %s\n", iscsi_get_error(iscsi));
ret++;
scsi_free_scsi_task(task);
goto test2;
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test2:
printf("Try to mount the media again ... ");
task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi));
ret++;
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++;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
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++;
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++;
scsi_free_scsi_task(task);
goto test3;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
test3:
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
finished:

View File

@@ -111,24 +111,14 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url, int data_
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 (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;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test2:
/* in case the previous command did eject the media */
@@ -150,24 +140,14 @@ test2:
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;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test3:
/* in case the previous command did eject the media */
@@ -189,24 +169,15 @@ test3:
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 (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;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test4:
/* in case the previous command did eject the media */
@@ -228,24 +199,14 @@ test4:
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;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test5:
/* in case the previous command did eject the media */
@@ -267,24 +228,14 @@ test5:
goto test6;
}
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 test6;
}
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 test6;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test6:
/* in case the previous command did eject the media */
@@ -306,24 +257,14 @@ test6:
goto test7;
}
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 test7;
}
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 test7;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test7:
/* in case the previous command did eject the media */
@@ -345,24 +286,14 @@ test7:
goto test8;
}
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 test8;
}
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 test8;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test8:
/* in case the previous command did eject the media */
@@ -384,24 +315,14 @@ test8:
goto test9;
}
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 test9;
}
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 test9;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
printf("Check with TESTUNITREADY that the medium is still present.\n");
ret = testunitready(iscsi, lun);
if (ret != 0) {
goto finished;
}
test9:
/* in case the previous command did eject the media */