TESTS: Add WRITE10 tests
This commit is contained in:
@@ -197,6 +197,11 @@ 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_write10_simple.c \
|
||||
test-tool/test_write10_beyond_eol.c \
|
||||
test-tool/test_write10_0blocks.c \
|
||||
test-tool/test_write10_wrprotect.c \
|
||||
test-tool/test_write10_flags.c \
|
||||
test-tool/test_write12_simple.c \
|
||||
test-tool/test_write12_beyond_eol.c \
|
||||
test-tool/test_write12_0blocks.c \
|
||||
|
||||
@@ -1865,6 +1865,139 @@ verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
write10(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int fua, int fua_nv, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITE10 LBA:%d blocks:%d "
|
||||
"wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, fua, fua_nv, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_write10_sync(iscsi, lun, lba,
|
||||
data, datalen, blocksize,
|
||||
wrprotect, dpo, fua, fua_nv, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITE10 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITE10 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] WRITE10 returned SUCCESS.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
write10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int fua, int fua_nv, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITE10 (Expecting INVALID_FIELD_IN_CDB) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d fua:%d fua_nv:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, fua, fua_nv, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_write10_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, fua, fua_nv, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITE10 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITE10 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITE10 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"INVALID_FIELD_IN_CDB. Sense:%s\n",
|
||||
iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITE10 returned ILLEGAL_REQUEST/INVALID_FIELD_IB_CDB.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
write10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
int dpo, int fua, int fua_nv, int group,
|
||||
unsigned char *data)
|
||||
{
|
||||
struct scsi_task *task;
|
||||
|
||||
logging(LOG_VERBOSE, "Send WRITE10 (Expecting LBA_OUT_OF_RANGE) "
|
||||
"LBA:%d blocks:%d wrprotect:%d "
|
||||
"dpo:%d fua:%d fua_nv:%d group:%d",
|
||||
lba, datalen / blocksize, wrprotect,
|
||||
dpo, fua, fua_nv, group);
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set in. Skipping write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
task = iscsi_write10_sync(iscsi, lun, lba, data, datalen, blocksize,
|
||||
wrprotect, dpo, fua, fua_nv, group);
|
||||
if (task == NULL) {
|
||||
logging(LOG_NORMAL, "[FAILED] Failed to send WRITE10 command: %s",
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITE10 successful but should "
|
||||
"have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE");
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
|
||||
logging(LOG_NORMAL, "[FAILED] WRITE10 failed with wrong sense. "
|
||||
"Should have failed with ILLEGAL_REQUEST/"
|
||||
"LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scsi_free_scsi_task(task);
|
||||
logging(LOG_VERBOSE, "[OK] WRITE10 returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
write12(struct iscsi_context *iscsi, int lun, uint32_t lba,
|
||||
uint32_t datalen, int blocksize, int wrprotect,
|
||||
|
||||
@@ -143,6 +143,9 @@ int verify16(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t
|
||||
int verify16_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||
int verify16_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||
int verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint64_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||
int write10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int write10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int write10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int write12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int write12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
int write12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
|
||||
|
||||
@@ -111,6 +111,15 @@ static CU_TestInfo tests_write12[] = {
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_TestInfo tests_write10[] = {
|
||||
{ (char *)"testWrite10Simple", test_write10_simple },
|
||||
{ (char *)"testWrite10BeyondEol", test_write10_beyond_eol },
|
||||
{ (char *)"testWrite10ZeroBlocks", test_write10_0blocks },
|
||||
{ (char *)"testWrite10WriteProtect", test_write10_wrprotect },
|
||||
{ (char *)"testWrite10Flags", test_write10_flags },
|
||||
CU_TEST_INFO_NULL
|
||||
};
|
||||
|
||||
static CU_TestInfo tests_write16[] = {
|
||||
{ (char *)"testWrite16Simple", test_write16_simple },
|
||||
{ (char *)"testWrite16BeyondEol", test_write16_beyond_eol },
|
||||
@@ -133,6 +142,8 @@ static CU_SuiteInfo suites[] = {
|
||||
tests_read16 },
|
||||
{ (char *)"TestReadCapacity10", test_setup, test_teardown,
|
||||
tests_readcapacity10 },
|
||||
{ (char *)"TestWrite10", test_setup, test_teardown,
|
||||
tests_write10 },
|
||||
{ (char *)"TestWrite12", test_setup, test_teardown,
|
||||
tests_write12 },
|
||||
{ (char *)"TestWrite16", test_setup, test_teardown,
|
||||
|
||||
@@ -64,6 +64,12 @@ void test_read16_flags(void);
|
||||
|
||||
void test_readcapacity10_simple(void);
|
||||
|
||||
void test_write10_simple(void);
|
||||
void test_write10_beyond_eol(void);
|
||||
void test_write10_0blocks(void);
|
||||
void test_write10_wrprotect(void);
|
||||
void test_write10_flags(void);
|
||||
|
||||
void test_write12_simple(void);
|
||||
void test_write12_beyond_eol(void);
|
||||
void test_write12_0blocks(void);
|
||||
|
||||
63
test-tool/test_write10_0blocks.c
Normal file
63
test-tool/test_write10_0blocks.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2013 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-test-cu.h"
|
||||
|
||||
void
|
||||
test_write10_0blocks(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!data_loss) {
|
||||
CU_PASS("[SKIPPED] --dataloss flag is not set. Skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (num_blocks >= 0x80000000) {
|
||||
CU_PASS("LUN is too big for read-beyond-eol tests with WRITE10. Skipping test.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "");
|
||||
logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==0");
|
||||
ret = write10(iscsic, tgt_lun, 0, 0, block_size,
|
||||
0, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 0-blocks one block past end-of-LUN");
|
||||
ret = write10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 0,
|
||||
block_size, 0, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==2^31");
|
||||
ret = write10_lbaoutofrange(iscsic, tgt_lun, 0x80000000, 0,
|
||||
block_size, 0, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==-1");
|
||||
ret = write10_lbaoutofrange(iscsic, tgt_lun, -1, 0, block_size,
|
||||
0, 0, 0, 0, 0, NULL);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
88
test-tool/test_write10_beyond_eol.c
Normal file
88
test-tool/test_write10_beyond_eol.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
Copyright (C) 2013 Ronnie Sahlberg <ronneisahlberg@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-test-cu.h"
|
||||
|
||||
|
||||
void
|
||||
test_write10_beyond_eol(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
if (!data_loss) {
|
||||
CU_PASS("[SKIPPED] --dataloss flag is not set. Skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (num_blocks >= 0x80000000) {
|
||||
CU_PASS("LUN is too big for write-beyond-eol tests with WRITE10. Skipping test.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "");
|
||||
logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks one block beyond the end");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = write10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 2 - i,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==2^31");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = write10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==-1");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = write10_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
|
||||
block_size, 0, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 2-256 blocks all but one block beyond the end");
|
||||
for (i = 2; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = write10_lbaoutofrange(iscsic, tgt_lun, num_blocks,
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
}
|
||||
77
test-tool/test_write10_flags.c
Normal file
77
test-tool/test_write10_flags.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright (C) 2013 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_write10_flags(void)
|
||||
{
|
||||
int ret;
|
||||
unsigned char *buf;
|
||||
|
||||
logging(LOG_VERBOSE, "");
|
||||
logging(LOG_VERBOSE, "Test WRITE10 flags");
|
||||
|
||||
if (!data_loss) {
|
||||
CU_PASS("[SKIPPED] --dataloss flag is not set. Skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
buf = malloc(block_size);
|
||||
logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
|
||||
ret = write10(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 1, 0, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==0");
|
||||
ret = write10(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 1, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==1");
|
||||
ret = write10(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 1, 1, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 with FUA==0 FUA_NV==1");
|
||||
ret = write10(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 0, 0, 1, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1 FUA_NV==1");
|
||||
ret = write10(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
0, 1, 1, 1, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
free(buf);
|
||||
}
|
||||
61
test-tool/test_write10_simple.c
Normal file
61
test-tool/test_write10_simple.c
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 2013 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_write10_simple(void)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
if (!data_loss) {
|
||||
CU_PASS("[SKIPPED] --dataloss flag is not set. Skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "");
|
||||
logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the start of the LUN");
|
||||
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = write10(iscsic, tgt_lun, 0, i * block_size,
|
||||
block_size, 0, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the end of the LUN");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
unsigned char *buf = malloc(block_size * i);
|
||||
|
||||
ret = write10(iscsic, tgt_lun, num_blocks +1 - i,
|
||||
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
|
||||
free(buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
}
|
||||
53
test-tool/test_write10_wrprotect.c
Normal file
53
test-tool/test_write10_wrprotect.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright (C) 2013 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CUnit/CUnit.h>
|
||||
|
||||
#include "iscsi.h"
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test-cu.h"
|
||||
|
||||
void
|
||||
test_write10_wrprotect(void)
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char *buf;
|
||||
|
||||
if (!data_loss) {
|
||||
CU_PASS("[SKIPPED] --dataloss flag is not set. Skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try out different non-zero values for WRPROTECT.
|
||||
* They should all fail.
|
||||
*/
|
||||
logging(LOG_VERBOSE, "");
|
||||
logging(LOG_VERBOSE, "Test WRITE10 with non-zero WRPROTECT");
|
||||
buf = malloc(block_size);
|
||||
for (i = 1; i < 8; i++) {
|
||||
ret = write10_invalidfieldincdb(iscsic, tgt_lun, 0,
|
||||
block_size, block_size,
|
||||
i, 0, 0, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
Reference in New Issue
Block a user