diff --git a/include/iscsi-private.h b/include/iscsi-private.h index 3280f1d..ddf7807 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -86,7 +86,7 @@ struct iscsi_context { int fd; int is_connected; - + int tcp_user_timeout; int tcp_keepcnt; int tcp_keepintvl; @@ -274,7 +274,7 @@ int iscsi_process_reject(struct iscsi_context *iscsi, int iscsi_send_target_nop_out(struct iscsi_context *iscsi, uint32_t ttt); void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, - ...); + ...) __attribute__((format(printf, 2, 3))); unsigned char *iscsi_get_user_in_buffer(struct iscsi_context *iscsi, struct iscsi_in_pdu *in, uint32_t pos, ssize_t *count); unsigned char *scsi_task_get_data_in_buffer(struct scsi_task *task, uint32_t pos, ssize_t *count); @@ -295,4 +295,3 @@ void iscsi_set_noautoreconnect(struct iscsi_context *iscsi, int state); #endif #endif /* __iscsi_private_h__ */ - diff --git a/lib/init.c b/lib/init.c index 840e163..ecb3925 100644 --- a/lib/init.c +++ b/lib/init.c @@ -105,7 +105,7 @@ iscsi_create_context(const char *initiator_name) if (getenv("LIBISCSI_DEBUG") != NULL) { iscsi_set_debug(iscsi,atoi(getenv("LIBISCSI_DEBUG"))); } - + if (getenv("LIBISCSI_TCP_USER_TIMEOUT") != NULL) { iscsi_set_tcp_user_timeout(iscsi,atoi(getenv("LIBISCSI_TCP_USER_TIMEOUT"))); } @@ -236,7 +236,7 @@ iscsi_destroy_context(struct iscsi_context *iscsi) if (iscsi->is_loggedin) { pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL, pdu->private_data); - } + } } iscsi_free_pdu(iscsi, pdu); } @@ -284,7 +284,7 @@ iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, ...) strncpy(errstr,"could not format error string!",MAX_STRING_SIZE); } va_end(ap); - + strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE); DPRINTF(iscsi,1,"%s",iscsi->error_string); } @@ -342,10 +342,10 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) char *portal; char *user = NULL; char *passwd = NULL; - char *target; + char *target = NULL; char *lun; char *tmp; - int l; + int l = 0; if (strncmp(url, "iscsi://", 8)) { if (full) { @@ -429,12 +429,13 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) iscsi_url = iscsi_malloc(iscsi, sizeof(struct iscsi_url)); else iscsi_url = malloc(sizeof(struct iscsi_url)); + if (iscsi_url == NULL) { iscsi_set_error(iscsi, "Out-of-memory: Failed to allocate iscsi_url structure"); return NULL; } memset(iscsi_url, 0, sizeof(struct iscsi_url)); - iscsi_url->iscsi= iscsi; + iscsi_url->iscsi= iscsi; strncpy(iscsi_url->portal,portal,MAX_STRING_SIZE); @@ -442,12 +443,12 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) strncpy(iscsi_url->user,user,MAX_STRING_SIZE); strncpy(iscsi_url->passwd,passwd,MAX_STRING_SIZE); } - + if (full) { strncpy(iscsi_url->target,target,MAX_STRING_SIZE); iscsi_url->lun = l; } - + return iscsi_url; } diff --git a/lib/socket.c b/lib/socket.c index 087d573..0566dc9 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -61,7 +61,7 @@ static void set_nonblocking(int fd) int set_tcp_sockopt(int sockfd, int optname, int value) { int level; - + #if defined(__FreeBSD__) || defined(__sun) struct protoent *buf; @@ -71,8 +71,8 @@ int set_tcp_sockopt(int sockfd, int optname, int value) return -1; #else level = SOL_TCP; - #endif - + #endif + return setsockopt(sockfd, level, optname, &value, sizeof(value)); } @@ -156,7 +156,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, "Missing ']' in IPv6 address", portal); return -1; } - *str = 0; + *str = 0; } /* is it a hostname ? */ @@ -205,9 +205,9 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, iscsi->connect_data = private_data; set_nonblocking(iscsi->fd); - + iscsi_set_tcp_keepalive(iscsi, iscsi->tcp_keepidle, iscsi->tcp_keepcnt, iscsi->tcp_keepintvl); - + if (iscsi->tcp_user_timeout > 0) { set_tcp_user_timeout(iscsi); } @@ -227,9 +227,9 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, } freeaddrinfo(ai); - + strncpy(iscsi->connected_portal,portal,MAX_STRING_SIZE); - + return 0; } @@ -243,7 +243,7 @@ iscsi_disconnect(struct iscsi_context *iscsi) } close(iscsi->fd); - + if (iscsi->connected_portal[0]) DPRINTF(iscsi,2,"disconnected from portal %s",iscsi->connected_portal); @@ -408,7 +408,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi) /* stop sending. maxcmdsn is reached */ return 0; } - + total = iscsi->outqueue->outdata.size; total = (total + 3) & 0xfffffffc; @@ -441,7 +441,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi) return 0; } -inline int +static inline int iscsi_service_reconnect_if_loggedin(struct iscsi_context *iscsi) { if (iscsi->is_loggedin) { @@ -505,7 +505,7 @@ iscsi_service(struct iscsi_context *iscsi, int revents) NULL, iscsi->connect_data); iscsi->socket_status_cb = NULL; } - + return iscsi_service_reconnect_if_loggedin(iscsi); } @@ -586,31 +586,31 @@ iscsi_free_iscsi_inqueue(struct iscsi_context *iscsi, struct iscsi_in_pdu *inque void iscsi_set_tcp_syncnt(struct iscsi_context *iscsi, int value) { iscsi->tcp_syncnt=value; - DPRINTF(iscsi,2,"TCP_SYNCNT will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_SYNCNT will be set to %d on next socket creation",value); } void iscsi_set_tcp_user_timeout(struct iscsi_context *iscsi, int value) { iscsi->tcp_user_timeout=value; - DPRINTF(iscsi,2,"TCP_USER_TIMEOUT will be set to %dms on next socket creation",value); + DPRINTF(iscsi,2,"TCP_USER_TIMEOUT will be set to %dms on next socket creation",value); } void iscsi_set_tcp_keepidle(struct iscsi_context *iscsi, int value) { iscsi->tcp_keepidle=value; - DPRINTF(iscsi,2,"TCP_KEEPIDLE will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_KEEPIDLE will be set to %d on next socket creation",value); } void iscsi_set_tcp_keepcnt(struct iscsi_context *iscsi, int value) { iscsi->tcp_keepcnt=value; - DPRINTF(iscsi,2,"TCP_KEEPCNT will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_KEEPCNT will be set to %d on next socket creation",value); } void iscsi_set_tcp_keepintvl(struct iscsi_context *iscsi, int value) { iscsi->tcp_keepintvl=value; - DPRINTF(iscsi,2,"TCP_KEEPINTVL will be set to %d on next socket creation",value); + DPRINTF(iscsi,2,"TCP_KEEPINTVL will be set to %d on next socket creation",value); } int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval) @@ -647,4 +647,3 @@ int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, in return 0; } - diff --git a/test-tool/0000_testunitready_simple.c b/test-tool/0000_testunitready_simple.c index 029fc44..c699aff 100644 --- a/test-tool/0000_testunitready_simple.c +++ b/test-tool/0000_testunitready_simple.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -21,10 +21,10 @@ #include "iscsi-test.h" int T0000_testunitready_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; - int ret, i, lun; + int ret, lun; printf("0000_testunitready_simple:\n"); printf("===================\n"); @@ -49,20 +49,18 @@ int T0000_testunitready_simple(const char *initiator, const char *url, int data_ printf("[FAILED]\n"); printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); ret++; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("TEST UNIT READY 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"); -test2: - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0105_read10_invalid.c b/test-tool/0105_read10_invalid.c index 96724ec..4913892 100644 --- a/test-tool/0105_read10_invalid.c +++ b/test-tool/0105_read10_invalid.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2010 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -24,7 +24,7 @@ #include "iscsi-test.h" int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct iscsi_data data; @@ -120,7 +120,8 @@ int T0105_read10_invalid(const char *initiator, const char *url, int data_loss _ scsi_free_scsi_task(task); goto test2; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (int64_t)block_size) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual overflow.\n"); ret = -1; @@ -166,7 +167,8 @@ test2: scsi_free_scsi_task(task); goto test3; } - if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || + task->residual != (int64_t)block_size) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual underflow.\n"); ret = -1; @@ -209,7 +211,8 @@ test3: scsi_free_scsi_task(task); goto test4; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size - 200) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (int64_t)(block_size - 200)) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual overflow.\n"); ret = -1; @@ -251,7 +254,8 @@ test4: scsi_free_scsi_task(task); goto test5; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (int64_t)block_size) { printf("[FAILED]\n"); printf("Read10 returned incorrect residual overflow.\n"); ret = -1; diff --git a/test-tool/0122_read6_invalid.c b/test-tool/0122_read6_invalid.c index 9440dc3..f0ebc1c 100644 --- a/test-tool/0122_read6_invalid.c +++ b/test-tool/0122_read6_invalid.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2010 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -19,11 +19,12 @@ #include #include #include "iscsi.h" +#include "iscsi-private.h" #include "scsi-lowlevel.h" #include "iscsi-test.h" int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct iscsi_data data; @@ -118,7 +119,8 @@ int T0122_read6_invalid(const char *initiator, const char *url, int data_loss _U scsi_free_scsi_task(task); goto test2; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (ssize_t)block_size) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual overflow.\n"); ret = -1; @@ -164,7 +166,8 @@ test2: scsi_free_scsi_task(task); goto test3; } - if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW || + task->residual != (ssize_t)block_size) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual underflow.\n"); ret = -1; @@ -207,7 +210,8 @@ test3: scsi_free_scsi_task(task); goto test4; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size - 200) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (ssize_t)block_size - 200) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual overflow.\n"); ret = -1; @@ -249,7 +253,8 @@ test4: scsi_free_scsi_task(task); goto test5; } - if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || task->residual != block_size) { + if (task->residual_status != SCSI_RESIDUAL_OVERFLOW || + task->residual != (ssize_t)block_size) { printf("[FAILED]\n"); printf("Read6 returned incorrect residual overflow.\n"); ret = -1; diff --git a/test-tool/0161_readcapacity16_alloclen.c b/test-tool/0161_readcapacity16_alloclen.c index 6f31f98..b6a74cc 100644 --- a/test-tool/0161_readcapacity16_alloclen.c +++ b/test-tool/0161_readcapacity16_alloclen.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2010 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -24,10 +24,9 @@ #include "iscsi-test.h" int T0161_readcapacity16_alloclen(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; - struct iscsi_data data; int ret, lun; printf("0161_readcapacity16_alloclen:\n"); diff --git a/test-tool/0241_prefetch10_flags.c b/test-tool/0241_prefetch10_flags.c index 4cb4770..0b86092 100644 --- a/test-tool/0241_prefetch10_flags.c +++ b/test-tool/0241_prefetch10_flags.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -21,12 +21,11 @@ #include "iscsi-test.h" int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0241_prefetch10_flags:\n"); printf("===================\n"); @@ -64,7 +63,7 @@ int T0241_prefetch10_flags(const char *initiator, const char *url, int data_loss scsi_free_scsi_task(task); goto finished; } - num_blocks = rc16->returned_lba; + scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0251_prefetch16_flags.c b/test-tool/0251_prefetch16_flags.c index 0766821..f0df610 100644 --- a/test-tool/0251_prefetch16_flags.c +++ b/test-tool/0251_prefetch16_flags.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -21,12 +21,11 @@ #include "iscsi-test.h" int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss _U_, int show_info) -{ +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, i, lun; - uint64_t num_blocks; printf("0251_prefetch16_flags:\n"); printf("===================\n"); @@ -64,7 +63,7 @@ int T0251_prefetch16_flags(const char *initiator, const char *url, int data_loss scsi_free_scsi_task(task); goto finished; } - num_blocks = rc16->returned_lba; + scsi_free_scsi_task(task); ret = 0; diff --git a/test-tool/0400_inquiry_basic.c b/test-tool/0400_inquiry_basic.c index e70f1f4..9e8cc71 100644 --- a/test-tool/0400_inquiry_basic.c +++ b/test-tool/0400_inquiry_basic.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss _U_, + int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_standard *inq; @@ -100,7 +101,6 @@ int T0400_inquiry_basic(const char *initiator, const char *url, int data_loss, i } printf("[OK]\n"); -test2: printf("Check that standard data is >= 36 bytes in size ... "); if (full_size < 36) { printf("[FAILED]\n"); @@ -111,8 +111,6 @@ test2: } printf("[OK]\n"); - -test3: printf("Check device-type is either of DISK, TAPE or CD/DVD ... "); switch (inq->device_type) { case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS: @@ -193,7 +191,7 @@ test9: if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) { continue; } - + printf("[FAILED]\n"); printf("VENDOR_IDENTIFICATION contains non-ASCII characters\n"); ret = -1; @@ -211,7 +209,7 @@ test10: if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) { continue; } - + printf("[FAILED]\n"); printf("PRODUCT_IDENTIFICATION contains non-ASCII characters\n"); ret = -1; @@ -243,7 +241,7 @@ test12: printf("[FAILED]\n"); printf("AERC is set but this device reports SPC-3 or later\n"); ret = -1; - goto test13; + goto test13; } printf("[OK]\n"); @@ -253,7 +251,7 @@ test13: printf("[FAILED]\n"); printf("TrmTsk is set but this device reports SPC-2 or later\n"); ret = -1; - goto test14; + goto test14; } printf("[OK]\n"); diff --git a/test-tool/0401_inquiry_alloclen.c b/test-tool/0401_inquiry_alloclen.c index 31a47c9..b38f215 100644 --- a/test-tool/0401_inquiry_alloclen.c +++ b/test-tool/0401_inquiry_alloclen.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,13 +22,12 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss _U_, + int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; int ret, lun, i; - int full_size; printf("0401_inquiry_alloclen:\n"); printf("===================\n"); @@ -57,22 +56,19 @@ int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss printf("[FAILED]\n"); printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("INQUIRY command with alloclen:%d failed : %s\n", i, iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0402_inquiry_evpd.c b/test-tool/0402_inquiry_evpd.c index 6db9370..d33cbf5 100644 --- a/test-tool/0402_inquiry_evpd.c +++ b/test-tool/0402_inquiry_evpd.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss _U_, + int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; int ret, lun, i; @@ -55,14 +56,14 @@ int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, in printf("[FAILED]\n"); printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto test2; + goto finished; } if (task->status == SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("INQUIRY should have failed with CHECK_CONDITION/ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST @@ -71,15 +72,12 @@ int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, in printf("INQUIRY should have failed with wrong sense code. It failed with %s but should have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; - goto test2; + goto finished; } scsi_free_scsi_task(task); } printf("[OK]\n"); -test2: - - finished: iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); diff --git a/test-tool/0403_inquiry_supported_vpd.c b/test-tool/0403_inquiry_supported_vpd.c index f28e7da..1660c14 100644 --- a/test-tool/0403_inquiry_supported_vpd.c +++ b/test-tool/0403_inquiry_supported_vpd.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,12 +22,14 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0403_inquiry_supported_vpd(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0403_inquiry_supported_vpd(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_supported_pages *inq; - int ret, lun, i, j; + size_t i; + int ret, lun, j; int full_size; int page_code; enum scsi_inquiry_pagecode required_spc_pages[] = { @@ -51,11 +53,8 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url, int data return -1; } - ret = 0; - - printf("Read SUPPORTED VPD data ... "); /* See how big this inquiry data is */ page_code = SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES; @@ -95,7 +94,6 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url, int data } printf("[OK]\n"); -test2: printf("Verify we have all mandatory SPC VPD pages:\n"); for (i = 0; i < sizeof(required_spc_pages) / sizeof(enum scsi_inquiry_pagecode); i++) { printf("Verify the target supports page 0x%02x ... ", required_spc_pages[i]); @@ -113,8 +111,6 @@ test2: } } - -test3: scsi_free_scsi_task(task); finished: diff --git a/test-tool/0404_inquiry_all_reported_vpd.c b/test-tool/0404_inquiry_all_reported_vpd.c index 5397315..f37d6db 100644 --- a/test-tool/0404_inquiry_all_reported_vpd.c +++ b/test-tool/0404_inquiry_all_reported_vpd.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_inquiry_supported_pages *inq; @@ -91,7 +92,6 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url, int d } printf("[OK]\n"); -test2: printf("Read each page and verify qualifier, type and page code:\n"); for (i = 0; i < inq->num_pages; i++) { struct scsi_task *pc_task; @@ -116,7 +116,8 @@ test2: printf("Verify page 0x%02x qualifier ... ", inq->pages[i]); if ((pc_task->datain.data[0] & 0xe0) >> 5 != inq->qualifier) { printf("[FAILED]\n"); - printf("Qualifier differs between VPD pages\n", iscsi_get_error(iscsi)); + printf("Qualifier differs between VPD pages: %x != %x\n", + pc_task->datain.data[0] & 0xe0, inq->qualifier); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -125,9 +126,10 @@ test2: } printf("Verify page 0x%02x device type ... ", inq->pages[i]); - if (pc_task->datain.data[0] & 0x1f != inq->device_type) { + if ((pc_task->datain.data[0] & 0x1f) != inq->device_type) { printf("[FAILED]\n"); - printf("Device Type differs between VPD pages\n", iscsi_get_error(iscsi)); + printf("Device Type differs between VPD pages: %x != %x\n", + pc_task->datain.data[0] & 0x1f, inq->device_type); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -138,7 +140,8 @@ test2: printf("Verify page 0x%02x page code ... ", inq->pages[i]); if (pc_task->datain.data[1] != inq->pages[i]) { printf("[FAILED]\n"); - printf("Page code is wrong\n", iscsi_get_error(iscsi)); + printf("Page code is wrong: %x != %x\n", + pc_task->datain.data[1], inq->pages[i]); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -149,8 +152,6 @@ test2: scsi_free_scsi_task(pc_task); } - -test3: scsi_free_scsi_task(task); finished: diff --git a/test-tool/0410_readtoc_basic.c b/test-tool/0410_readtoc_basic.c index e7bb4d4..2f84452 100644 --- a/test-tool/0410_readtoc_basic.c +++ b/test-tool/0410_readtoc_basic.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Jon Grimm - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss _U_, + int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task, *task1; struct scsi_inquiry_standard *inq; @@ -132,13 +133,13 @@ int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss, i scsi_free_scsi_task(task); goto finished; } - /* LBA will return 0, if the medium is blank. */ + /* LBA will return 0, if the medium is blank. */ is_blank = rc10->lba ? 0 : 1; } /* If we get 'medium not present' there is no medium in the drive */ 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.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)) { no_medium = 1; @@ -189,9 +190,9 @@ test1: } if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_NOT_READY + || 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)) { + && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("READTOC failed but ascq was wrong. Should " "have failed with MEDIUM_NOT_PRESENT. " @@ -216,8 +217,8 @@ test1: printf("READTOC Should have failed\n"); ret = -1; } else if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST - || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST + || task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[FAILED]\n"); printf("READTOC failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/INVALID OPERATION_CODE. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; @@ -229,7 +230,6 @@ test1: goto finished; } - if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("READTOC command failed : %s\n", iscsi_get_error(iscsi)); @@ -239,9 +239,6 @@ test1: } printf("[OK]\n"); - - -test2: /* If we get here, there is a disk loaded and it contains data */ printf("Verify we got at least 4 bytes of data for track 0 ... "); full_size = scsi_datain_getfullsize(task); @@ -262,8 +259,6 @@ test2: } printf("[OK]\n"); - -test3: printf("Verify we can READTOC format 0000b (TOC) track 1 ... "); task1 = iscsi_readtoc_sync(iscsi, lun, 0, 1, 0, 255); if (task1 == NULL) { @@ -284,8 +279,6 @@ test3: } printf("[OK]\n"); - -test4: printf("Verify we got at least 4 bytes of data for track 1 ... "); full_size = scsi_datain_getfullsize(task1); if (full_size < 4) { @@ -307,7 +300,6 @@ test4: } printf("[OK]\n"); -test5: printf("Verify track 0 and 1 both returned the same data ... "); if (list->num != list1->num || list->first != list1->first || diff --git a/test-tool/0420_reserve6_simple.c b/test-tool/0420_reserve6_simple.c index b5f55b3..e6f2300 100644 --- a/test-tool/0420_reserve6_simple.c +++ b/test-tool/0420_reserve6_simple.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Jon Grimm - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.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 _U_, + int show_info) +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -40,7 +41,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("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("\n"); return 0; } @@ -51,9 +52,9 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { - printf("Failed to login to target\n"); + printf("Failed to login to target\n"); ret = 1; goto out_login1; } @@ -71,8 +72,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_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[OK]\n"); printf("RESERVE6 Not Supported\n"); goto finished2; @@ -80,7 +81,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, printf("[FAILED]\n"); printf("RESERVE6 failed but ascq was wrong. Should " "have failed with ILLEGAL_REQUEST/" - "INVALID OPERATOR. Sense:%s\n", + "INVALID OPERATOR. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; goto finished2; @@ -93,14 +94,14 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, task = iscsi_release6_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", + printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished1; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RELEASE6 command failed : %s\n", + printf("RELEASE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished2; @@ -108,8 +109,6 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss, scsi_free_scsi_task(task); printf("[OK]\n"); - -test2: printf("Test that reservation works.\n"); printf("Send RESERVE6 from Initiator 1. ... "); task = iscsi_reserve6_sync(iscsi, lun); @@ -148,7 +147,6 @@ test2: scsi_free_scsi_task(task); printf("[OK]\n"); -test3: printf("Send RESERVE6 from Initiator 2. Expect conflict. ... "); task = iscsi_reserve6_sync(iscsi2, lun); if (task == NULL) { @@ -157,7 +155,7 @@ test3: iscsi_get_error(iscsi)); ret = -1; goto finished1; - } + } /* We expect this command to fail for the test to pass. */ if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { printf("[FAILED]\n"); @@ -168,7 +166,6 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test3a: printf("Send RELEASE6 from Initiator 2..Expect NO-OP. ... "); task = iscsi_release6_sync(iscsi2, lun); if (task == NULL) { @@ -196,7 +193,7 @@ test4: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { 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)); ret = -1; goto finished1; @@ -211,12 +208,11 @@ test4: scsi_free_scsi_task(task); printf("[OK]\n"); -test5: printf("Send TESTUNITREADY from Initiator 2. Expect conflict. ... "); task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished1; @@ -230,20 +226,19 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); -test6: printf("Test that release actually works\n"); printf("Send RELEASE6 from Initiator 1 ... "); task = iscsi_release6_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send RELEASE6 command : %s\n", + printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished1; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RELEASE6 command failed : %s\n", + printf("RELEASE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished2; diff --git a/test-tool/0421_reserve6_lun_reset.c b/test-tool/0421_reserve6_lun_reset.c index e956d0e..69321ee 100644 --- a/test-tool/0421_reserve6_lun_reset.c +++ b/test-tool/0421_reserve6_lun_reset.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -37,8 +37,9 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, mgmt_task->finished = 1; } -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 _U_, int show_info) +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -65,7 +66,7 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -86,8 +87,8 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -96,9 +97,9 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_lo } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } @@ -111,7 +112,7 @@ test2: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -133,7 +134,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -148,7 +149,6 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Send a LUN Reset to the target ... "); iscsi_task_mgmt_lun_reset_async(iscsi, lun, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { @@ -179,7 +179,7 @@ test5: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -189,7 +189,7 @@ test5: && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { printf("Got BUS RESET. Retry accessing the LUN\n"); goto test5; - + } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); diff --git a/test-tool/0422_reserve6_logout.c b/test-tool/0422_reserve6_logout.c index e30d597..102ccd4 100644 --- a/test-tool/0422_reserve6_logout.c +++ b/test-tool/0422_reserve6_logout.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.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 _U_, + int show_info) +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -48,7 +49,7 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -69,8 +70,8 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -79,9 +80,9 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss, } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } @@ -94,7 +95,7 @@ test2: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -116,7 +117,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -131,18 +132,16 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Logout the first initiator ... "); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); printf("[OK]\n"); -test5: printf("Verify we can access the LUN from the second initiator ... "); task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; diff --git a/test-tool/0423_reserve6_sessionloss.c b/test-tool/0423_reserve6_sessionloss.c index 94e4b78..c2683c5 100644 --- a/test-tool/0423_reserve6_sessionloss.c +++ b/test-tool/0423_reserve6_sessionloss.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -22,8 +22,9 @@ #include "scsi-lowlevel.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 _U_, int show_info) +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -48,7 +49,7 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_ return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -69,8 +70,8 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_ goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -79,9 +80,9 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_ } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } @@ -94,7 +95,7 @@ test2: task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -116,7 +117,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -131,17 +132,15 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Drop the session to the first initiator ... "); iscsi_destroy_context(iscsi); printf("[OK]\n"); -test5: printf("Verify we can access the LUN from the second initiator ... "); task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; diff --git a/test-tool/0424_reserve6_target_reset.c b/test-tool/0424_reserve6_target_reset.c index b9fd07d..ac62ab2 100644 --- a/test-tool/0424_reserve6_target_reset.c +++ b/test-tool/0424_reserve6_target_reset.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -37,8 +37,9 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, mgmt_task->finished = 1; } -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 _U_, int show_info) +{ struct iscsi_context *iscsi, *iscsi2; struct scsi_task *task; int ret, lun; @@ -65,7 +66,7 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data return -1; } - iscsi2 = iscsi_context_login(initiator2, url, &lun); + iscsi2 = iscsi_context_login(initiatorname2, url, &lun); if (iscsi2 == NULL) { printf("Failed to login to target\n"); return -1; @@ -73,9 +74,6 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data ret = 0; - - - printf("Send RESERVE6 from the first initiator ... "); task = iscsi_reserve6_sync(iscsi, lun); if (task == NULL) { @@ -86,8 +84,8 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST - && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST + && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); printf("RESERVE6 Not Supported\n"); ret = -2; @@ -96,22 +94,21 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, int data } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("RESERVE6 failed with sense:%s\n", + printf("RESERVE6 failed with sense:%s\n", iscsi_get_error(iscsi)); - ret = -1; + ret = -1; scsi_free_scsi_task(task); goto test2; } scsi_free_scsi_task(task); printf("[OK]\n"); - test2: printf("Verify we can access the LUN from the first initiator ... "); task = iscsi_testunitready_sync(iscsi, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -133,7 +130,7 @@ test3: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -148,7 +145,6 @@ test3: scsi_free_scsi_task(task); printf("[OK]\n"); -test4: printf("Send a Target Cold-Reset ... "); iscsi_task_mgmt_target_cold_reset_async(iscsi, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { @@ -179,7 +175,7 @@ test5: task = iscsi_testunitready_sync(iscsi2, lun); if (task == NULL) { 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)); ret = -1; goto finished; @@ -189,7 +185,7 @@ test5: && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { printf("Got BUS RESET. Retry accessing the LUN\n"); goto test5; - + } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); diff --git a/test-tool/0430_report_all_supported_ops.c b/test-tool/0430_report_all_supported_ops.c index 2ba1340..19cd61a 100644 --- a/test-tool/0430_report_all_supported_ops.c +++ b/test-tool/0430_report_all_supported_ops.c @@ -1,17 +1,17 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg Copyright (C) 2012 by Jon Grimm - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -23,14 +23,16 @@ #include "scsi-lowlevel.h" #include "iscsi-test.h" -int T0430_report_all_supported_ops(const char *initiator, const char *url, int data_loss, int show_info) -{ +int T0430_report_all_supported_ops(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ struct iscsi_context *iscsi; struct scsi_task *task; struct scsi_report_supported_op_codes *rsoc; struct scsi_command_descriptor *desc; - int ret, lun, i; + int ret, lun; int full_size, desc_size; + unsigned i; printf("0430_report_all_supported_ops:\n"); printf("===================\n"); @@ -55,7 +57,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d task = iscsi_report_supported_opcodes_sync(iscsi, lun, 0, 4); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send Report Supported Opcodes command : %s\n", + printf("Failed to send Report Supported Opcodes command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; @@ -64,7 +66,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[SKIPPED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -2; @@ -72,7 +74,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; @@ -101,7 +103,7 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d printf("Supported Commands: %d\n", rsoc->num_descriptors); printf("=======================\n"); - for (i=0; i < rsoc->num_descriptors; i++) { + for (i = 0; i < rsoc->num_descriptors; i++) { printf("op:%x\tsa:%x\tcdb length:%d\n", rsoc->descriptors[i].op_code, rsoc->descriptors[i].service_action, @@ -111,25 +113,23 @@ int T0430_report_all_supported_ops(const char *initiator, const char *url, int d printf("\n[OK]\n"); scsi_free_scsi_task(task); - -test2: /*Report All Supported Operations including timeout info.*/ printf("See if Report Supported Opcodes with Timeouts is supported... "); /* See how big data is */ task = iscsi_report_supported_opcodes_sync(iscsi, lun, 1, 4); if (task == NULL) { printf("[FAILED]\n"); - printf("Failed to send Report Supported Opcodes command : %s\n", + printf("Failed to send Report Supported Opcodes command : %s\n", iscsi_get_error(iscsi)); ret = -1; goto finished; } if (task->status == SCSI_STATUS_CHECK_CONDITION && 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 || task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB)) { printf("[SKIPPED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -2; @@ -137,7 +137,7 @@ test2: } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); - printf("REPORT SUPPORTED OPCODES command failed : %s\n", + printf("REPORT SUPPORTED OPCODES command failed : %s\n", iscsi_get_error(iscsi)); scsi_free_scsi_task(task); ret = -1; @@ -170,7 +170,7 @@ test2: desc_size = sizeof (struct scsi_command_descriptor) + sizeof (struct scsi_op_timeout_descriptor); desc = &rsoc->descriptors[0]; - for (i=0; i < rsoc->num_descriptors; i++) { + for (i = 0; i < rsoc->num_descriptors; i++) { printf("op:%x\tsa:%x\tcdb_length:%d\ttimeout info: length:%d\tcommand specific:%x\tnominal processing%d\trecommended%d\n", desc->op_code, desc->service_action, @@ -179,7 +179,7 @@ test2: desc->to[0].command_specific, desc->to[0].nominal_processing_timeout, desc->to[0].recommended_timeout); - desc = (struct scsi_command_descriptor *)((char *)desc + + desc = (struct scsi_command_descriptor *)((char *)desc + desc_size); } diff --git a/test-tool/1030_unsolicited_data_overflow.c b/test-tool/1030_unsolicited_data_overflow.c index b5dd350..3a2b581 100644 --- a/test-tool/1030_unsolicited_data_overflow.c +++ b/test-tool/1030_unsolicited_data_overflow.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -40,14 +40,14 @@ static void test_cb(struct iscsi_context *iscsi _U_, int status, } int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int data_loss, int show_info) -{ - struct iscsi_context *iscsi, *iscsi2; +{ + struct iscsi_context *iscsi = NULL; + struct iscsi_context *iscsi2 = NULL; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int ret, lun; unsigned char *buf = NULL; struct iscsi_async_state test_state; - uint32_t old_first_burst_len; printf("1030_unsolicited_data_overflow:\n"); printf("===============================\n"); @@ -99,7 +99,7 @@ int T1030_unsolicited_data_overflow(const char *initiator, const char *url, int ret = 0; iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_YES; - old_first_burst_len = iscsi->first_burst_length; + /* make first burst REAL big */ iscsi->first_burst_length *= 16; buf = malloc(iscsi->first_burst_length); @@ -141,9 +141,7 @@ test2: printf("[OK]\n"); finished: - if (buf) { - free(buf); - } + free(buf); iscsi_destroy_context(iscsi); iscsi_destroy_context(iscsi2); return ret; diff --git a/test-tool/1031_unsolicited_data_out.c b/test-tool/1031_unsolicited_data_out.c index 1ba1b81..7c823ae 100644 --- a/test-tool/1031_unsolicited_data_out.c +++ b/test-tool/1031_unsolicited_data_out.c @@ -1,16 +1,16 @@ -/* +/* Copyright (C) 2012 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -27,7 +27,7 @@ uint32_t block_size; static int -my_iscsi_add_data(struct iscsi_context *iscsi, struct iscsi_data *data, +my_iscsi_add_data(struct iscsi_context *iscsi _U_, struct iscsi_data *data, unsigned char *dptr, int dsize, int pdualignment) { int len, aligned; @@ -149,9 +149,11 @@ my_iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opc return pdu; } -int T1031_unsolicited_data_out(const char *initiator, const char *url, int data_loss, int show_info) -{ - struct iscsi_context *iscsi, *iscsi2; +int T1031_unsolicited_data_out(const char *initiator, const char *url, + int data_loss _U_, int show_info) +{ + struct iscsi_context *iscsi = NULL; + struct iscsi_context *iscsi2 = NULL; struct scsi_task *task; struct scsi_readcapacity16 *rc16; int i, ret, lun; diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index 27e61cf..948bbfc 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -1,18 +1,18 @@ -/* +/* iscsi-test tool Copyright (C) 2010 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ @@ -34,8 +34,8 @@ #include "iscsi-private.h" #include "iscsi-test.h" -const char *initiator = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test"; -const char *initiator2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2"; +const char *initiatorname1 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test"; +const char *initiatorname2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2"; static int data_loss = 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); 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_destroy_context(iscsi); 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 }, { "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 }, - { "initiator-name", 'i', POPT_ARG_STRING, &initiator, 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", 'i', POPT_ARG_STRING, &initiatorname1, 0, "Initiatorname to use", "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" }, { "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" }, @@ -427,7 +427,7 @@ int main(int argc, const char *argv[]) for (test = &tests[0]; test->name; test++) { printf("%s\n", test->name); if (show_info) { - test->test(initiator, url, data_loss, show_info); + test->test(initiatorname1, url, data_loss, show_info); } } exit(0); @@ -438,7 +438,7 @@ int main(int argc, const char *argv[]) fprintf(stderr, "You must specify the URL\n"); print_usage(); free(skipname); - free(testname); + free(testname); exit(10); } @@ -447,7 +447,7 @@ int main(int argc, const char *argv[]) if (testname != NULL && fnmatch(testname, test->name, 0)) { continue; } - + if (skipname != NULL) { char * pchr = skipname; char * pchr2 = NULL; @@ -463,7 +463,7 @@ int main(int argc, const char *argv[]) if (skip) continue; } - res = test->test(initiator, url, data_loss, show_info); + res = test->test(initiatorname1, url, data_loss, show_info); if (res == 0) { printf("TEST %s [OK]\n", test->name); } else if (res == -2) { @@ -482,4 +482,3 @@ int main(int argc, const char *argv[]) return num_failed ? num_failed : num_skipped ? 77 : 0; } - diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index d597773..3327280 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -1,24 +1,24 @@ -/* +/* iscsi-test tool Copyright (C) 2010 by Ronnie Sahlberg - + 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, see . */ -extern const char *initiator; -extern const char *initiator2; +extern const char *initiatorname1; +extern const char *initiatorname2; 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 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); -