test-tool: fix initiatorname and initiatorname2 issues

gcc-4.6.3 warned about this one on several occasions:
  gcc -DHAVE_CONFIG_H -I.  -I. -I./include "-D_U_=__attribute__((unused))" -I./test-tool  -Wall -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -ggdb3 -O0 -MT test-tool/bin_iscsi_test-0000_testunitready_simple.o -MD -MP -MF test-tool/.deps/bin_iscsi_test-0000_testunitready_simple.Tpo -c -o test-tool/bin_iscsi_test-0000_testunitready_simple.o `test -f 'test-tool/0000_testunitready_simple.c' || echo './'`test-tool/0000_testunitready_simple.c
  test-tool/0000_testunitready_simple.c: In function 'T0000_testunitready_simple':
  test-tool/0000_testunitready_simple.c:23:44: warning: declaration of 'initiator' shadows a global declaration [-Wshadow]
  test-tool/iscsi-test.h:20:20: warning: shadowed declaration is here [-Wshadow]

For now the global initiator is renamed to initiatorname1 (and initiator2 is
renamed to initiatorname2, respectively), but ultimately the globals should
probably go away.

While fixing this it also became apparent that initiator-name-2 was parsed
into the "initiator" variable as well.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
This commit is contained in:
Arne Redlich
2012-10-31 15:32:18 +01:00
parent 3af45f5867
commit 4d27ecae32
7 changed files with 91 additions and 93 deletions

View File

