merge fixup
This commit is contained in:
@@ -56,6 +56,7 @@ dist_noinst_HEADERS += test-tool/iscsi-test.h
|
||||
bin_iscsi_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/test-tool
|
||||
bin_iscsi_test_LDFLAGS = -ldl
|
||||
bin_iscsi_test_SOURCES = test-tool/iscsi-test.c \
|
||||
test-tool/0000_testunitready_simple.c \
|
||||
test-tool/0100_read10_simple.c test-tool/0101_read10_beyond_eol.c \
|
||||
test-tool/0102_read10_0blocks.c test-tool/0103_read10_rdprotect.c \
|
||||
test-tool/0104_read10_flags.c test-tool/0105_read10_invalid.c \
|
||||
@@ -128,6 +129,10 @@ bin_iscsi_test_SOURCES = test-tool/iscsi-test.c \
|
||||
test-tool/0386_preventallow_2_it_nexuses.c \
|
||||
test-tool/0390_mandatory_opcodes_sbc.c \
|
||||
test-tool/0400_inquiry_basic.c \
|
||||
test-tool/0401_inquiry_alloclen.c \
|
||||
test-tool/0402_inquiry_evpd.c \
|
||||
test-tool/0403_inquiry_supported_vpd.c \
|
||||
test-tool/0404_inquiry_all_reported_vpd.c \
|
||||
test-tool/0410_readtoc_basic.c \
|
||||
\
|
||||
test-tool/1000_cmdsn_invalid.c \
|
||||
|
||||
@@ -208,7 +208,11 @@ scsi_reportluns_cdb(int report_type, int alloc_len)
|
||||
*(uint32_t *)&task->cdb[6] = htonl(alloc_len);
|
||||
|
||||
task->cdb_size = 12;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
if (alloc_len != 0) {
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = alloc_len;
|
||||
|
||||
task->params.reportluns.report_type = report_type;
|
||||
@@ -571,7 +575,11 @@ scsi_cdb_inquiry(int evpd, int page_code, int alloc_len)
|
||||
*(uint16_t *)&task->cdb[3] = htons(alloc_len);
|
||||
|
||||
task->cdb_size = 6;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
if (alloc_len != 0) {
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = alloc_len;
|
||||
|
||||
task->params.inquiry.evpd = evpd;
|
||||
@@ -853,7 +861,11 @@ scsi_cdb_read6(uint32_t lba, uint32_t xferlen, int blocksize)
|
||||
task->cdb[4] = num_blocks;
|
||||
}
|
||||
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
if (xferlen != 0) {
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = xferlen;
|
||||
|
||||
task->params.read6.lba = lba;
|
||||
@@ -1396,7 +1408,11 @@ scsi_cdb_unmap(int anchor, int group, uint16_t xferlen)
|
||||
*(uint16_t *)&task->cdb[7] = htons(xferlen);
|
||||
|
||||
task->cdb_size = 10;
|
||||
task->xfer_dir = SCSI_XFER_WRITE;
|
||||
if (xferlen != 0) {
|
||||
task->xfer_dir = SCSI_XFER_WRITE;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = xferlen;
|
||||
|
||||
return task;
|
||||
@@ -1517,7 +1533,11 @@ scsi_cdb_modesense6(int dbd, enum scsi_modesense_page_control pc,
|
||||
task->cdb[4] = alloc_len;
|
||||
|
||||
task->cdb_size = 6;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
if (alloc_len != 0) {
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = alloc_len;
|
||||
|
||||
task->params.modesense6.dbd = dbd;
|
||||
@@ -1899,7 +1919,11 @@ scsi_cdb_serviceactionin16(enum scsi_service_action_in sa, uint32_t xferlen)
|
||||
*(uint32_t *)&task->cdb[10] = htonl(xferlen);
|
||||
|
||||
task->cdb_size = 16;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
if (xferlen != 0) {
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = xferlen;
|
||||
|
||||
task->params.serviceactionin.sa = sa;
|
||||
@@ -1939,7 +1963,11 @@ scsi_cdb_get_lba_status(uint64_t starting_lba, uint32_t alloc_len)
|
||||
*(uint32_t *)&task->cdb[10] = htonl(alloc_len);
|
||||
|
||||
task->cdb_size = 16;
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
if (alloc_len != 0) {
|
||||
task->xfer_dir = SCSI_XFER_READ;
|
||||
} else {
|
||||
task->xfer_dir = SCSI_XFER_NONE;
|
||||
}
|
||||
task->expxferlen = alloc_len;
|
||||
|
||||
task->params.serviceactionin.sa = SCSI_GET_LBA_STATUS;
|
||||
|
||||
69
test-tool/0000_testunitready_simple.c
Normal file
69
test-tool/0000_testunitready_simple.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#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;
|
||||
|
||||
printf("0000_testunitready_simple:\n");
|
||||
printf("===================\n");
|
||||
if (show_info) {
|
||||
printf("Test basic TESTUNITREADY functionality.\n");
|
||||
printf("1, Verify TESTUNITREADY works.\n");
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
iscsi = iscsi_context_login(initiator, url, &lun);
|
||||
if (iscsi == NULL) {
|
||||
printf("Failed to login to target\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
printf("Test TESTUNITREADY ... ");
|
||||
task = iscsi_testunitready_sync(iscsi, lun);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi));
|
||||
ret++;
|
||||
goto test2;
|
||||
}
|
||||
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;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
test2:
|
||||
|
||||
finished:
|
||||
iscsi_logout_sync(iscsi);
|
||||
iscsi_destroy_context(iscsi);
|
||||
return ret;
|
||||
}
|
||||
@@ -186,36 +186,54 @@ test8:
|
||||
test9:
|
||||
printf("Verify VENDOR_IDENTIFICATION is in ASCII ... ");
|
||||
for (i = 8; i < 16; i++) {
|
||||
if (!isascii(task->datain.data[i])) {
|
||||
printf("[FAILED]\n");
|
||||
printf("VENDOR_IDENTIFICATION contains non-ASCII characters\n");
|
||||
ret = -1;
|
||||
goto test10;
|
||||
/* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
|
||||
if (task->datain.data[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
goto test10;
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
test10:
|
||||
printf("Verify PRODUCT_IDENTIFICATION is in ASCII ... ");
|
||||
for (i = 16; i < 32; i++) {
|
||||
if (!isascii(task->datain.data[i])) {
|
||||
printf("[FAILED]\n");
|
||||
printf("PRODUCT_IDENTIFICATION contains non-ASCII characters\n");
|
||||
ret = -1;
|
||||
goto test11;
|
||||
/* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
|
||||
if (task->datain.data[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
goto test11;
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
test11:
|
||||
printf("Verify PRODUCT_REVISION_LEVEL is in ASCII ... ");
|
||||
for (i = 32; i < 36; i++) {
|
||||
if (!isascii(task->datain.data[i])) {
|
||||
printf("[FAILED]\n");
|
||||
printf("PRODUCT_REVISION_LEVEL contains non-ASCII characters\n");
|
||||
ret = -1;
|
||||
goto test12;
|
||||
/* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
|
||||
if (task->datain.data[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("[FAILED]\n");
|
||||
printf("PRODUCT_REVISION_LEVEL contains non-ASCII characters\n");
|
||||
ret = -1;
|
||||
goto test12;
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
|
||||
80
test-tool/0401_inquiry_alloclen.c
Normal file
80
test-tool/0401_inquiry_alloclen.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test.h"
|
||||
|
||||
int T0401_inquiry_alloclen(const char *initiator, const char *url, int data_loss, 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");
|
||||
if (show_info) {
|
||||
printf("Test INQUIRY with alloclen 0-255.\n");
|
||||
printf("1, Test standard inquiry with alloclen 0-255 is successful\n");
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
iscsi = iscsi_context_login(initiator, url, &lun);
|
||||
if (iscsi == NULL) {
|
||||
printf("Failed to login to target\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
|
||||
printf("Test INQUIRY with alloclen 0-255 ... ");
|
||||
for (i = 0; i < 256; i++) {
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, 0, i);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test2;
|
||||
}
|
||||
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;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
test2:
|
||||
|
||||
|
||||
finished:
|
||||
iscsi_logout_sync(iscsi);
|
||||
iscsi_destroy_context(iscsi);
|
||||
return ret;
|
||||
}
|
||||
87
test-tool/0402_inquiry_evpd.c
Normal file
87
test-tool/0402_inquiry_evpd.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test.h"
|
||||
|
||||
int T0402_inquiry_evpd(const char *initiator, const char *url, int data_loss, int show_info)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
int ret, lun, i;
|
||||
|
||||
printf("0402_inquiry_evpd:\n");
|
||||
printf("===================\n");
|
||||
if (show_info) {
|
||||
printf("Test the EVPD flag.\n");
|
||||
printf("1, Test that EVPD==0 and PC!=0 is an error\n");
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
iscsi = iscsi_context_login(initiator, url, &lun);
|
||||
if (iscsi == NULL) {
|
||||
printf("Failed to login to target\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
|
||||
printf("Test INQUIRY with EVPD==0 and PC!=0 ... ");
|
||||
for (i = 1; i < 256; i++) {
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 0, i, 255);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test2;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
|
||||
printf("[FAILED]\n");
|
||||
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;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
test2:
|
||||
|
||||
|
||||
finished:
|
||||
iscsi_logout_sync(iscsi);
|
||||
iscsi_destroy_context(iscsi);
|
||||
return ret;
|
||||
}
|
||||
124
test-tool/0403_inquiry_supported_vpd.c
Normal file
124
test-tool/0403_inquiry_supported_vpd.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "iscsi.h"
|
||||
#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)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_supported_pages *inq;
|
||||
int ret, lun, i, j;
|
||||
int full_size;
|
||||
int page_code;
|
||||
enum scsi_inquiry_pagecode required_spc_pages[] = {
|
||||
SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES,
|
||||
SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION
|
||||
};
|
||||
|
||||
printf("0403_inquiry_supported_vpd:\n");
|
||||
printf("==========================\n");
|
||||
if (show_info) {
|
||||
printf("Check the INQUIRY SUPPORTED VPD page.\n");
|
||||
printf("1, Check we can read the SUPPORTED VPD page.\n");
|
||||
printf("2, Verify we have all mandatory SPC VPD pages\n");
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
iscsi = iscsi_context_login(initiator, url, &lun);
|
||||
if (iscsi == NULL) {
|
||||
printf("Failed to login to target\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
|
||||
printf("Read SUPPORTED VPD data ... ");
|
||||
/* See how big this inquiry data is */
|
||||
page_code = SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES;
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 1, page_code, 255);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("INQUIRY command failed : %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 1, page_code, full_size)) == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
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]);
|
||||
for (j = 0; j < inq->num_pages; j++) {
|
||||
if (required_spc_pages[i] == inq->pages[j]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == inq->num_pages) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Target did not report page 0x%02x. This page is mandatory in SPC.\n", required_spc_pages[i]);
|
||||
ret = -1;
|
||||
} else {
|
||||
printf("[OK]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
test3:
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
finished:
|
||||
iscsi_logout_sync(iscsi);
|
||||
iscsi_destroy_context(iscsi);
|
||||
return ret;
|
||||
}
|
||||
160
test-tool/0404_inquiry_all_reported_vpd.c
Normal file
160
test-tool/0404_inquiry_all_reported_vpd.c
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "iscsi.h"
|
||||
#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)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
struct scsi_inquiry_supported_pages *inq;
|
||||
int ret, lun, i;
|
||||
int full_size;
|
||||
enum scsi_inquiry_pagecode page_code;
|
||||
|
||||
printf("0404_inquiry_all_reported_vpd:\n");
|
||||
printf("==========================\n");
|
||||
if (show_info) {
|
||||
printf("Check the INQUIRY SUPPORTED VPD page.\n");
|
||||
printf("1, Check we can read the SUPPORTED VPD page.\n");
|
||||
printf("2, Verify we can read each reported page and check the qualifier,device-type and page code on the returned data\n");
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
iscsi = iscsi_context_login(initiator, url, &lun);
|
||||
if (iscsi == NULL) {
|
||||
printf("Failed to login to target\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
|
||||
printf("Read SUPPORTED VPD data ... ");
|
||||
/* See how big this inquiry data is */
|
||||
page_code = SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES;
|
||||
task = iscsi_inquiry_sync(iscsi, lun, 1, page_code, 255);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("INQUIRY command failed : %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
/* we need more data for the full list */
|
||||
if ((task = iscsi_inquiry_sync(iscsi, lun, 1, page_code, full_size)) == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
inq = scsi_datain_unmarshall(task);
|
||||
if (inq == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto finished;
|
||||
}
|
||||
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;
|
||||
|
||||
printf("Verify page 0x%02x can be read ... ", inq->pages[i]);
|
||||
pc_task = iscsi_inquiry_sync(iscsi, lun, 1, inq->pages[i], 255);
|
||||
if (pc_task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
continue;
|
||||
}
|
||||
if (pc_task->status != SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to read VPD page : %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(pc_task);
|
||||
ret = -1;
|
||||
continue;
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
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));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(pc_task);
|
||||
continue;
|
||||
} else {
|
||||
printf("[OK]\n");
|
||||
}
|
||||
|
||||
printf("Verify page 0x%02x device type ... ", inq->pages[i]);
|
||||
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));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(pc_task);
|
||||
continue;
|
||||
} else {
|
||||
printf("[OK]\n");
|
||||
}
|
||||
|
||||
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));
|
||||
ret = -1;
|
||||
scsi_free_scsi_task(pc_task);
|
||||
continue;
|
||||
} else {
|
||||
printf("[OK]\n");
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(pc_task);
|
||||
}
|
||||
|
||||
|
||||
test3:
|
||||
scsi_free_scsi_task(task);
|
||||
|
||||
finished:
|
||||
iscsi_logout_sync(iscsi);
|
||||
iscsi_destroy_context(iscsi);
|
||||
return ret;
|
||||
}
|
||||
@@ -46,6 +46,9 @@ struct scsi_test {
|
||||
struct scsi_test tests[] = {
|
||||
/* SCSI protocol tests */
|
||||
|
||||
/* testunitready*/
|
||||
{ "T0000_testunitready_simple", T0000_testunitready_simple },
|
||||
|
||||
/* read10*/
|
||||
{ "T0100_read10_simple", T0100_read10_simple },
|
||||
{ "T0101_read10_beyond_eol", T0101_read10_beyond_eol },
|
||||
@@ -203,6 +206,10 @@ struct scsi_test tests[] = {
|
||||
|
||||
/* inquiry*/
|
||||
{ "T0400_inquiry_basic", T0400_inquiry_basic },
|
||||
{ "T0401_inquiry_alloclen", T0401_inquiry_alloclen },
|
||||
{ "T0402_inquiry_evpd", T0402_inquiry_evpd },
|
||||
{ "T0403_inquiry_supported_vpd", T0403_inquiry_supported_vpd },
|
||||
{ "T0404_inquiry_all_reported_vpd", T0404_inquiry_all_reported_vpd },
|
||||
|
||||
/* read TOC/PMA/ATIP */
|
||||
{ "T0410_readtoc_basic", T0410_readtoc_basic },
|
||||
|
||||
@@ -29,6 +29,8 @@ void wait_until_test_finished(struct iscsi_context *iscsi, struct iscsi_async_st
|
||||
struct iscsi_pdu;
|
||||
int (*local_iscsi_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
||||
|
||||
int T0000_testunitready_simple(const char *initiator, const char *url, int data_loss, int show_info);
|
||||
|
||||
int T0100_read10_simple(const char *initiator, const char *url, int data_loss, int show_info);
|
||||
int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_loss, int show_info);
|
||||
int T0102_read10_0blocks(const char *initiator, const char *url, int data_loss, int show_info);
|
||||
@@ -157,6 +159,10 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url, int
|
||||
int T0390_mandatory_opcodes_sbc(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, int show_info);
|
||||
int T0401_inquiry_alloclen(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, int show_info);
|
||||
int T0403_inquiry_supported_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, int show_info);
|
||||
|
||||
int T0410_readtoc_basic(const char *initiator, const char *url, int data_loss, int show_info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user