Merge pull request #21 from jongrimm/master

Added test (to 420) to have Initiator 2 RELEASE6, when Initiator1 already has reserved.
This commit is contained in:
Ronnie Sahlberg
2012-10-01 18:33:33 -07:00

View File

@@ -54,7 +54,8 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
iscsi2 = iscsi_context_login(initiator2, url, &lun); iscsi2 = iscsi_context_login(initiator2, url, &lun);
if (iscsi2 == NULL) { if (iscsi2 == NULL) {
printf("Failed to login to target\n"); printf("Failed to login to target\n");
return -1; ret = 1;
goto out_login1;
} }
ret = 0; ret = 0;
@@ -66,7 +67,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
printf("Failed to send RESERVE6 command : %s\n", printf("Failed to send RESERVE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
if (task->status == SCSI_STATUS_CHECK_CONDITION if (task->status == SCSI_STATUS_CHECK_CONDITION
@@ -74,7 +75,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[OK]\n"); printf("[OK]\n");
printf("RESERVE6 Not Supported\n"); printf("RESERVE6 Not Supported\n");
ret = 0; goto finished2;
} else { } else {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 failed but ascq was wrong. Should " printf("RESERVE6 failed but ascq was wrong. Should "
@@ -82,10 +83,10 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
"INVALID OPERATOR. Sense:%s\n", "INVALID OPERATOR. Sense:%s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished2;
} }
scsi_free_scsi_task(task);
goto finished;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
printf("Send RELEASE6 ... "); printf("Send RELEASE6 ... ");
@@ -95,64 +96,58 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
printf("Failed to send RELEASE6 command : %s\n", printf("Failed to send RELEASE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RELEASE6 command failed : %s\n", printf("RELEASE6 command failed : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
test2: test2:
printf("Test that reservation works.\n"); printf("Test that reservation works.\n");
printf("Send RESERVE6 from Initiator 1 ... "); printf("Send RESERVE6 from Initiator 1. ... ");
task = iscsi_reserve6_sync(iscsi, lun); task = iscsi_reserve6_sync(iscsi, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("Failed to send RESERVE6 command : %s\n", printf("Failed to send RESERVE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 command failed : %s\n", printf("RESERVE6 command failed : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
printf("Send another RESERVE6 from Initiator 1 ... ");
task = iscsi_reserve6_sync(iscsi, lun); task = iscsi_reserve6_sync(iscsi, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("Failed to send RESERVE6 command : %s\n", printf("Failed to send RESERVE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 command failed : %s\n", printf("RESERVE6 command failed : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
test3: test3:
printf("Send RESERVE6 from Initiator 2. Expect conflict. ... "); printf("Send RESERVE6 from Initiator 2. Expect conflict. ... ");
task = iscsi_reserve6_sync(iscsi2, lun); task = iscsi_reserve6_sync(iscsi2, lun);
@@ -161,42 +156,41 @@ test3:
printf("Failed to send RESERVE6 command : %s\n", printf("Failed to send RESERVE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
/* We expect this command to fail for the test to pass. */ /* We expect this command to fail for the test to pass. */
if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("Expected RESERVATION CONFLICT\n"); printf("Expected RESERVATION CONFLICT\n");
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
test3a: test3a:
printf("Send RELEASE6 from Initiator 2. Expect NO-OP ..."); printf("Send RELEASE6 from Initiator 2..Expect NO-OP. ... ");
task = iscsi_release6_sync(iscsi2, lun); task = iscsi_release6_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("Failed to send RELEASE6 command : %s\n", printf("Failed to send RELEASE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
/* We expect this command to pass. */ /* We expect this command to pass. */
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RELEASE6 command: failed with sense %s\n", printf("RELEASE6 command: failed with sense %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
/* Treat as non-fatal failure for now. STGT is broken.*/
scsi_free_scsi_task(task);
goto test4; goto test4;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
test4: test4:
printf("Send TESTUNITREADY from Initiator 1 ... "); printf("Send TESTUNITREADY from Initiator 1 ... ");
task = iscsi_testunitready_sync(iscsi, lun); task = iscsi_testunitready_sync(iscsi, lun);
@@ -205,19 +199,18 @@ test4:
printf("Failed to send TEST UNIT READY command: %s\n", printf("Failed to send TEST UNIT READY command: %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("TEST UNIT READY command: failed with sense %s\n", printf("TEST UNIT READY command: failed with sense %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
test5: test5:
printf("Send TESTUNITREADY from Initiator 2. Expect conflict. ... "); printf("Send TESTUNITREADY from Initiator 2. Expect conflict. ... ");
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
@@ -226,19 +219,17 @@ test5:
printf("Failed to send TEST UNIT READY command: %s\n", printf("Failed to send TEST UNIT READY command: %s\n",
iscsi_get_error(iscsi2)); iscsi_get_error(iscsi2));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("Expected RESERVATION CONFLICT\n"); printf("Expected RESERVATION CONFLICT\n");
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
test6: test6:
printf("Test that release actually works\n"); printf("Test that release actually works\n");
printf("Send RELEASE6 from Initiator 1 ... "); printf("Send RELEASE6 from Initiator 1 ... ");
@@ -248,17 +239,16 @@ test6:
printf("Failed to send RELEASE6 command : %s\n", printf("Failed to send RELEASE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RELEASE6 command failed : %s\n", printf("RELEASE6 command failed : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
printf("Send RESERVE6 Initiator 2 ... "); printf("Send RESERVE6 Initiator 2 ... ");
@@ -268,16 +258,16 @@ test6:
printf("Failed to send RESERVE6 command : %s\n", printf("Failed to send RESERVE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 command failed : %s\n", printf("RESERVE6 command failed : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
scsi_free_scsi_task(task);
printf("[OK]\n"); printf("[OK]\n");
printf("Send RELEASE6 Initiator 2 ... "); printf("Send RELEASE6 Initiator 2 ... ");
@@ -287,22 +277,26 @@ test6:
printf("Failed to send RELEASE6 command : %s\n", printf("Failed to send RELEASE6 command : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished; goto finished1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RELEASE6 command failed : %s\n", printf("RELEASE6 command failed : %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
ret = -1; ret = -1;
goto finished; goto finished2;
} }
printf("[OK]\n");
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
printf("[OK]\n");
goto finished1;
finished:
finished2:
scsi_free_scsi_task(task);
finished1:
iscsi_logout_sync(iscsi2);
iscsi_destroy_context(iscsi2);
out_login1:
iscsi_logout_sync(iscsi); iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi); iscsi_destroy_context(iscsi);
return ret; return ret;