Tests: Create a global scratch buffer and avoid allocating memory in the tests

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-02-21 07:56:47 -08:00
parent b4e4649ae5
commit f88bcf61cc
89 changed files with 454 additions and 545 deletions

View File

@@ -109,6 +109,7 @@ struct scsi_inquiry_block_limits *inq_bl;
struct scsi_readcapacity16 *rc16;
struct scsi_report_supported_op_codes *rsop;
unsigned char *scratch;
size_t block_size;
uint64_t num_blocks;
int lbppb;

View File

@@ -314,6 +314,7 @@ extern struct scsi_inquiry_block_limits *inq_bl;
extern struct scsi_readcapacity16 *rc16;
extern struct scsi_report_supported_op_codes *rsop;
extern unsigned char *scratch;
extern size_t block_size;
extern uint64_t num_blocks;
extern int lbppb;

View File

@@ -1249,6 +1249,9 @@ main(int argc, char *argv[])
lbppb = 1 << rc16->lbppbe;
}
/* create a really big buffer we can use in the tests */
scratch = malloc(65536 * block_size);
inq_task = NULL;
inquiry(sd, &inq_task, 0, 0, 64, EXPECT_STATUS_GOOD);
if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
@@ -1452,12 +1455,13 @@ main(int argc, char *argv[])
for (i = 0; i < mp_num_sds; i++) {
free_scsi_device(mp_sds[i]);
}
free(scratch);
return 0;
err_sds_free:
for (i = 0; i < mp_num_sds; i++) {
free_scsi_device(mp_sds[i]);
}
free(scratch);
return -1;
}

View File

