diff --git a/Makefile.am b/Makefile.am index 9839d89..9d8f412 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,6 +191,7 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \ test-tool/test_inquiry_standard.c \ test-tool/test_inquiry_alloc_length.c \ test-tool/test_inquiry_evpd.c \ + test-tool/test_inquiry_supported_vpd.c \ test-tool/test_nomedia_sbc.c \ test-tool/test_orwrite_simple.c \ test-tool/test_orwrite_beyond_eol.c \ diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 363a869..04911d7 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -5109,7 +5109,7 @@ inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsi { struct scsi_task *task; - logging(LOG_VERBOSE, "Send INQUIRY evpd:%d page_code:%d alloc_len:%d", + logging(LOG_VERBOSE, "Send INQUIRY evpd:%d page_code:%02x alloc_len:%d", evpd, page_code, maxsize); task = iscsi_inquiry_sync(iscsi, lun, evpd, page_code, maxsize); if (task == NULL) { @@ -5139,7 +5139,7 @@ inquiry_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int evpd, int pa { struct scsi_task *task; - logging(LOG_VERBOSE, "Send INQUIRY (Expecting INVALID_FIELD_IN_CDB) evpd:%d page_code:%d alloc_len:%d", + logging(LOG_VERBOSE, "Send INQUIRY (Expecting INVALID_FIELD_IN_CDB) evpd:%d page_code:%02x alloc_len:%d", evpd, page_code, maxsize); task = iscsi_inquiry_sync(iscsi, lun, evpd, page_code, maxsize); if (task == NULL) { diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index 360c1b1..852b897 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -70,6 +70,7 @@ static CU_TestInfo tests_inquiry[] = { { (char *)"testInquiryStandard", test_inquiry_standard }, { (char *)"testInquiryAllocLength", test_inquiry_alloc_length}, { (char *)"testInquiryEVPD", test_inquiry_evpd}, + { (char *)"testInquirySupportedVPD", test_inquiry_supported_vpd}, CU_TEST_INFO_NULL }; diff --git a/test-tool/iscsi-test-cu.h b/test-tool/iscsi-test-cu.h index 11a1bb8..180a0e4 100644 --- a/test-tool/iscsi-test-cu.h +++ b/test-tool/iscsi-test-cu.h @@ -46,6 +46,7 @@ void test_get_lba_status_beyond_eol(void); void test_inquiry_standard(void); void test_inquiry_alloc_length(void); void test_inquiry_evpd(void); +void test_inquiry_supported_vpd(void); void test_nomedia_sbc(void); diff --git a/test-tool/test_inquiry_supported_vpd.c b/test-tool/test_inquiry_supported_vpd.c new file mode 100644 index 0000000..3c81fee --- /dev/null +++ b/test-tool/test_inquiry_supported_vpd.c @@ -0,0 +1,69 @@ +/* + Copyright (C) 2013 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 . +*/ + +#include + +#include + +#include "iscsi.h" +#include "scsi-lowlevel.h" +#include "iscsi-support.h" +#include "iscsi-test-cu.h" + +void +test_inquiry_supported_vpd(void) +{ + int ret, i; + struct scsi_inquiry_supported_pages *inq; + + logging(LOG_VERBOSE, LOG_BLANK_LINE); + logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages"); + + logging(LOG_VERBOSE, "Verify we can read the SUPPORTED VPD page"); + ret = inquiry(iscsic, tgt_lun, + 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, + 255, &task); + CU_ASSERT_EQUAL(ret, 0); + + logging(LOG_VERBOSE, "Verify we got at least 4 bytes of data"); + CU_ASSERT(task->datain.size >= 4); + + logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer"); + inq = scsi_datain_unmarshall(task); + CU_ASSERT_NOT_EQUAL(inq, NULL); + if (inq == NULL) { + logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN " + "buffer"); + return; + } + + logging(LOG_VERBOSE, "Verify we read all the supported pages"); + for (i = 0; i < inq->num_pages; i++) { + logging(LOG_VERBOSE, "Verify we can read page 0x%02x", + inq->pages[i]); + + ret = inquiry(iscsic, tgt_lun, + 1, inq->pages[i], + 255, NULL); + CU_ASSERT_EQUAL(ret, 0); + } + + if (task != NULL) { + scsi_free_scsi_task(task); + task = NULL; + } +}