TESTS: add READCAPACITY16 tests
This commit is contained in:
@@ -197,6 +197,8 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
|
||||
test-tool/test_read16_rdprotect.c \
|
||||
test-tool/test_read16_flags.c \
|
||||
test-tool/test_readcapacity10_simple.c \
|
||||
test-tool/test_readcapacity16_simple.c \
|
||||
test-tool/test_readcapacity16_alloclen.c \
|
||||
test-tool/test_verify10_simple.c \
|
||||
test-tool/test_verify10_beyond_eol.c \
|
||||
test-tool/test_verify10_0blocks.c \
|
||||
|
||||
@@ -1427,6 +1427,39 @@ readcapacity10(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
readcapacity16(struct iscsi_context *iscsi, int lun, int alloc_len)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Send READCAPACITY16 alloc_len:%d", alloc_len);
|
||||
|
||||
task = scsi_cdb_serviceactionin16(SCSI_READCAPACITY16, alloc_len);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "Out-of-memory: Failed to create "
|
||||
"READCAPACITY16 cdb.");
|
||||
return -1;
|
||||
}
|
||||
task = iscsi_scsi_command_sync(iscsi, lun, task, NULL);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send READCAPACITY16 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 command: "
|
||||
"failed with sense. %s", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] READCAPACITY16 returned SUCCESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
verify10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data)
|
||||
{
|
||||
|
||||
@@ -131,6 +131,7 @@ int read16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen,
|
||||
int read16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int read16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int readcapacity10(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi);
|
||||
int readcapacity16(struct iscsi_context *iscsi, int lun, int alloc_len);
|
||||
int verify10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
|
||||
int verify10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
|
||||
int verify10_miscompare(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
|
||||
|
||||
@@ -102,6 +102,12 @@ static CU_TestInfo tests_readcapacity10[] = {
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_TestInfo tests_readcapacity16[] = {
|
||||
{ (char *)"testReadCapacity16Simple", test_readcapacity16_simple },
|
||||
{ (char *)"testReadCapacity16Alloclen", test_readcapacity16_alloclen },
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_TestInfo tests_verify10[] = {
|
||||
{ (char *)"testVerify10Simple", test_verify10_simple },
|
||||
{ (char *)"testVerify10BeyondEol", test_verify10_beyond_eol },
|
||||
@@ -175,6 +181,8 @@ static CU_SuiteInfo suites[] = {
|
||||
tests_read16 },
|
||||
{ (char *)"TestReadCapacity10", test_setup, test_teardown,
|
||||
tests_readcapacity10 },
|
||||
{ (char *)"TestReadCapacity16", test_setup, test_teardown,
|
||||
tests_readcapacity16 },
|
||||
{ (char *)"TestVerify10", test_setup, test_teardown,
|
||||
tests_verify10 },
|
||||
{ (char *)"TestVerify12", test_setup, test_teardown,
|
||||
|
||||
@@ -64,6 +64,9 @@ void test_read16_flags(void);
|
||||
|
||||
void test_readcapacity10_simple(void);
|
||||
|
||||
void test_readcapacity16_simple(void);
|
||||
void test_readcapacity16_alloclen(void);
|
||||
|
||||
void test_verify10_simple(void);
|
||||
void test_verify10_beyond_eol(void);
|
||||
void test_verify10_0blocks(void);
|
||||
|
||||
42
test-tool/test_readcapacity16_alloclen.c
Normal file
42
test-tool/test_readcapacity16_alloclen.c
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 2013 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 <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-support.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_readcapacity16_alloclen(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "");
|
||||
logging(LOG_VERBOSE, "Test that READCAPACITY16 with alloc_len 0-15 is not an error");
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
ret = readcapacity16(iscsic, tgt_lun, i);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
40
test-tool/test_readcapacity16_simple.c
Normal file
40
test-tool/test_readcapacity16_simple.c
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 2013 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 <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-support.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_readcapacity16_simple(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "");
|
||||
logging(LOG_VERBOSE, "Test that READCAPACITY16 works");
|
||||
|
||||
ret = readcapacity16(iscsic, tgt_lun, 16);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user