@@ -34,7 +34,6 @@ test_compareandwrite_dpofua(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(2 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test COMPAREANDWRITE DPO/FUA flags");
@@ -54,13 +53,13 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Read the first block");
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
if (ret == 0)
memcpy(buf + block_size, buf, block_size);
memcpy(scratch + block_size, scratch, block_size);
else
memset(buf, 0xa6, 2 * block_size);
memset(scratch, 0xa6, 2 * block_size);
if (dpofua) {
logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
@@ -72,11 +71,11 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1");
if (dpofua) {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 0, 0,
EXPECT_STATUS_GOOD);
} else {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
}
@@ -89,12 +88,12 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Test COMPAREANDWRITE with FUA==1");
if (dpofua) {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 0, 1, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
@@ -102,12 +101,12 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1 FUA==1");
if (dpofua) {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 1, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -33,7 +33,6 @@ test_compareandwrite_miscompare(void)
{
int i, ret;
unsigned j;
unsigned char *buf = alloca(2 * 256 * block_size);
int maxbl;
CHECK_FOR_DATALOSS;
@@ -50,12 +49,12 @@ test_compareandwrite_miscompare(void)
"start of the LUN. One Byte miscompare in the final block.");
for (i = 1; i < 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
memset(buf, 'A', 2 * i * block_size);
memset(scratch, 'A', 2 * i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
@@ -66,7 +65,7 @@ test_compareandwrite_miscompare(void)
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
buf[i * block_size - 27] = 'C';
scratch[i * block_size - 27] = 'C';
if (i > maxbl) {
logging(LOG_VERBOSE, "Number of blocks %d is greater than "
@@ -74,7 +73,7 @@ test_compareandwrite_miscompare(void)
"Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl);
ret = compareandwrite(sd, 0,
buf, 2 * i * block_size,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
@@ -87,12 +86,12 @@ test_compareandwrite_miscompare(void)
continue;
}
memset(buf + i * block_size, 'B', i * block_size);
memset(scratch + i * block_size, 'B', i * block_size);
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:0 (if they all contain 'A')", i);
ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_MISCOMPARE);
if (ret == -2) {
@@ -105,12 +104,12 @@ test_compareandwrite_miscompare(void)
logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
"they are still unchanged as 'A'", i);
ret = read16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) {
if (buf[j] != 'A') {
if (scratch[j] != 'A') {
logging(LOG_VERBOSE, "[FAILED] Data changed "
"eventhough there was a miscompare");
CU_FAIL("Block was written to");
@@ -125,17 +124,17 @@ test_compareandwrite_miscompare(void)
for (i = 1; i < 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
i, num_blocks - i);
memset(buf, 'A', 2 * i * block_size);
memset(scratch, 'A', 2 * i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
buf[i * block_size - 27] = 'C';
scratch[i * block_size - 27] = 'C';
if (i > maxbl) {
@@ -144,20 +143,20 @@ test_compareandwrite_miscompare(void)
"Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl);
ret = compareandwrite(sd, 0,
buf, 2 * i * block_size,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
continue;
}
memset(buf + i * block_size, 'B', i * block_size);
memset(scratch + i * block_size, 'B', i * block_size);
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:%" PRIu64 " (if they all contain 'A')",
i, num_blocks - i);
ret = compareandwrite(sd, num_blocks - i,
buf, 2 * i * block_size, block_size,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_MISCOMPARE);
CU_ASSERT_EQUAL(ret, 0);
@@ -166,12 +165,12 @@ test_compareandwrite_miscompare(void)
"they are still unchanged as 'A'",
i, num_blocks - i);
ret = read16(sd, NULL, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) {
if (buf[j] != 'A') {
if (scratch[j] != 'A') {
logging(LOG_VERBOSE, "[FAILED] Data changed "
"eventhough there was a miscompare");
CU_FAIL("Block was written to");

View File

@@ -33,7 +33,6 @@ test_compareandwrite_simple(void)
{
int i, ret;
unsigned j;
unsigned char *buf = alloca(2 * 256 * block_size);
int maxbl;
CHECK_FOR_DATALOSS;
@@ -51,12 +50,12 @@ test_compareandwrite_simple(void)
"start of the LUN");
for (i = 1; i < 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
memset(buf, 'A', 2 * i * block_size);
memset(scratch, 'A', 2 * i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
@@ -71,7 +70,7 @@ test_compareandwrite_simple(void)
"Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl);
ret = compareandwrite(sd, 0,
buf, 2 * i * block_size,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
@@ -84,12 +83,12 @@ test_compareandwrite_simple(void)
continue;
}
memset(buf + i * block_size, 'B', i * block_size);
memset(scratch + i * block_size, 'B', i * block_size);
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:0 (if they all contain 'A')", i);
ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_STATUS_GOOD);
if (ret == -2) {
@@ -102,15 +101,15 @@ test_compareandwrite_simple(void)
logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
"they are all 'B'", i);
ret = read16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) {
if (buf[j] != 'B') {
if (scratch[j] != 'B') {
logging(LOG_VERBOSE, "[FAILED] Data did not "
"read back as 'B' (buf[%d] = %#02x)",
j, buf[j]);
"read back as 'B' (scratch[%d] = %#02x)",
j, scratch[j]);
CU_FAIL("Block was not written correctly");
return;
}
@@ -123,12 +122,12 @@ test_compareandwrite_simple(void)
for (i = 1; i < 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
i, num_blocks - i);
memset(buf, 'A', 2 * i * block_size);
memset(scratch, 'A', 2 * i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -138,20 +137,20 @@ test_compareandwrite_simple(void)
"Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl);
ret = compareandwrite(sd, 0,
buf, 2 * i * block_size,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
continue;
}
memset(buf + i * block_size, 'B', i * block_size);
memset(scratch + i * block_size, 'B', i * block_size);
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:%" PRIu64 " (if they all contain 'A')",
i, num_blocks - i);
ret = compareandwrite(sd, num_blocks - i,
buf, 2 * i * block_size, block_size,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -160,15 +159,15 @@ test_compareandwrite_simple(void)
" and verify they are all 'B'",
i, num_blocks - i);
ret = read16(sd, NULL, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) {
if (buf[j] != 'B') {
if (scratch[j] != 'B') {
logging(LOG_VERBOSE, "[FAILED] Data did not "
"read back as 'B' (buf[%d] = %#02x)",
j, buf[j]);
"read back as 'B' (scratch[%d] = %#02x)",
j, scratch[j]);
CU_FAIL("Block was not written correctly");
return;
}

View File

@@ -31,7 +31,6 @@ test_get_lba_status_unmap_single(void)
{
int ret;
uint64_t i;
unsigned char *buf = alloca((256 + lbppb + 1) * block_size);
struct unmap_list list[1];
struct scsi_task *t = NULL;
struct scsi_get_lba_status *lbas = NULL;
@@ -41,7 +40,7 @@ test_get_lba_status_unmap_single(void)
CHECK_FOR_THIN_PROVISIONING;
CHECK_FOR_LBPU;
memset(buf, 'A', (256 + lbppb + 1) * block_size);
memset(scratch, 'A', (256 + lbppb + 1) * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test GET_LBA_STATUS for a single unmapped block "
@@ -52,7 +51,7 @@ test_get_lba_status_unmap_single(void)
logging(LOG_VERBOSE, "Write the first %i blocks with a known "
"pattern and thus map the blocks", 256 + lbppb);
ret = write10(sd, 0, (256 + lbppb) * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -118,7 +117,7 @@ test_get_lba_status_unmap_single(void)
logging(LOG_VERBOSE, "Write the first %i blocks with a known "
"pattern and thus map the blocks", (256 + lbppb));
ret = write10(sd, 0, (256 + lbppb) * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i);

View File

@@ -59,7 +59,6 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu
void test_iscsi_datasn_invalid(void)
{
int ret;
unsigned char *buf = alloca(2 * block_size);
CHECK_FOR_DATALOSS;
@@ -83,10 +82,10 @@ void test_iscsi_datasn_invalid(void)
iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(sd->iscsi_ctx, 3);
memset(buf, 0xa6, 2 * block_size);
memset(scratch, 0xa6, 2 * block_size);
ret = write10(sd, 100, 2 * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
@@ -109,7 +108,7 @@ void test_iscsi_datasn_invalid(void)
iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = write10(sd, 100, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
@@ -132,7 +131,7 @@ void test_iscsi_datasn_invalid(void)
iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = write10(sd, 100, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
@@ -156,7 +155,7 @@ void test_iscsi_datasn_invalid(void)
iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = write10(sd, 100, 2 * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");

View File

@@ -32,7 +32,6 @@ test_modesense6_control_swp(void)
struct scsi_task *ms_task = NULL;
struct scsi_mode_sense *ms;
struct scsi_mode_page *page;
unsigned char *buf = alloca(block_size);
int ret;
CHECK_FOR_DATALOSS;
@@ -90,13 +89,13 @@ test_modesense6_control_swp(void)
logging(LOG_VERBOSE, "Read a block from the now Read-Only device");
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to write a block to the Read-Only device");
ret = write10(sd, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -35,7 +35,6 @@ test_multipathio_compareandwrite(void)
int io_bl = 1; /* 1 block CAW IOs */
int path;
int i, ret;
unsigned char *buf = alloca(2 * io_bl * block_size);
int maxbl;
CHECK_FOR_DATALOSS;
@@ -56,9 +55,9 @@ test_multipathio_compareandwrite(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Initialising data prior to COMPARE_AND_WRITE");
memset(buf, 0, io_bl * block_size);
memset(scratch, 0, io_bl * block_size);
ret = writesame10(mp_sds[0], 0,
block_size, 256, 0, 0, 0, 0, buf,
block_size, 256, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
@@ -75,13 +74,13 @@ test_multipathio_compareandwrite(void)
path, path + 1, path);
/* compare data is first half */
memset(buf, path, io_bl * block_size);
memset(scratch, path, io_bl * block_size);
/* write data is the second half, wrap around */
memset(buf + io_bl * block_size, path + 1,
memset(scratch + io_bl * block_size, path + 1,
io_bl * block_size);
ret = compareandwrite(mp_sds[path], i,
buf, 2 * io_bl * block_size,
scratch, 2 * io_bl * block_size,
block_size, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
if (ret == -2) {
@@ -96,7 +95,7 @@ test_multipathio_compareandwrite(void)
path, path + 1);
ret = compareandwrite(mp_sds[path], i,
buf, 2 * io_bl * block_size,
scratch, 2 * io_bl * block_size,
block_size, 0, 0, 0, 0,
EXPECT_MISCOMPARE);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -30,20 +30,19 @@ void
test_orwrite_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
@@ -60,7 +59,8 @@ test_orwrite_beyond_eol(void)
break;
}
ret = orwrite(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -72,7 +72,8 @@ test_orwrite_beyond_eol(void)
break;
}
ret = orwrite(sd, -1,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -84,7 +85,8 @@ test_orwrite_beyond_eol(void)
break;
}
ret = orwrite(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -34,7 +34,6 @@ test_orwrite_dpofua(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE DPO/FUA flags");
@@ -61,10 +60,10 @@ test_orwrite_dpofua(void)
}
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (dpofua) {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 0, 0, 0, buf,
block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
@@ -74,7 +73,7 @@ test_orwrite_dpofua(void)
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 0, 0, 0, buf,
block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
@@ -87,12 +86,12 @@ test_orwrite_dpofua(void)
logging(LOG_VERBOSE, "Test ORWRITE with FUA==1");
if (dpofua) {
ret = orwrite(sd, 0, block_size,
block_size, 0, 0, 1, 0, 0, buf,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = orwrite(sd, 0, block_size,
block_size, 0, 0, 1, 0, 0, buf,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -100,12 +99,12 @@ test_orwrite_dpofua(void)
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1");
if (dpofua) {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 1, 0, 0, buf,
block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = orwrite(sd, 0, block_size,
block_size, 0, 1, 1, 0, 0, buf,
block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -31,20 +31,19 @@ void
test_orwrite_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
@@ -60,7 +59,8 @@ test_orwrite_simple(void)
break;
}
ret = orwrite(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -32,8 +32,8 @@ void
test_orwrite_verify(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
unsigned char *readbuf = alloca(256 * block_size);
unsigned char *buf = &scratch[0];
unsigned char *readbuf = &scratch[256 * block_size];
CHECK_FOR_DATALOSS;

View File

@@ -31,7 +31,6 @@ void
test_orwrite_wrprotect(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -42,12 +41,12 @@ test_orwrite_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = orwrite(sd, 0, block_size,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {

View File

@@ -68,29 +68,28 @@ verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd
pr_type);
CU_ASSERT_EQUAL(0, ret);
read_write_buf = malloc(512); /* allocate a buffer */
CU_ASSERT_PTR_NOT_NULL_FATAL(read_write_buf);
CU_ASSERT_PTR_NOT_NULL_FATAL(scratch);
/* make sure init1 can read */
ret = verify_read_works(sd1, read_write_buf);
ret = verify_read_works(sd1, scratch);
CU_ASSERT_EQUAL(0, ret);
/* make sure init1 can write */
ret = verify_write_works(sd1, read_write_buf);
ret = verify_write_works(sd1, scratch);
CU_ASSERT_EQUAL(0, ret);
/* verify registered init2 read access */
if (reg_i2_can_read)
ret = verify_read_works(sd2, read_write_buf);
ret = verify_read_works(sd2, scratch);
else
ret = verify_read_fails(sd2, read_write_buf);
ret = verify_read_fails(sd2, scratch);
CU_ASSERT_EQUAL(0, ret);
/* verify registered init2 write access */
if (reg_i2_can_write)
ret = verify_write_works(sd2, read_write_buf);
ret = verify_write_works(sd2, scratch);
else
ret = verify_write_fails(sd2, read_write_buf);
ret = verify_write_fails(sd2, scratch);
CU_ASSERT_EQUAL(0, ret);
/* unregister init2 */
@@ -99,16 +98,16 @@ verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd
/* verify unregistered init2 read access */
if (unreg_i2_can_read)
ret = verify_read_works(sd2, read_write_buf);
ret = verify_read_works(sd2, scratch);
else
ret = verify_read_fails(sd2, read_write_buf);
ret = verify_read_fails(sd2, scratch);
CU_ASSERT_EQUAL(0, ret);
/* verify unregistered init2 write access */
if (unreg_i2_can_write)
ret = verify_write_works(sd2, read_write_buf);
ret = verify_write_works(sd2, scratch);
else
ret = verify_write_fails(sd2, read_write_buf);
ret = verify_write_fails(sd2, scratch);
CU_ASSERT_EQUAL(0, ret);
/* release our reservation */

View File

@@ -33,7 +33,6 @@ void
test_read10_invalid(void)
{
struct iscsi_data data;
char *buf = alloca(block_size);
struct scsi_task *task_ret;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -246,9 +245,9 @@ test_read10_invalid(void)
task->xfer_dir = SCSI_XFER_WRITE;
task->expxferlen = block_size;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
data.size = block_size;
data.data = (unsigned char *)buf;
data.data = (unsigned char *)scratch;
iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(sd->iscsi_ctx, 3);

View File

@@ -27,13 +27,13 @@
#include "iscsi-test-cu.h"
static void
init_lun_with_data(unsigned char *buf, uint64_t lba)
init_lun_with_data(uint64_t lba)
{
int ret;
memset(buf, 'a', 256 * block_size);
memset(scratch, 'a', 256 * block_size);
ret = write10(sd, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -43,7 +43,6 @@ test_unmap_simple(void)
{
int i, ret;
struct unmap_list list[257];
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test basic UNMAP");
@@ -57,7 +56,7 @@ test_unmap_simple(void)
"LUN as a single descriptor");
logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
init_lun_with_data(buf, 0);
init_lun_with_data(0);
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i);
@@ -69,14 +68,14 @@ test_unmap_simple(void)
logging(LOG_VERBOSE, "Read blocks 0-%d", i);
ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
if (rc16 && rc16->lbprz) {
logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
"should read back as 0");
if (all_zeroes(buf, i * block_size) == 0) {
if (all_zeroes(scratch, i * block_size) == 0) {
logging(LOG_NORMAL, "[FAILED] Blocks did not "
"read back as zero");
CU_FAIL("[FAILED] Blocks did not read back "
@@ -92,7 +91,7 @@ test_unmap_simple(void)
"LUN with one descriptor per block");
logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
init_lun_with_data(buf, 0);
init_lun_with_data(0);
CU_ASSERT_EQUAL(ret, 0);
for (i = 0; i < 256; i++) {
@@ -104,14 +103,14 @@ test_unmap_simple(void)
logging(LOG_VERBOSE, "Read blocks 0-%d", i);
ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
if (rc16 && rc16->lbprz) {
logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
"should read back as 0");
if (all_zeroes(buf, i * block_size) == 0) {
if (all_zeroes(scratch, i * block_size) == 0) {
logging(LOG_NORMAL, "[FAILED] Blocks did not "
"read back as zero");
CU_FAIL("[FAILED] Blocks did not read back "

View File

@@ -30,7 +30,6 @@ void
test_verify10_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
if (num_blocks >= 0x80000000) {
CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY10. Skipping test.\n");
@@ -39,13 +38,13 @@ test_verify10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
VERIFY10(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -55,7 +54,7 @@ test_verify10_beyond_eol(void)
break;
}
VERIFY10(sd, 0x80000000,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -64,7 +63,7 @@ test_verify10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
VERIFY10(sd, -1, i * block_size, block_size, 0, 0, 1, buf,
VERIFY10(sd, -1, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -75,7 +74,7 @@ test_verify10_beyond_eol(void)
break;
}
VERIFY10(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_verify10_dpo(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 DPO flag");
@@ -42,7 +41,7 @@ test_verify10_dpo(void)
CHECK_FOR_SBC;
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -66,10 +65,10 @@ test_verify10_dpo(void)
logging(LOG_VERBOSE, "Test VERIFY10 with DPO==1");
if (dpofua) {
VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, buf,
VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, buf,
VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -30,18 +30,17 @@ void
test_verify10_flags(void)
{
int ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 flags");
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test VERIFY10 with BYTCHK==1");
VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, buf,
VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,7 +31,6 @@ void
test_verify10_mismatch(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 for blocks 1-255");
@@ -42,15 +41,15 @@ test_verify10_mismatch(void)
break;
}
ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, buf,
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
}
@@ -62,16 +61,16 @@ test_verify10_mismatch(void)
break;
}
ret = read10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify10_mismatch_no_cmp(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK for blocks 1-255");
@@ -42,15 +41,15 @@ test_verify10_mismatch_no_cmp(void)
break;
}
ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 0, buf,
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -62,16 +61,16 @@ test_verify10_mismatch_no_cmp(void)
break;
}
ret = read10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify10_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the start of the LUN");
@@ -40,11 +39,11 @@ test_verify10_simple(void)
break;
}
ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, buf,
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
@@ -54,12 +53,12 @@ test_verify10_simple(void)
break;
}
ret = read10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify10_vrprotect(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 with non-zero VRPROTECT");
@@ -42,12 +41,12 @@ test_verify10_vrprotect(void)
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY10(sd, 0, block_size,
block_size, i, 0, 1, buf,
block_size, i, 0, 1, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -30,7 +30,6 @@ void
test_verify12_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
if (num_blocks >= 0x80000000) {
CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY12. Skipping test.\n");
@@ -39,13 +38,13 @@ test_verify12_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
VERIFY12(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -55,7 +54,7 @@ test_verify12_beyond_eol(void)
break;
}
VERIFY12(sd, 0x80000000,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -65,7 +64,7 @@ test_verify12_beyond_eol(void)
break;
}
VERIFY12(sd, -1, i * block_size,
block_size, 0, 0, 1, buf,
block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -75,7 +74,7 @@ test_verify12_beyond_eol(void)
break;
}
VERIFY12(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_verify12_dpo(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 DPO flag");
@@ -42,7 +41,7 @@ test_verify12_dpo(void)
CHECK_FOR_SBC;
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -66,10 +65,10 @@ test_verify12_dpo(void)
logging(LOG_VERBOSE, "Test VERIFY12 with DPO==1");
if (dpofua) {
VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, buf,
VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, buf,
VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -31,18 +31,17 @@ void
test_verify12_flags(void)
{
int ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 flags");
ret = read12(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test VERIFY12 with BYTCHK==1");
VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, buf,
VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,7 +31,6 @@ void
test_verify12_mismatch(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 for blocks 1-255");
@@ -42,14 +41,14 @@ test_verify12_mismatch(void)
break;
}
ret = read12(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, buf,
VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
}
@@ -61,16 +60,16 @@ test_verify12_mismatch(void)
break;
}
ret = read12(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify12_mismatch_no_cmp(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK for blocks 1-255");
@@ -42,14 +41,14 @@ test_verify12_mismatch_no_cmp(void)
break;
}
ret = read12(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 0, buf,
VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -61,16 +60,16 @@ test_verify12_mismatch_no_cmp(void)
break;
}
ret = read12(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify12_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the start of the LUN");
@@ -40,11 +39,11 @@ test_verify12_simple(void)
break;
}
ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, buf,
VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
@@ -54,12 +53,12 @@ test_verify12_simple(void)
break;
}
ret = read12(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify12_vrprotect(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 with non-zero VRPROTECT");
@@ -43,12 +42,12 @@ test_verify12_vrprotect(void)
for (i = 1; i < 8; i++) {
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY12(sd, 0, block_size,
block_size, i, 0, 1, buf,
block_size, i, 0, 1, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -30,18 +30,16 @@ void
test_verify16_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
VERIFY16(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -51,7 +49,7 @@ test_verify16_beyond_eol(void)
break;
}
VERIFY16(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -60,7 +58,7 @@ test_verify16_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
VERIFY16(sd, -1, i * block_size, block_size, 0, 0, 1, buf,
VERIFY16(sd, -1, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
@@ -70,7 +68,7 @@ test_verify16_beyond_eol(void)
break;
}
VERIFY16(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_verify16_dpo(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 DPO flag");
@@ -42,7 +41,7 @@ test_verify16_dpo(void)
CHECK_FOR_SBC;
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -66,10 +65,10 @@ test_verify16_dpo(void)
logging(LOG_VERBOSE, "Test VERIFY16 with DPO==1");
if (dpofua) {
VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, buf,
VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, buf,
VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -31,17 +31,16 @@ void
test_verify16_flags(void)
{
int ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 flags");
ret = read16(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test VERIFY16 with BYTCHK==1");
VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, buf,
VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,7 +31,6 @@ void
test_verify16_mismatch(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 for blocks 1-255");
@@ -43,14 +42,14 @@ test_verify16_mismatch(void)
}
ret = read16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 1, buf,
VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
}
@@ -63,16 +62,16 @@ test_verify16_mismatch(void)
}
ret = read16(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify16_mismatch_no_cmp(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK for blocks 1-255");
@@ -43,14 +42,14 @@ test_verify16_mismatch_no_cmp(void)
}
ret = read16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 0, buf,
VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -63,16 +62,16 @@ test_verify16_mismatch_no_cmp(void)
}
ret = read16(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
scratch[offset] ^= 'X';
logging(LOG_VERBOSE, "Flip some bits in the data");
VERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify16_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the start of the LUN");
@@ -40,10 +39,10 @@ test_verify16_simple(void)
break;
}
ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
VERIFY16(sd, 0, i * block_size,
block_size, 0, 0, 1, buf,
block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
@@ -54,12 +53,12 @@ test_verify16_simple(void)
}
ret = read16(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_verify16_vrprotect(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 with non-zero VRPROTECT");
@@ -42,12 +41,12 @@ test_verify16_vrprotect(void)
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = read16(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
VERIFY16(sd, 0, block_size,
block_size, i, 0, 1, buf,
block_size, i, 0, 1, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -30,7 +30,6 @@ void
test_write10_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -41,13 +40,13 @@ test_write10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITE10(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -57,7 +56,7 @@ test_write10_beyond_eol(void)
break;
}
WRITE10(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -67,7 +66,7 @@ test_write10_beyond_eol(void)
break;
}
WRITE10(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -77,7 +76,7 @@ test_write10_beyond_eol(void)
break;
}
WRITE10(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_write10_dpofua(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 DPO/FUA flags");
@@ -61,31 +60,31 @@ test_write10_dpofua(void)
}
logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (dpofua) {
WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test WRITE10 with FUA==1");
if (dpofua) {
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1");
if (dpofua) {
WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -29,32 +29,30 @@
void
test_write10_flags(void)
{
unsigned char *buf = alloca(block_size);
{
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 flags");
logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
memset(buf, 0xa6, block_size);
WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
memset(scratch, 0xa6, block_size);
WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==0");
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==1");
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE10 with FUA==0 FUA_NV==1");
WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1 FUA_NV==1");
WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, buf,
WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,19 +31,18 @@ void
test_write10_simple(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITE10(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
WRITE10(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -53,7 +52,7 @@ test_write10_simple(void)
break;
}
WRITE10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_write10_wrprotect(void)
{
int i;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -42,12 +41,12 @@ test_write10_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
WRITE10(sd, 0, block_size, block_size,
i, 0, 0, 0, 0, buf,
i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -30,7 +30,6 @@ void
test_write12_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -41,13 +40,13 @@ test_write12_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITE12(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -57,7 +56,7 @@ test_write12_beyond_eol(void)
break;
}
WRITE12(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -67,7 +66,7 @@ test_write12_beyond_eol(void)
break;
}
WRITE12(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -77,7 +76,7 @@ test_write12_beyond_eol(void)
break;
}
WRITE12(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_write12_dpofua(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE12 DPO/FUA flags");
@@ -61,30 +60,30 @@ test_write12_dpofua(void)
}
logging(LOG_VERBOSE, "Test WRITE12 with DPO==1");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (dpofua) {
WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test WRITE12 with FUA==1");
if (dpofua) {
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1");
if (dpofua) {
WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -29,32 +29,30 @@
void
test_write12_flags(void)
{
unsigned char *buf = alloca(block_size);
{
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE12 flags");
logging(LOG_VERBOSE, "Test WRITE12 with DPO==1");
memset(buf, 0xa6, block_size);
WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
memset(scratch, 0xa6, block_size);
WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==0");
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==1");
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE12 with FUA==0 FUA_NV==1");
WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1 FUA_NV==1");
WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, buf,
WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,18 +31,18 @@ void
test_write12_simple(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITE12(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
WRITE12(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -52,7 +52,7 @@ test_write12_simple(void)
break;
}
WRITE12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,8 +31,6 @@ void
test_write12_wrprotect(void)
{
int i;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -43,12 +41,12 @@ test_write12_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
WRITE12(sd, 0, block_size, block_size,
i, 0, 0, 0, 0, buf,
i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -30,21 +30,19 @@ void
test_write16_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITE16(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -54,7 +52,7 @@ test_write16_beyond_eol(void)
break;
}
WRITE16(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -64,7 +62,7 @@ test_write16_beyond_eol(void)
break;
}
WRITE16(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -74,7 +72,7 @@ test_write16_beyond_eol(void)
break;
}
WRITE16(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_write16_dpofua(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE16 DPO/FUA flags");
@@ -61,31 +60,31 @@ test_write16_dpofua(void)
}
logging(LOG_VERBOSE, "Test WRITE16 with DPO==1");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (dpofua) {
WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test WRITE16 with FUA==1");
if (dpofua) {
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1");
if (dpofua) {
WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -30,8 +30,6 @@
void
test_write16_flags(void)
{
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -39,23 +37,23 @@ test_write16_flags(void)
logging(LOG_VERBOSE, "Test WRITE16 flags");
logging(LOG_VERBOSE, "Test WRITE16 with DPO==1");
memset(buf, 0xa6, block_size);
WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, buf,
memset(scratch, 0xa6, block_size);
WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==0");
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==1");
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE16 with FUA==0 FUA_NV==1");
WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1 FUA_NV==1");
WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, buf,
WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,20 +31,19 @@ void
test_write16_simple(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITE16(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
WRITE16(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -54,7 +53,7 @@ test_write16_simple(void)
break;
}
WRITE16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_write16_wrprotect(void)
{
int i;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -42,12 +41,12 @@ test_write16_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
WRITE16(sd, 0, block_size, block_size,
i, 0, 0, 0, 0, buf,
i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -31,8 +31,6 @@ test_writeatomic16_beyond_eol(void)
{
int align, i, gran, ret;
const size_t bufsz = 256 * 2 * block_size;
unsigned char *buf = alloca(bufsz);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -44,12 +42,12 @@ test_writeatomic16_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
memset(buf, 0xa6, bufsz);
memset(scratch, 0xa6, bufsz);
align = inq_bl->atomic_align ? inq_bl->atomic_align : 1;
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
ret = writeatomic16(sd, 0,
block_size * gran,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -66,7 +64,7 @@ test_writeatomic16_beyond_eol(void)
ret = writeatomic16(sd, num_blocks - i,
2 * i * block_size, block_size,
0, 0, 0, 0, buf,
0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -77,7 +75,8 @@ test_writeatomic16_beyond_eol(void)
break;
}
ret = writeatomic16(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size,
0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -89,7 +88,7 @@ test_writeatomic16_beyond_eol(void)
break;
}
ret = writeatomic16(sd, -align, i * block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -101,7 +100,8 @@ test_writeatomic16_beyond_eol(void)
break;
}
ret = writeatomic16(sd, num_blocks - gran,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size,
0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -34,7 +34,6 @@ test_writeatomic16_dpofua(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEATOMIC16 DPO/FUA flags");
@@ -48,7 +47,6 @@ test_writeatomic16_dpofua(void)
}
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
buf = alloca(gran * block_size);
logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
@@ -69,10 +67,10 @@ test_writeatomic16_dpofua(void)
}
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (dpofua) {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -82,7 +80,7 @@ test_writeatomic16_dpofua(void)
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -95,12 +93,12 @@ test_writeatomic16_dpofua(void)
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with FUA==1");
if (dpofua) {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 0, 1, 0, buf,
block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 0, 1, 0, buf,
block_size, 0, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -108,12 +106,12 @@ test_writeatomic16_dpofua(void)
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1 FUA==1");
if (dpofua) {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 1, 0, buf,
block_size, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 1, 0, buf,
block_size, 0, 1, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -32,8 +32,6 @@ test_writeatomic16_simple(void)
{
int i, gran, ret;
const size_t bufsz = 256 * block_size;
unsigned char *buf = alloca(bufsz);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -45,11 +43,11 @@ test_writeatomic16_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
memset(buf, 0, bufsz);
memset(scratch, 0, bufsz);
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
ret = writeatomic16(sd, 0,
block_size * gran,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -59,13 +57,13 @@ test_writeatomic16_simple(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = gran; i <= 256; i += gran) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeatomic16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -76,7 +74,8 @@ test_writeatomic16_simple(void)
break;
}
ret = writeatomic16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size,
0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -33,7 +33,6 @@ test_writeatomic16_vpd(void)
struct scsi_inquiry_block_limits *bl;
struct scsi_task *bl_task = NULL;
int gran;
unsigned char *buf;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEATOMIC16 VPD data");
@@ -63,10 +62,9 @@ test_writeatomic16_vpd(void)
logging(LOG_VERBOSE, "Check if WRITEATOMIC16 is supported");
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
buf = alloca(block_size * gran);
memset(buf, 0x00, block_size * gran);
memset(scratch , 0x00, block_size * gran);
ret = writeatomic16(sd, 0, block_size * gran,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_VERBOSE, "WRITEATOMIC16 is NOT supported by the target.");
@@ -110,7 +108,7 @@ test_writeatomic16_vpd(void)
} else {
logging(LOG_VERBOSE, "Atomic Write at LBA 1 should fail due to misalignment");
ret = writeatomic16(sd, 1, block_size * gran,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret) {
logging(LOG_VERBOSE, "[FAILED] Misaligned write did NOT fail with INVALID_FIELD_IN_CDB");
@@ -124,7 +122,7 @@ test_writeatomic16_vpd(void)
} else {
logging(LOG_VERBOSE, "Atomic Write of 1 block should fail due to invalid granularity");
ret = writeatomic16(sd, 0, block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret) {
logging(LOG_VERBOSE, "[FAILED] Misgranularity write did NOT fail with INVALID_FIELD_IN_CDB");

View File

@@ -31,7 +31,6 @@ void
test_writeatomic16_wrprotect(void)
{
int i, gran, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -44,10 +43,10 @@ test_writeatomic16_wrprotect(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writeatomic16(sd, 0,
block_size * gran,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -59,13 +58,13 @@ test_writeatomic16_wrprotect(void)
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with non-zero WRPROTECT");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = writeatomic16(sd, 0,
gran * block_size, block_size,
i, 0, 0, 0, buf,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");

View File

@@ -28,7 +28,6 @@ void
test_writesame10_0blocks(void)
{
int ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -46,11 +45,11 @@ test_writesame10_0blocks(void)
logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==0 (WSNZ=%d)",
inq_bl->wsnz);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
if (inq_bl->wsnz) {
ret = writesame10(sd, 0,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks.");
CU_ASSERT_EQUAL(ret, 0);
@@ -58,7 +57,7 @@ test_writesame10_0blocks(void)
}
ret = writesame10(sd, 0,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
@@ -73,21 +72,21 @@ test_writesame10_0blocks(void)
logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks one block past end-of-LUN");
ret = writesame10(sd, num_blocks + 1,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==2^31");
ret = writesame10(sd, 0x80000000,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==-1");
ret = writesame10(sd, -1,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -30,7 +30,6 @@ void
test_writesame10_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -42,10 +41,10 @@ test_writesame10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks one block beyond the end");
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
for (i = 1; i <= 256; i++) {
ret = writesame10(sd, num_blocks - i + 1,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
@@ -58,7 +57,7 @@ test_writesame10_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
ret = writesame10(sd, 0x80000000,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -67,7 +66,7 @@ test_writesame10_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
ret = writesame10(sd, -1,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -76,7 +75,7 @@ test_writesame10_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITESAME10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
ret = writesame10(sd, num_blocks - 1,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -31,7 +31,6 @@ void
test_writesame10_simple(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -39,10 +38,10 @@ test_writesame10_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of the LUN");
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
for (i = 1; i <= 256; i++) {
ret = writesame10(sd, 0,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
@@ -54,7 +53,7 @@ test_writesame10_simple(void)
logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
ret = writesame10(sd, num_blocks - i,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -32,7 +32,6 @@ test_writesame10_unmap(void)
{
int ret;
unsigned int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -42,17 +41,18 @@ test_writesame10_unmap(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of "
"the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
WRITE10(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
memset(scratch, 0xff, i * block_size);
WRITE10(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame10(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -64,9 +64,9 @@ test_writesame10_unmap(void)
"are now zero", i);
ret = read10(sd, NULL, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
@@ -78,15 +78,15 @@ test_writesame10_unmap(void)
"the LUN");
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
memset(scratch, 0xff, i * block_size);
WRITE10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame10(sd, num_blocks - i,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -98,9 +98,9 @@ test_writesame10_unmap(void)
"are now zero", i);
ret = read10(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
@@ -110,7 +110,7 @@ test_writesame10_unmap(void)
logging(LOG_VERBOSE, "Verify that WRITESAME10 ANCHOR==1 + UNMAP==0 is "
"invalid");
ret = writesame10(sd, 0,
block_size, 1, 1, 0, 0, 0, buf,
block_size, 1, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
@@ -118,15 +118,15 @@ test_writesame10_unmap(void)
if (inq_lbp->anc_sup) {
logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0");
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame10(sd, 0,
block_size, 1, 1, 1, 0, 0, buf,
block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0 no "
"ANC_SUP so expecting to fail");
ret = writesame10(sd, 0,
block_size, 1, 1, 1, 0, 0, buf,
block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
CU_ASSERT_EQUAL(ret, 0);
@@ -149,15 +149,15 @@ test_writesame10_unmap(void)
"lengths", i, i);
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
memset(scratch, 0xff, i * block_size);
WRITE10(sd, 0,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame10(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -169,9 +169,9 @@ test_writesame10_unmap(void)
"are now zero", i);
ret = read10(sd, NULL, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
@@ -183,7 +183,7 @@ test_writesame10_unmap(void)
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
ret = writesame10(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -30,7 +30,6 @@ void
test_writesame10_unmap_unaligned(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -40,11 +39,11 @@ test_writesame10_unmap_unaligned(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that unaligned WRITESAME10 Unmap succeeds. LBPPB==%d", lbppb);
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
for (i = 1; i < lbppb; i++) {
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10 at LBA:%d", lbppb - i, i);
ret = writesame10(sd, i,
block_size, lbppb - i, 0, 1, 0, 0, buf,
block_size, lbppb - i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -46,17 +46,15 @@ test_writesame10_unmap_until_end(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, block_size * i);
memset(scratch, 0xff, block_size * i);
WRITE10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
ret = writesame10(sd, num_blocks - i,
block_size, 0, 0, 1, 0, 0, buf,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -68,13 +66,12 @@ test_writesame10_unmap_until_end(void)
"are now zero", i);
ret = read10(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
}
free(buf);
}
}

View File

@@ -31,7 +31,6 @@ void
test_writesame10_unmap_vpd(void)
{
int ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME10 UNMAP availability is "
@@ -42,9 +41,8 @@ test_writesame10_unmap_vpd(void)
logging(LOG_VERBOSE, "Check if WRITESAME10 can be used for UNMAP.");
logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME10");
memset(buf, 0, block_size);
ret = writesame10(sd, 0,
block_size, 1, 0, 1, 0, 0, buf,
memset(scratch, 0, block_size);
ret = writesame10(sd, 0, block_size, 1, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret != 0) {
logging(LOG_VERBOSE, "WRITESAME10 UNMAP is not available. "

View File

@@ -31,7 +31,6 @@ void
test_writesame10_wrprotect(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -42,12 +41,12 @@ test_writesame10_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = writesame10(sd, 0,
block_size, 1, 0, 0, i, 0, buf,
block_size, 1, 0, 0, i, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 is not implemented.");

View File

@@ -28,7 +28,6 @@ void
test_writesame16_0blocks(void)
{
int ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -41,19 +40,18 @@ test_writesame16_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==0 (WSNZ=%d)",
inq_bl->wsnz);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
if (inq_bl->wsnz) {
ret = writesame16(sd, 0,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 does not support 0-blocks.");
CU_ASSERT_EQUAL(ret, 0);
return;
}
ret = writesame16(sd, 0,
block_size, 0, 0, 0, 0, 0, buf,
ret = writesame16(sd, 0, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
@@ -69,21 +67,21 @@ test_writesame16_0blocks(void)
logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks one block past end-of-LUN");
ret = writesame16(sd, num_blocks + 1,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==2^63");
ret = writesame16(sd, 0x8000000000000000ULL,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==-1");
ret = writesame16(sd, -1,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -30,17 +30,16 @@ void
test_writesame16_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks one block beyond the end");
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
for (i = 1; i <= 256; i++) {
ret = writesame16(sd, num_blocks - i + 1,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
@@ -54,7 +53,7 @@ test_writesame16_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
ret = writesame16(sd, 0x8000000000000000ULL,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -63,7 +62,7 @@ test_writesame16_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
ret = writesame16(sd, -1,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -72,7 +71,7 @@ test_writesame16_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITESAME16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
ret = writesame16(sd, num_blocks - 1,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -31,7 +31,6 @@ void
test_writesame16_simple(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -39,10 +38,10 @@ test_writesame16_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
for (i = 1; i <= 256; i++) {
ret = writesame16(sd, 0,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
@@ -55,7 +54,7 @@ test_writesame16_simple(void)
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
ret = writesame16(sd, num_blocks - i,
block_size, i, 0, 0, 0, 0, buf,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -31,7 +31,6 @@ test_writesame16_unmap(void)
{
int ret;
unsigned int i;
unsigned char *buf;
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -40,22 +39,22 @@ test_writesame16_unmap(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
buf = calloc(65536, block_size);
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
WRITE16(sd, 0, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
memset(scratch, 0xff, i * block_size);
WRITE16(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame16(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
goto finished;
return;
}
CU_ASSERT_EQUAL(ret, 0);
@@ -66,9 +65,9 @@ test_writesame16_unmap(void)
"are now zero", i);
ret = read16(sd, NULL, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
@@ -79,15 +78,15 @@ test_writesame16_unmap(void)
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
memset(scratch, 0xff, i * block_size);
WRITE16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame16(sd, num_blocks - i,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -98,9 +97,9 @@ test_writesame16_unmap(void)
"are now zero", i);
ret = read16(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
@@ -109,7 +108,7 @@ test_writesame16_unmap(void)
logging(LOG_VERBOSE, "Verify that WRITESAME16 ANCHOR==1 + UNMAP==0 is invalid");
ret = writesame16(sd, 0,
block_size, 1, 1, 0, 0, 0, buf,
block_size, 1, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
@@ -117,14 +116,14 @@ test_writesame16_unmap(void)
if (inq_lbp->anc_sup) {
logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0");
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame16(sd, 0,
block_size, 1, 1, 1, 0, 0, buf,
block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0 no ANC_SUP so expecting to fail");
ret = writesame16(sd, 0,
block_size, 1, 1, 1, 0, 0, buf,
block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
@@ -136,7 +135,7 @@ test_writesame16_unmap(void)
"BlockLimits VPD is missing.");
CU_FAIL("[FAILED] WRITESAME16 works but "
"BlockLimits VPD is missing.");
goto finished;
return;
}
i = 256;
@@ -148,15 +147,15 @@ test_writesame16_unmap(void)
"lengths", i, i);
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
memset(scratch, 0xff, i * block_size);
WRITE16(sd, 0,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame16(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -168,9 +167,9 @@ test_writesame16_unmap(void)
"are now zero", i);
ret = read16(sd, NULL, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
@@ -182,7 +181,7 @@ test_writesame16_unmap(void)
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
ret = writesame16(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -197,15 +196,15 @@ test_writesame16_unmap(void)
"lengths", i, i);
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, i * block_size);
memset(scratch, 0xff, i * block_size);
WRITE16(sd, 0,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame16(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -217,9 +216,9 @@ test_writesame16_unmap(void)
"are now zero", i);
ret = read16(sd, NULL, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");
@@ -231,11 +230,8 @@ test_writesame16_unmap(void)
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
ret = writesame16(sd, 0,
block_size, i, 0, 1, 0, 0, buf,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}
finished:
free(buf);
}

View File

@@ -32,7 +32,6 @@ test_writesame16_unmap_until_end(void)
{
int ret;
unsigned int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -47,18 +46,18 @@ test_writesame16_unmap_until_end(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, block_size * i);
memset(scratch, 0xff, block_size * i);
WRITE16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame16(sd, num_blocks - i,
block_size, 0, 0, 1, 0, 0, buf,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
@@ -75,9 +74,9 @@ test_writesame16_unmap_until_end(void)
"are now zero", i);
ret = read16(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");

View File

@@ -31,7 +31,6 @@ void
test_writesame16_unmap_vpd(void)
{
int ret;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 UNMAP availability is "
@@ -43,9 +42,8 @@ test_writesame16_unmap_vpd(void)
logging(LOG_VERBOSE, "Check if WRITESAME16 can be used for UNMAP.");
logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME16");
memset(buf, 0, block_size);
ret = writesame16(sd, 0,
block_size, 1, 0, 1, 0, 0, buf,
memset(scratch, 0, block_size);
ret = writesame16(sd, 0, block_size, 1, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret != 0) {
logging(LOG_VERBOSE, "WRITESAME16 UNMAP is not available. "

View File

@@ -31,7 +31,6 @@ void
test_writesame16_wrprotect(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -42,12 +41,12 @@ test_writesame16_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = writesame16(sd, 0,
block_size, 1, 0, 0, i, 0, buf,
block_size, 1, 0, 0, i, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");

View File

@@ -30,7 +30,6 @@ void
test_writeverify10_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -41,13 +40,13 @@ test_writeverify10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITEVERIFY10(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -57,7 +56,7 @@ test_writeverify10_beyond_eol(void)
break;
}
WRITEVERIFY10(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -67,7 +66,7 @@ test_writeverify10_beyond_eol(void)
break;
}
WRITEVERIFY10(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -77,7 +76,7 @@ test_writeverify10_beyond_eol(void)
break;
}
WRITEVERIFY10(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_writeverify10_dpo(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 DPO flag");
@@ -42,7 +41,7 @@ test_writeverify10_dpo(void)
CHECK_FOR_SBC;
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -67,11 +66,11 @@ test_writeverify10_dpo(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1");
if (dpofua) {
WRITEVERIFY10(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITEVERIFY10(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -30,8 +30,6 @@
void
test_writeverify10_flags(void)
{
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -39,7 +37,7 @@ test_writeverify10_flags(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1");
memset(buf, 0xa6, block_size);
WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, buf,
memset(scratch, 0xa6, block_size);
WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,19 +31,18 @@ void
test_writeverify10_simple(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITEVERIFY10(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -53,7 +52,7 @@ test_writeverify10_simple(void)
break;
}
WRITEVERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_writeverify10_wrprotect(void)
{
int i;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -42,12 +41,12 @@ test_writeverify10_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
WRITEVERIFY10(sd, 0, block_size, block_size,
i, 0, 0, 0, buf,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -30,7 +30,6 @@ void
test_writeverify12_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -41,13 +40,13 @@ test_writeverify12_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITEVERIFY12(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -57,7 +56,7 @@ test_writeverify12_beyond_eol(void)
break;
}
WRITEVERIFY12(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -67,7 +66,7 @@ test_writeverify12_beyond_eol(void)
break;
}
WRITEVERIFY12(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -77,7 +76,7 @@ test_writeverify12_beyond_eol(void)
break;
}
WRITEVERIFY12(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_writeverify12_dpo(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 DPO flag");
@@ -42,7 +41,7 @@ test_writeverify12_dpo(void)
CHECK_FOR_SBC;
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -67,11 +66,11 @@ test_writeverify12_dpo(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1");
if (dpofua) {
WRITEVERIFY12(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITEVERIFY12(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -30,8 +30,6 @@
void
test_writeverify12_flags(void)
{
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -39,7 +37,7 @@ test_writeverify12_flags(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1");
memset(buf, 0xa6, block_size);
WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, buf,
memset(scratch, 0xa6, block_size);
WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,19 +31,18 @@ void
test_writeverify12_simple(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITEVERIFY12(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -53,7 +52,7 @@ test_writeverify12_simple(void)
break;
}
WRITEVERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -31,7 +31,6 @@ void
test_writeverify12_wrprotect(void)
{
int i;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -42,12 +41,12 @@ test_writeverify12_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
WRITEVERIFY12(sd, 0, block_size, block_size,
i, 0, 0, 0, buf,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;

View File

@@ -30,20 +30,19 @@ void
test_writeverify16_beyond_eol(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks one block beyond the end");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITEVERIFY16(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -53,7 +52,7 @@ test_writeverify16_beyond_eol(void)
break;
}
WRITEVERIFY16(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -63,7 +62,7 @@ test_writeverify16_beyond_eol(void)
break;
}
WRITEVERIFY16(sd, -1,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
@@ -73,7 +72,7 @@ test_writeverify16_beyond_eol(void)
break;
}
WRITEVERIFY16(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
}

View File

@@ -34,7 +34,6 @@ test_writeverify16_dpo(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 DPO flag");
@@ -42,7 +41,7 @@ test_writeverify16_dpo(void)
CHECK_FOR_SBC;
ret = read10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
@@ -65,14 +64,14 @@ test_writeverify16_dpo(void)
}
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (dpofua) {
WRITEVERIFY16(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
} else {
WRITEVERIFY16(sd, 0, block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}

View File

@@ -30,8 +30,6 @@
void
test_writeverify16_flags(void)
{
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -39,7 +37,7 @@ test_writeverify16_flags(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1");
memset(buf, 0xa6, block_size);
WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, buf,
memset(scratch, 0xa6, block_size);
WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}

View File

@@ -31,20 +31,19 @@ void
test_writeverify16_simple(void)
{
int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the start of the LUN");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
WRITEVERIFY16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
@@ -54,7 +53,7 @@ test_writeverify16_simple(void)
break;
}
WRITEVERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
}
}

View File

@@ -32,7 +32,6 @@ void
test_writeverify16_wrprotect(void)
{
int i;
unsigned char *buf = alloca(block_size);
/*
* Try out different non-zero values for WRPROTECT.
@@ -43,12 +42,12 @@ test_writeverify16_wrprotect(void)
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
WRITEVERIFY16(sd, 0, block_size, block_size,
i, 0, 0, 0, buf,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;