TESTS: convert readcapacity10 test to new framework

This commit is contained in:
Ronnie Sahlberg
2013-01-20 16:22:31 -08:00
parent a57ef69c8e
commit 2a1a7bc2bb
6 changed files with 77 additions and 1 deletions

View File

@@ -182,7 +182,8 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
test-tool/test_read10_0blocks.c \
test-tool/test_read10_rdprotect.c \
test-tool/test_read10_flags.c \
test-tool/test_read10_invalid.c
test-tool/test_read10_invalid.c \
test-tool/test_readcapacity10_simple.c
endif

View File

@@ -1069,6 +1069,32 @@ read10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba,
return 0;
}
int
readcapacity10(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send READCAPACITY10 LBA:%d pmi:%d",
lba, pmi);
task = iscsi_readcapacity10_sync(iscsi, lun, lba, pmi);
if (task == NULL) {
logging(LOG_NORMAL, "[FAILED] Failed to send READCAPACITY10 command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] READCAPACITY10 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] READCAPACITY10 returned SUCCESS.");
return 0;
}
int
verify10(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize)
{

View File

@@ -122,6 +122,7 @@ int prefetch16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, int
int read10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_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 verify10(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize);
int verify10_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize);
int verify10_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize);

View File

@@ -72,11 +72,18 @@ static CU_TestInfo tests_read10[] = {
CU_TEST_INFO_NULL
};
static CU_TestInfo tests_readcapacity10[] = {
{ (char *)"testReadCapacity10Simple", test_readcapacity10_simple },
CU_TEST_INFO_NULL
};
static CU_SuiteInfo suites[] = {
{ (char *)"TestTestUnitReady", test_setup, test_teardown,
tests_testunitready },
{ (char *)"TestRead10", test_setup, test_teardown,
tests_read10 },
{ (char *)"TestReadCapacity10", test_setup, test_teardown,
tests_readcapacity10 },
CU_SUITE_INFO_NULL
};

View File

@@ -44,5 +44,6 @@ void test_read10_rdprotect(void);
void test_read10_flags(void);
void test_read10_invalid(void);
void test_readcapacity10_simple(void);
#endif /* _ISCSI_TEST_CU_H_ */

View 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_readcapacity10_simple(void)
{
int ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test basic READCAPACITY10");
ret = readcapacity10(iscsic, tgt_lun, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}