TESTS: simple support for READDEFECTDATA10/12

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-09-22 22:43:16 -07:00
parent 01a8e22207
commit 39001203b7
14 changed files with 409 additions and 1 deletions

View File

@@ -104,6 +104,8 @@ iscsi_test_cu_SOURCES = iscsi-test-cu.c \
test_readcapacity16_protection.c \
test_readcapacity16_simple.c \
test_readcapacity16_support.c \
test_readdefectdata10_simple.c \
test_readdefectdata12_simple.c \
test_readonly_sbc.c \
test_receive_copy_results_copy_status.c \
test_receive_copy_results_op_params.c \

View File

@@ -2008,6 +2008,70 @@ readcapacity16(struct scsi_device *sdev, struct scsi_task **out_task, int alloc_
return ret;
}
int
readdefectdata10(struct scsi_device *sdev, struct scsi_task **out_task,
int req_plist, int req_glist,
int defect_list_format, uint16_t alloc_len,
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
struct scsi_task *task;
int ret;
logging(LOG_VERBOSE, "Send READDEFECTDATA10 (Expecting %s)"
" req_plist:%d req_glist:%d format:%d",
scsi_status_str(status),
req_plist, req_glist, defect_list_format);
task = scsi_cdb_readdefectdata10(req_plist, req_glist,
defect_list_format, alloc_len);
assert(task != NULL);
task = send_scsi_command(sdev, task, NULL);
ret = check_result("READDEFECTDATA10", sdev, task,
status, key, ascq, num_ascq);
if (out_task) {
*out_task = task;
} else if (task) {
scsi_free_scsi_task(task);
}
return ret;
}
int
readdefectdata12(struct scsi_device *sdev, struct scsi_task **out_task,
int req_plist, int req_glist,
int defect_list_format,
uint32_t address_descriptor_index,
uint32_t alloc_len,
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
struct scsi_task *task;
int ret;
logging(LOG_VERBOSE, "Send READDEFECTDATA12 (Expecting %s)"
" req_plist:%d req_glist:%d format:%d",
scsi_status_str(status),
req_plist, req_glist, defect_list_format);
task = scsi_cdb_readdefectdata12(req_plist, req_glist,
defect_list_format,
address_descriptor_index,
alloc_len);
assert(task != NULL);
task = send_scsi_command(sdev, task, NULL);
ret = check_result("READDEFECTDATA12", sdev, task,
status, key, ascq, num_ascq);
if (out_task) {
*out_task = task;
} else if (task) {
scsi_free_scsi_task(task);
}
return ret;
}
int
release6(struct scsi_device *sdev)
{

View File

@@ -389,6 +389,34 @@ do { \
CU_ASSERT_EQUAL(_r, 0); \
} while (0);
#define READDEFECTDATA10(...) \
do { \
int _r; \
_r = readdefectdata10(__VA_ARGS__); \
if (_r == -2) { \
logging(LOG_NORMAL, "[SKIPPED] READDEFECTDATA10 " \
"is not implemented."); \
CU_PASS("[SKIPPED] Target does not support " \
"READDEFECTDATA10. Skipping test"); \
return; \
} \
CU_ASSERT_EQUAL(_r, 0); \
} while (0);
#define READDEFECTDATA12(...) \
do { \
int _r; \
_r = readdefectdata12(__VA_ARGS__); \
if (_r == -2) { \
logging(LOG_NORMAL, "[SKIPPED] READDEFECTDATA12 " \
"is not implemented."); \
CU_PASS("[SKIPPED] Target does not support " \
"READDEFECTDATA12. Skipping test"); \
return; \
} \
CU_ASSERT_EQUAL(_r, 0); \
} while (0);
#define RECEIVE_COPY_RESULTS(...) \
do { \
int _r; \
@@ -833,6 +861,18 @@ int read12(struct scsi_device *sdev, struct scsi_task **task, uint32_t lba, uint
int read16(struct scsi_device *sdev, struct scsi_task **task, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int readcapacity10(struct scsi_device *sdev, struct scsi_task **task, uint32_t lba, int pmi, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int readcapacity16(struct scsi_device *sdev, struct scsi_task **task, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int readdefectdata10(struct scsi_device *sdev, struct scsi_task **task,
int req_plist, int req_glist,
int defect_list_format, uint16_t alloc_len,
int status, enum scsi_sense_key key,
int *ascq, int num_ascq);
int readdefectdata12(struct scsi_device *sdev, struct scsi_task **task,
int req_plist, int req_glist,
int defect_list_format,
uint32_t address_descriptor_index,
uint32_t alloc_len,
int status, enum scsi_sense_key key,
int *ascq, int num_ascq);
int report_supported_opcodes(struct scsi_device *sdev, struct scsi_task **save_task, int rctd, int options, int opcode, int sa, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int release6(struct scsi_device *sdev);
int reserve6(struct scsi_device *sdev);

View File

@@ -265,6 +265,16 @@ static CU_TestInfo tests_readcapacity16[] = {
CU_TEST_INFO_NULL
};
static CU_TestInfo tests_readdefectdata10[] = {
{ (char *)"Simple", test_readdefectdata10_simple },
CU_TEST_INFO_NULL
};
static CU_TestInfo tests_readdefectdata12[] = {
{ (char *)"Simple", test_readdefectdata12_simple },
CU_TEST_INFO_NULL
};
static CU_TestInfo tests_readonly[] = {
{ (char *)"ReadOnlySBC", test_readonly_sbc },
CU_TEST_INFO_NULL
@@ -516,6 +526,8 @@ static libiscsi_suite_info scsi_suites[] = {
{ "Read16", NON_PGR_FUNCS, tests_read16 },
{ "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
{ "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
{ "ReadDefectData10", NON_PGR_FUNCS, tests_readdefectdata10 },
{ "ReadDefectData12", NON_PGR_FUNCS, tests_readdefectdata12 },
{ "ReadOnly", NON_PGR_FUNCS, tests_readonly },
{ "ReceiveCopyResults", NON_PGR_FUNCS, tests_receive_copy_results },
{ "ReportSupportedOpcodes", NON_PGR_FUNCS,
@@ -611,6 +623,8 @@ static libiscsi_suite_info all_suites[] = {
{ "Read16", NON_PGR_FUNCS, tests_read16 },
{ "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
{ "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
{ "ReadDefectData10", NON_PGR_FUNCS, tests_readdefectdata10 },
{ "ReadDefectData12", NON_PGR_FUNCS, tests_readdefectdata12 },
{ "ReadOnly", NON_PGR_FUNCS, tests_readonly },
{ "ReceiveCopyResults", NON_PGR_FUNCS, tests_receive_copy_results },
{ "ReportSupportedOpcodes", NON_PGR_FUNCS,
@@ -654,6 +668,8 @@ static libiscsi_suite_info linux_suites[] = {
{ "Read16", NON_PGR_FUNCS, tests_read16 },
{ "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
{ "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
{ "ReadDefectData10", NON_PGR_FUNCS, tests_readdefectdata10 },
{ "ReadDefectData12", NON_PGR_FUNCS, tests_readdefectdata12 },
{ "ReadOnly", NON_PGR_FUNCS, tests_readonly },
{ "ReportSupportedOpcodes", NON_PGR_FUNCS,
tests_report_supported_opcodes },

View File

@@ -170,6 +170,10 @@ void test_readcapacity16_protection(void);
void test_readcapacity16_simple(void);
void test_readcapacity16_support(void);
void test_readdefectdata10_simple(void);
void test_readdefectdata12_simple(void);
void test_readonly_sbc(void);
void test_receive_copy_results_copy_status(void);

View File

@@ -0,0 +1,37 @@
/* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
/*
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_readdefectdata10_simple(void)
{
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test basic READDEFECTDATA10");
READDEFECTDATA10(sd, NULL, 0, 0, 0, 32,
EXPECT_STATUS_GOOD);
}

View File

@@ -0,0 +1,37 @@
/* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
/*
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_readdefectdata12_simple(void)
{
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test basic READDEFECTDATA12");
READDEFECTDATA12(sd, NULL, 0, 0, 0, 0, 32,
EXPECT_STATUS_GOOD);
}