diff --git a/Makefile.am b/Makefile.am index 53c24ba..c463ef9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -257,6 +257,7 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \ test-tool/test_readonly_sbc.c \ test-tool/test_report_supported_opcodes_simple.c \ test-tool/test_report_supported_opcodes_rctd.c \ + test-tool/test_report_supported_opcodes_servactv.c \ test-tool/test_reserve6_simple.c \ test-tool/test_reserve6_2initiators.c \ test-tool/test_reserve6_logout.c \ diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index 68074c7..b11a1d0 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -224,6 +224,7 @@ static CU_TestInfo tests_readonly[] = { static CU_TestInfo tests_report_supported_opcodes[] = { { (char *)"ReportSupportedOpcodesSimple", test_report_supported_opcodes_simple }, { (char *)"ReportSupportedOpcodesRCTD", test_report_supported_opcodes_rctd }, + { (char *)"ReportSupportedOpcodesSERVACTV", test_report_supported_opcodes_servactv }, CU_TEST_INFO_NULL }; diff --git a/test-tool/iscsi-test-cu.h b/test-tool/iscsi-test-cu.h index 2dd69a8..8078b51 100644 --- a/test-tool/iscsi-test-cu.h +++ b/test-tool/iscsi-test-cu.h @@ -140,6 +140,7 @@ void test_readonly_sbc(void); void test_report_supported_opcodes_simple(void); void test_report_supported_opcodes_rctd(void); +void test_report_supported_opcodes_servactv(void); void test_reserve6_simple(void); void test_reserve6_2initiators(void); diff --git a/test-tool/test_report_supported_opcodes_servactv.c b/test-tool/test_report_supported_opcodes_servactv.c new file mode 100644 index 0000000..06881dd --- /dev/null +++ b/test-tool/test_report_supported_opcodes_servactv.c @@ -0,0 +1,72 @@ +/* + 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_report_supported_opcodes_servactv(void) +{ + int i, ret; + struct scsi_task *rso_task; + struct scsi_report_supported_op_codes *rsoc; + + logging(LOG_VERBOSE, LOG_BLANK_LINE); + logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag"); + + + logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes " + "without timeout descriptors"); + ret = report_supported_opcodes(iscsic, tgt_lun, + 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, + 65535, &rso_task); + if (ret == -2) { + logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " + "implemented."); + CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); + return; + } + CU_ASSERT_EQUAL(ret, 0); + if (ret != 0) { + return; + } + + logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer"); + rsoc = scsi_datain_unmarshall(rso_task); + CU_ASSERT_NOT_EQUAL(rsoc, NULL); + + + logging(LOG_VERBOSE, "Verify that when SERVACTV is clear then " + "ServiceAction must be zero."); + for (i = 0; i < rsoc->num_descriptors; i++) { + if (!rsoc->descriptors[i].servactv && rsoc->descriptors[i].sa) { + logging(LOG_NORMAL, "[FAILED] ServiceAction is " + "non-zero but SERVACTV is clear"); + CU_FAIL("[FAILED] ServiceAction is " + "non-zero but SERVACTV is clear"); + } + } + + scsi_free_scsi_task(rso_task); +}