test: reserve_basic: mem leak cleanup
This commit is contained in:
@@ -53,8 +53,9 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
|
|||||||
|
|
||||||
iscsi2 = iscsi_context_login(initiator, url, &lun);
|
iscsi2 = iscsi_context_login(initiator, 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,20 +75,20 @@ 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 "
|
||||||
"have failed with ILLEGAL_REQUEST/"
|
"have failed with ILLEGAL_REQUEST/"
|
||||||
"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...\n");
|
printf("Send RELEASE6...\n");
|
||||||
task = iscsi_release6_sync(iscsi, lun);
|
task = iscsi_release6_sync(iscsi, lun);
|
||||||
if (task == NULL) {
|
if (task == NULL) {
|
||||||
@@ -95,17 +96,16 @@ 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:
|
||||||
@@ -117,17 +117,16 @@ test2:
|
|||||||
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...\n");
|
printf("Send another RESERVE6 from Initiator 1...\n");
|
||||||
@@ -137,18 +136,18 @@ test2:
|
|||||||
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.\n");
|
printf("Send RESERVE6 from Initiator 2...Expect conflict.\n");
|
||||||
task = iscsi_reserve6_sync(iscsi2, lun);
|
task = iscsi_reserve6_sync(iscsi2, lun);
|
||||||
@@ -157,17 +156,16 @@ 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:
|
||||||
@@ -178,18 +176,19 @@ test3a:
|
|||||||
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:
|
||||||
@@ -200,20 +199,19 @@ 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.\n");
|
printf("Send TESTUNITREADY from Initiator 2...Expect conflict.\n");
|
||||||
task = iscsi_testunitready_sync(iscsi2, lun);
|
task = iscsi_testunitready_sync(iscsi2, lun);
|
||||||
if (task == NULL) {
|
if (task == NULL) {
|
||||||
@@ -221,15 +219,15 @@ 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:
|
||||||
@@ -241,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...\n");
|
printf("Send RESERVE6 Initiator 2...\n");
|
||||||
@@ -261,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...\n");
|
printf("Send RELEASE6 Initiator 2...\n");
|
||||||
@@ -280,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;
|
||||||
|
|||||||
Reference in New Issue
Block a user