@@ -1,16 +1,16 @@
/* /*
Copyright (C) 2012 by Jon Grimm <jon.grimm@gmail.com> Copyright (C) 2012 by Jon Grimm <jon.grimm@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -23,7 +23,7 @@
#include "iscsi-test.h" #include "iscsi-test.h"
int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, int show_info) int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, int show_info)
{ {
struct iscsi_context *iscsi, *iscsi2; struct iscsi_context *iscsi, *iscsi2;
struct scsi_task *task; struct scsi_task *task;
int ret, lun; int ret, lun;
@@ -40,7 +40,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
printf("4. Test Initiator 1 can testunitready if reserved by Initiator 1.\n"); printf("4. Test Initiator 1 can testunitready if reserved by Initiator 1.\n");
printf("5. Test Initiator 2 can't testunitready if reserved by Initiator 1.\n"); printf("5. Test Initiator 2 can't testunitready if reserved by Initiator 1.\n");
printf("6. Test Initiator 2 can get reservation once Intiator 1 releases reservation.\n"); printf("6. Test Initiator 2 can get reservation once Intiator 1 releases reservation.\n");
printf("\n"); printf("\n");
return 0; return 0;
} }
@@ -51,9 +51,9 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
return -1; return -1;
} }
iscsi2 = iscsi_context_login(initiator2, url, &lun); iscsi2 = iscsi_context_login(initiatorname2, url, &lun);
if (iscsi2 == NULL) { if (iscsi2 == NULL) {
printf("Failed to login to target\n"); printf("Failed to login to target\n");
ret = 1; ret = 1;
goto out_login1; goto out_login1;
} }
@@ -71,8 +71,8 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
} }
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
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& 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");
goto finished2; goto finished2;
@@ -80,7 +80,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
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; goto finished2;
@@ -93,14 +93,14 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss,
task = iscsi_release6_sync(iscsi, lun); task = iscsi_release6_sync(iscsi, 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 finished1; 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));
ret = -1; ret = -1;
goto finished2; goto finished2;
@@ -157,7 +157,7 @@ test3:
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
goto finished1; 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");
@@ -196,7 +196,7 @@ test4:
task = iscsi_testunitready_sync(iscsi, lun); task = iscsi_testunitready_sync(iscsi, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished1; goto finished1;
@@ -216,7 +216,7 @@ test5:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished1; goto finished1;
@@ -236,14 +236,14 @@ test6:
task = iscsi_release6_sync(iscsi, lun); task = iscsi_release6_sync(iscsi, 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 finished1; 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));
ret = -1; ret = -1;
goto finished2; goto finished2;

View File

@@ -1,16 +1,16 @@
/* /*
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com> Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -38,7 +38,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_,
} }
int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_loss, int show_info) int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_loss, int show_info)
{ {
struct iscsi_context *iscsi, *iscsi2; struct iscsi_context *iscsi, *iscsi2;
struct scsi_task *task; struct scsi_task *task;
int ret, lun; int ret, lun;
@@ -65,7 +65,7 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo
return -1; return -1;
} }
iscsi2 = iscsi_context_login(initiator2, url, &lun); iscsi2 = iscsi_context_login(initiatorname2, url, &lun);
if (iscsi2 == NULL) { if (iscsi2 == NULL) {
printf("Failed to login to target\n"); printf("Failed to login to target\n");
return -1; return -1;
@@ -86,8 +86,8 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo
goto finished; goto finished;
} }
if (task->status == SCSI_STATUS_CHECK_CONDITION if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n"); printf("[SKIPPED]\n");
printf("RESERVE6 Not Supported\n"); printf("RESERVE6 Not Supported\n");
ret = -2; ret = -2;
@@ -96,9 +96,9 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 failed with sense:%s\n", printf("RESERVE6 failed with sense:%s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
goto test2; goto test2;
} }
@@ -111,7 +111,7 @@ test2:
task = iscsi_testunitready_sync(iscsi, lun); task = iscsi_testunitready_sync(iscsi, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -133,7 +133,7 @@ test3:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -179,7 +179,7 @@ test5:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -189,7 +189,7 @@ test5:
&& task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) {
printf("Got BUS RESET. Retry accessing the LUN\n"); printf("Got BUS RESET. Retry accessing the LUN\n");
goto test5; goto test5;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");

View File

@@ -1,16 +1,16 @@
/* /*
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com> Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -23,7 +23,7 @@
#include "iscsi-test.h" #include "iscsi-test.h"
int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, int show_info) int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, int show_info)
{ {
struct iscsi_context *iscsi, *iscsi2; struct iscsi_context *iscsi, *iscsi2;
struct scsi_task *task; struct scsi_task *task;
int ret, lun; int ret, lun;
@@ -48,7 +48,7 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss,
return -1; return -1;
} }
iscsi2 = iscsi_context_login(initiator2, url, &lun); iscsi2 = iscsi_context_login(initiatorname2, url, &lun);
if (iscsi2 == NULL) { if (iscsi2 == NULL) {
printf("Failed to login to target\n"); printf("Failed to login to target\n");
return -1; return -1;
@@ -69,8 +69,8 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss,
goto finished; goto finished;
} }
if (task->status == SCSI_STATUS_CHECK_CONDITION if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n"); printf("[SKIPPED]\n");
printf("RESERVE6 Not Supported\n"); printf("RESERVE6 Not Supported\n");
ret = -2; ret = -2;
@@ -79,9 +79,9 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss,
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 failed with sense:%s\n", printf("RESERVE6 failed with sense:%s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
goto test2; goto test2;
} }
@@ -94,7 +94,7 @@ test2:
task = iscsi_testunitready_sync(iscsi, lun); task = iscsi_testunitready_sync(iscsi, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -116,7 +116,7 @@ test3:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -142,7 +142,7 @@ test5:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;

View File

@@ -1,16 +1,16 @@
/* /*
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com> Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -23,7 +23,7 @@
#include "iscsi-test.h" #include "iscsi-test.h"
int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_loss, int show_info) int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_loss, int show_info)
{ {
struct iscsi_context *iscsi, *iscsi2; struct iscsi_context *iscsi, *iscsi2;
struct scsi_task *task; struct scsi_task *task;
int ret, lun; int ret, lun;
@@ -48,7 +48,7 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_
return -1; return -1;
} }
iscsi2 = iscsi_context_login(initiator2, url, &lun); iscsi2 = iscsi_context_login(initiatorname2, url, &lun);
if (iscsi2 == NULL) { if (iscsi2 == NULL) {
printf("Failed to login to target\n"); printf("Failed to login to target\n");
return -1; return -1;
@@ -69,8 +69,8 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_
goto finished; goto finished;
} }
if (task->status == SCSI_STATUS_CHECK_CONDITION if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n"); printf("[SKIPPED]\n");
printf("RESERVE6 Not Supported\n"); printf("RESERVE6 Not Supported\n");
ret = -2; ret = -2;
@@ -79,9 +79,9 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 failed with sense:%s\n", printf("RESERVE6 failed with sense:%s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
goto test2; goto test2;
} }
@@ -94,7 +94,7 @@ test2:
task = iscsi_testunitready_sync(iscsi, lun); task = iscsi_testunitready_sync(iscsi, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -116,7 +116,7 @@ test3:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -141,7 +141,7 @@ test5:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;

View File

@@ -1,16 +1,16 @@
/* /*
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com> Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -38,7 +38,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_,
} }
int T0424_reserve6_target_reset(const char *initiator, const char *url, int data_loss, int show_info) int T0424_reserve6_target_reset(const char *initiator, const char *url, int data_loss, int show_info)
{ {
struct iscsi_context *iscsi, *iscsi2; struct iscsi_context *iscsi, *iscsi2;
struct scsi_task *task; struct scsi_task *task;
int ret, lun; int ret, lun;
@@ -65,7 +65,7 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data
return -1; return -1;
} }
iscsi2 = iscsi_context_login(initiator2, url, &lun); iscsi2 = iscsi_context_login(initiatorname2, url, &lun);
if (iscsi2 == NULL) { if (iscsi2 == NULL) {
printf("Failed to login to target\n"); printf("Failed to login to target\n");
return -1; return -1;
@@ -86,8 +86,8 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data
goto finished; goto finished;
} }
if (task->status == SCSI_STATUS_CHECK_CONDITION if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n"); printf("[SKIPPED]\n");
printf("RESERVE6 Not Supported\n"); printf("RESERVE6 Not Supported\n");
ret = -2; ret = -2;
@@ -96,9 +96,9 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");
printf("RESERVE6 failed with sense:%s\n", printf("RESERVE6 failed with sense:%s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
ret = -1; ret = -1;
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
goto test2; goto test2;
} }
@@ -111,7 +111,7 @@ test2:
task = iscsi_testunitready_sync(iscsi, lun); task = iscsi_testunitready_sync(iscsi, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -133,7 +133,7 @@ test3:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -179,7 +179,7 @@ test5:
task = iscsi_testunitready_sync(iscsi2, lun); task = iscsi_testunitready_sync(iscsi2, lun);
if (task == NULL) { if (task == NULL) {
printf("[FAILED]\n"); printf("[FAILED]\n");
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 finished;
@@ -189,7 +189,7 @@ test5:
&& task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) {
printf("Got BUS RESET. Retry accessing the LUN\n"); printf("Got BUS RESET. Retry accessing the LUN\n");
goto test5; goto test5;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n"); printf("[FAILED]\n");

View File

@@ -1,18 +1,18 @@
/* /*
iscsi-test tool iscsi-test tool
Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com> Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -34,8 +34,8 @@
#include "iscsi-private.h" #include "iscsi-private.h"
#include "iscsi-test.h" #include "iscsi-test.h"
const char *initiator = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test"; const char *initiatorname1 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test";
const char *initiator2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2"; const char *initiatorname2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2";
static int data_loss = 0; static int data_loss = 0;
static int show_info = 0; static int show_info = 0;
@@ -288,7 +288,7 @@ struct iscsi_context *iscsi_context_login(const char *initiatorname, const char
iscsi_url = iscsi_parse_full_url(iscsi, url); iscsi_url = iscsi_parse_full_url(iscsi, url);
if (iscsi_url == NULL) { if (iscsi_url == NULL) {
fprintf(stderr, "Failed to parse URL: %s\n", fprintf(stderr, "Failed to parse URL: %s\n",
iscsi_get_error(iscsi)); iscsi_get_error(iscsi));
iscsi_destroy_context(iscsi); iscsi_destroy_context(iscsi);
return NULL; return NULL;
@@ -387,8 +387,8 @@ int main(int argc, const char *argv[])
{ "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL }, { "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL },
{ "usage", 0, POPT_ARG_NONE, &show_usage, 0, "Display brief usage message", NULL }, { "usage", 0, POPT_ARG_NONE, &show_usage, 0, "Display brief usage message", NULL },
{ "list", 'l', POPT_ARG_NONE, &list_tests, 0, "List all tests", NULL }, { "list", 'l', POPT_ARG_NONE, &list_tests, 0, "List all tests", NULL },
{ "initiator-name", 'i', POPT_ARG_STRING, &initiator, 0, "Initiatorname to use", "iqn-name" }, { "initiator-name", 'i', POPT_ARG_STRING, &initiatorname1, 0, "Initiatorname to use", "iqn-name" },
{ "initiator-name-2", 'I', POPT_ARG_STRING, &initiator, 0, "Second initiatorname to use for tests using more two sessions", "iqn-name" }, { "initiator-name-2", 'I', POPT_ARG_STRING, &initiatorname2, 0, "Second initiatorname to use for tests using more than one session", "iqn-name" },
{ "test", 't', POPT_ARG_STRING, &testname, 0, "Which test to run", "testname" }, { "test", 't', POPT_ARG_STRING, &testname, 0, "Which test to run", "testname" },
{ "skip", 's', POPT_ARG_STRING, &skipname, 0, "Which test to skip", "skipname" }, { "skip", 's', POPT_ARG_STRING, &skipname, 0, "Which test to skip", "skipname" },
{ "info", 0, POPT_ARG_NONE, &show_info, 0, "Show information about the test", "testname" }, { "info", 0, POPT_ARG_NONE, &show_info, 0, "Show information about the test", "testname" },
@@ -427,7 +427,7 @@ int main(int argc, const char *argv[])
for (test = &tests[0]; test->name; test++) { for (test = &tests[0]; test->name; test++) {
printf("%s\n", test->name); printf("%s\n", test->name);
if (show_info) { if (show_info) {
test->test(initiator, url, data_loss, show_info); test->test(initiatorname1, url, data_loss, show_info);
} }
} }
exit(0); exit(0);
@@ -438,7 +438,7 @@ int main(int argc, const char *argv[])
fprintf(stderr, "You must specify the URL\n"); fprintf(stderr, "You must specify the URL\n");
print_usage(); print_usage();
free(skipname); free(skipname);
free(testname); free(testname);
exit(10); exit(10);
} }
@@ -447,7 +447,7 @@ int main(int argc, const char *argv[])
if (testname != NULL && fnmatch(testname, test->name, 0)) { if (testname != NULL && fnmatch(testname, test->name, 0)) {
continue; continue;
} }
if (skipname != NULL) { if (skipname != NULL) {
char * pchr = skipname; char * pchr = skipname;
char * pchr2 = NULL; char * pchr2 = NULL;
@@ -463,7 +463,7 @@ int main(int argc, const char *argv[])
if (skip) continue; if (skip) continue;
} }
res = test->test(initiator, url, data_loss, show_info); res = test->test(initiatorname1, url, data_loss, show_info);
if (res == 0) { if (res == 0) {
printf("TEST %s [OK]\n", test->name); printf("TEST %s [OK]\n", test->name);
} else if (res == -2) { } else if (res == -2) {
@@ -482,4 +482,3 @@ int main(int argc, const char *argv[])
return num_failed ? num_failed : num_skipped ? 77 : 0; return num_failed ? num_failed : num_skipped ? 77 : 0;
} }

View File

@@ -1,24 +1,24 @@
/* /*
iscsi-test tool iscsi-test tool
Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com> Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
extern const char *initiator; extern const char *initiatorname1;
extern const char *initiator2; extern const char *initiatorname2;
struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun); struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun);
@@ -182,4 +182,3 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss,
int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_loss, int show_info); int T1020_bufferoffset_invalid(const char *initiator, const char *url, int data_loss, int show_info);
int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info); int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info);
int T1031_unsolicited_data_out(const char *initiator, const char *url, int data_loss, int show_info); int T1031_unsolicited_data_out(const char *initiator, const char *url, int data_loss, int show_info);