TESTS: add a flag --usb so we can clamp all i/o to at most 120k

Add checks for maximum tranfer length to all commands that are limited
by BlockLimits/MTL
This commit is contained in:
Ronnie Sahlberg
2013-04-27 09:59:59 -07:00
parent c866787dcb
commit 2627a8845e
69 changed files with 500 additions and 354 deletions

View File

@@ -61,6 +61,7 @@ int lbpws;
int anc_sup;
int readonly;
int sbc3_support;
int maximum_transfer_length;
int (*real_iscsi_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);

View File

@@ -143,6 +143,7 @@ extern int lbpws;
extern int anc_sup;
extern int readonly;
extern int sbc3_support;
extern int maximum_transfer_length;
struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun);

View File

@@ -477,6 +477,9 @@ print_usage(void)
" -f|--fail Error Action: FAIL if any tests fail\n");
fprintf(stderr,
" -A|--abort Error Action: ABORT if any tests fail\n");
fprintf(stderr,
" -u|--usb The device is attached to a USB bus.\n"
" Additional restrictions apply, such as maximum transfer length 120kb.\n");
fprintf(stderr,
" -s|--silent Test Mode: Silent\n");
fprintf(stderr,
@@ -670,6 +673,7 @@ main(int argc, char *argv[])
struct scsi_readcapacity16 *rc16;
struct scsi_inquiry_standard *inq;
int full_size;
int is_usb;
static struct option long_opts[] = {
{ "help", no_argument, 0, '?' },
{ "list", no_argument, 0, 'l' },
@@ -682,6 +686,7 @@ main(int argc, char *argv[])
{ "abort", no_argument, 0, 'A' },
{ "silent", no_argument, 0, 's' },
{ "normal", no_argument, 0, 'n' },
{ "usb", no_argument, 0, 'u' },
{ "verbose", no_argument, 0, 'v' },
{ "Verbose-scsi", no_argument, 0, 'V' },
{ NULL, 0, 0, 0 }
@@ -689,7 +694,7 @@ main(int argc, char *argv[])
int i, c;
int opt_idx = 0;
while ((c = getopt_long(argc, argv, "?hli:I:t:sdgfAsnvV", long_opts,
while ((c = getopt_long(argc, argv, "?hli:I:t:sdgfAsnuvV", long_opts,
&opt_idx)) > 0) {
switch (c) {
case 'h':
@@ -726,6 +731,9 @@ main(int argc, char *argv[])
case 'n':
mode = CU_BRM_NORMAL;
break;
case 'u':
is_usb = 1;
break;
case 'v':
mode = CU_BRM_VERBOSE; /* default */
break;
@@ -917,6 +925,11 @@ main(int argc, char *argv[])
}
scsi_free_scsi_task(task);
if (is_usb) {
printf("USB device. Clamping maximum transfer length to 120k\n");
maximum_transfer_length = 120 *1024 / block_size;
}
iscsi_logout_sync(iscsic);
iscsi_destroy_context(iscsic);

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_orwrite_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -35,13 +37,13 @@ test_orwrite_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite_lbaoutofrange(iscsic, tgt_lun,
num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
@@ -53,39 +55,39 @@ test_orwrite_beyond_eol(void)
logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite_lbaoutofrange(iscsic, tgt_lun,
0x8000000000000000,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite_lbaoutofrange(iscsic, tgt_lun,
-1,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test ORWRITE 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite_lbaoutofrange(iscsic, tgt_lun,
num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_orwrite_flags(void)
{
int ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -37,14 +38,12 @@ test_orwrite_flags(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE flags");
buf = malloc(block_size);
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1");
ret = orwrite(iscsic, tgt_lun, 0,
block_size, block_size,
0, 1, 0, 0, 0, buf);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
free(buf);
return;
}
CU_ASSERT_EQUAL(ret, 0);
@@ -76,5 +75,4 @@ test_orwrite_flags(void)
block_size, block_size,
0, 1, 1, 1, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,6 +30,7 @@ void
test_orwrite_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -37,11 +39,11 @@ test_orwrite_simple(void)
logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
@@ -52,11 +54,11 @@ test_orwrite_simple(void)
logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = orwrite(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -17,6 +17,7 @@
#include <stdio.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,6 +31,9 @@ void
test_orwrite_verify(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
unsigned char *readbuf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -37,18 +41,14 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
unsigned char *readbuf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
memset(buf, 0, block_size * i);
ret = write16(iscsic, tgt_lun, 0, i * block_size,
ret = write10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
CU_PASS("WRITE16 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
@@ -63,7 +63,7 @@ test_orwrite_verify(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read16(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf);
CU_ASSERT_EQUAL(ret, 0);
@@ -78,7 +78,7 @@ test_orwrite_verify(void)
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read16(iscsic, tgt_lun, 0, i * block_size,
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf);
CU_ASSERT_EQUAL(ret, 0);
@@ -86,15 +86,13 @@ test_orwrite_verify(void)
memset(buf, 0xff, block_size * i);
ret = memcmp(buf, readbuf, block_size * i);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
free(readbuf);
}
logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
unsigned char *readbuf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
memset(buf, 0, block_size * i);
@@ -132,8 +130,5 @@ test_orwrite_verify(void)
memset(buf, 0xff, block_size * i);
ret = memcmp(buf, readbuf, block_size * i);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
free(readbuf);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_orwrite_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -40,18 +41,15 @@ test_orwrite_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = orwrite_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
i, 0, 0, 0, 0, buf);
if (ret == -2) {
free(buf);
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}

View File

@@ -37,6 +37,9 @@ test_read10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ10 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);
@@ -46,6 +49,9 @@ test_read10_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);
@@ -55,6 +61,9 @@ test_read10_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
@@ -63,6 +72,9 @@ test_read10_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2012 by Lee Duncan <lee@gonzoleeman.net>
@@ -35,6 +34,9 @@ test_read10_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
@@ -43,6 +45,9 @@ test_read10_simple(void)
logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -37,6 +37,9 @@ test_read12_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ12 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);
@@ -51,6 +54,9 @@ test_read12_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ12 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);
@@ -60,6 +66,9 @@ test_read12_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ12 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
@@ -68,6 +77,9 @@ test_read12_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ12 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);

View File

@@ -34,6 +34,9 @@ test_read12_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL);
if (ret == -2) {
@@ -47,6 +50,9 @@ test_read12_simple(void)
logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -34,6 +34,10 @@ test_read16_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ16 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);
@@ -48,6 +52,10 @@ test_read16_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);
@@ -57,6 +65,10 @@ test_read16_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
@@ -65,6 +77,10 @@ test_read16_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, NULL);

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -36,6 +35,10 @@ test_read16_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL);
if (ret == -2) {
@@ -49,6 +52,10 @@ test_read16_simple(void)
logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL);

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 by Ronnie Sahlberg <ronniesahlberg@gmail.com>

View File

@@ -33,6 +33,7 @@ test_verify10_0blocks(void)
ret = verify10(iscsic, tgt_lun, 0, 0, block_size,
0, 0, 1, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test");
return;
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_verify10_beyond_eol(void)
{
int i, ret;
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");
@@ -37,47 +39,52 @@ test_verify10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify10_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -44,6 +43,7 @@ test_verify10_flags(void)
ret = verify10(iscsic, tgt_lun, 0, block_size,
block_size, 0, 1, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test");
free(buf);
return;

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,13 +30,16 @@ 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");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -48,18 +52,18 @@ test_verify10_mismatch(void)
block_size, 0, 0, 1, buf);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -70,7 +74,6 @@ test_verify10_mismatch(void)
ret = verify10_miscompare(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,13 +30,16 @@ 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");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -48,19 +51,20 @@ test_verify10_mismatch_no_cmp(void)
ret = verify10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -71,7 +75,6 @@ test_verify10_mismatch_no_cmp(void)
ret = verify10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,11 +30,14 @@ 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 end of the LUN");
logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -42,25 +45,24 @@ test_verify10_simple(void)
ret = verify10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 1, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
ret = verify10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,21 +30,21 @@ 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");
for (i = 1; i < 8; i++) {
unsigned char *buf = malloc(block_size);
ret = read10(iscsic, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
ret = verify10_invalidfieldincdb(iscsic, tgt_lun, 0, block_size,
block_size, i, 0, 1, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY10 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY10. Skipping test");
return;
}

View File

@@ -33,6 +33,7 @@ test_verify12_0blocks(void)
ret = verify12(iscsic, tgt_lun, 0, 0, block_size,
0, 0, 1, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test");
return;
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_verify12_beyond_eol(void)
{
int i, ret;
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");
@@ -37,47 +39,52 @@ test_verify12_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify12_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify12_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY12 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify12_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,12 +30,12 @@ void
test_verify12_flags(void)
{
int ret;
unsigned char *buf = malloc(block_size);
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY12 flags");
ret = read12(iscsic, tgt_lun, 0, block_size,
ret = read10(iscsic, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -44,8 +44,8 @@ test_verify12_flags(void)
ret = verify12(iscsic, tgt_lun, 0, block_size,
block_size, 0, 1, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test");
free(buf);
return;
}
CU_ASSERT_EQUAL(ret, 0);
@@ -55,5 +55,4 @@ test_verify12_flags(void)
ret = verify12(iscsic, tgt_lun, 0, block_size,
block_size, 0, 0, 1, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,16 +30,18 @@ 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");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
ret = read12(iscsic, tgt_lun, 0, i * block_size,
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
@@ -47,19 +50,20 @@ test_verify12_mismatch(void)
ret = verify12_miscompare(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 1, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -70,7 +74,6 @@ test_verify12_mismatch(void)
ret = verify12_miscompare(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,16 +30,18 @@ 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");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
ret = read12(iscsic, tgt_lun, 0, i * block_size,
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
@@ -48,19 +50,20 @@ test_verify12_mismatch_no_cmp(void)
ret = verify12(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -71,7 +74,6 @@ test_verify12_mismatch_no_cmp(void)
ret = verify12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,37 +30,39 @@ 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 end of the LUN");
logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
ret = read12(iscsic, tgt_lun, 0, i * block_size,
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
ret = verify12(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 1, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
ret = verify12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,21 +30,20 @@ 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");
for (i = 1; i < 8; i++) {
unsigned char *buf = malloc(block_size);
ret = read12(iscsic, tgt_lun, 0, block_size,
ret = read10(iscsic, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
ret = verify12_invalidfieldincdb(iscsic, tgt_lun, 0, block_size,
block_size, i, 0, 1, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY12 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY12. Skipping test");
return;
}

View File

@@ -33,6 +33,7 @@ test_verify16_0blocks(void)
ret = verify16(iscsic, tgt_lun, 0, 0, block_size,
0, 0, 1, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
return;
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,51 +29,62 @@ void
test_verify16_beyond_eol(void)
{
int i, ret;
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");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify16_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = verify16_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,22 +31,21 @@ void
test_verify16_flags(void)
{
int ret;
unsigned char *buf = malloc(block_size);
unsigned char *buf = alloca(block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 flags");
ret = read16(iscsic, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test VERIFY16 with DPO==1");
ret = verify16(iscsic, tgt_lun, 0, block_size,
block_size, 0, 1, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
free(buf);
return;
}
CU_ASSERT_EQUAL(ret, 0);
@@ -55,5 +55,4 @@ test_verify16_flags(void)
ret = verify16(iscsic, tgt_lun, 0, block_size,
block_size, 0, 0, 1, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,16 +30,19 @@ void
test_verify16_mismatch(void)
{
int i, ret;
unsigned char *buf = malloc(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test VERIFY16 for blocks 1-255");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
@@ -47,19 +51,21 @@ test_verify16_mismatch(void)
ret = verify16_miscompare(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 1, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -70,7 +76,6 @@ test_verify16_mismatch(void)
ret = verify16_miscompare(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,16 +31,19 @@ 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");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
/* flip a random byte in the data */
buf[offset] ^= 'X';
@@ -48,19 +52,21 @@ test_verify16_mismatch_no_cmp(void)
ret = verify16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
int offset = random() % (i * block_size);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
@@ -71,7 +77,6 @@ test_verify16_mismatch_no_cmp(void)
ret = verify16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,29 +30,32 @@ 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 end of the LUN");
logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
ret = read16(iscsic, tgt_lun, 0, i * block_size,
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
ret = verify16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 1, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
free(buf);
return;
}
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = read16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
@@ -60,7 +63,6 @@ test_verify16_simple(void)
ret = verify16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 1, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,21 +30,20 @@ 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");
for (i = 1; i < 8; i++) {
unsigned char *buf = malloc(block_size);
ret = read16(iscsic, tgt_lun, 0, block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
ret = verify16_invalidfieldincdb(iscsic, tgt_lun, 0, block_size,
block_size, i, 0, 1, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
return;
}

View File

@@ -30,25 +30,25 @@ test_write10_0blocks(void)
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==0");
ret = write10(iscsic, tgt_lun, 0, 0, block_size,
0, 0, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
CU_PASS("WRITE10 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
if (num_blocks >= 0x80000000) {
CU_PASS("LUN is too big for read-beyond-eol tests with WRITE10. Skipping test.\n");
return;
}
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==0");
ret = write10(iscsic, tgt_lun, 0, 0, block_size,
0, 0, 0, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITE10 0-blocks one block past end-of-LUN");
ret = write10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 0,
block_size, 0, 0, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
CU_PASS("WRITE10 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_write10_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -39,12 +41,12 @@ test_write10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
CU_PASS("WRITE10 is not implemented.");
@@ -56,35 +58,35 @@ test_write10_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write10_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITE10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,14 +30,13 @@ void
test_write10_flags(void)
{
int ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 flags");
buf = malloc(block_size);
logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
ret = write10(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -75,5 +75,4 @@ test_write10_flags(void)
block_size, block_size,
0, 1, 1, 1, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,6 +30,8 @@ void
test_write10_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -36,11 +39,11 @@ test_write10_simple(void)
logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
CU_PASS("WRITE10 is not implemented.");
@@ -51,11 +54,11 @@ test_write10_simple(void)
logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_write10_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
@@ -39,7 +40,6 @@ test_write10_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE10 with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = write10_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -51,5 +51,4 @@ test_write10_wrprotect(void)
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_write12_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -39,12 +41,12 @@ test_write12_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE12 is not implemented.");
CU_PASS("WRITE12 is not implemented.");
@@ -56,35 +58,35 @@ test_write12_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write12_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write12_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITE12 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write12_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,14 +30,13 @@ void
test_write12_flags(void)
{
int ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE12 flags");
buf = malloc(block_size);
logging(LOG_VERBOSE, "Test WRITE12 with DPO==1");
ret = write12(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -75,5 +75,4 @@ test_write12_flags(void)
block_size, block_size,
0, 1, 1, 1, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,6 +30,7 @@ void
test_write12_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -36,11 +38,11 @@ test_write12_simple(void)
logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write12(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE12 is not implemented.");
CU_PASS("WRITE12 is not implemented.");
@@ -51,11 +53,11 @@ test_write12_simple(void)
logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_write12_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
@@ -39,7 +40,6 @@ test_write12_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE12 with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = write12_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -51,5 +51,4 @@ test_write12_wrprotect(void)
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,8 @@ void
test_write16_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -35,12 +38,13 @@ test_write16_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
CU_PASS("WRITE16 is not implemented.");
@@ -52,35 +56,35 @@ test_write16_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITE16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_write16_flags(void)
{
int ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -37,7 +38,6 @@ test_write16_flags(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE16 flags");
buf = malloc(block_size);
logging(LOG_VERBOSE, "Test WRITE16 with DPO==1");
ret = write16(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -76,5 +76,4 @@ test_write16_flags(void)
block_size, block_size,
0, 1, 1, 1, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,6 +30,8 @@ void
test_write16_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -37,11 +40,11 @@ test_write16_simple(void)
logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
CU_PASS("WRITE16 is not implemented.");
@@ -52,11 +55,11 @@ test_write16_simple(void)
logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = write16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_write16_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -40,7 +41,6 @@ test_write16_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITE16 with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = write16_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -52,5 +52,4 @@ test_write16_wrprotect(void)
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}

View File

@@ -37,6 +37,7 @@ test_writesame16_0blocks(void)
block_size, 0,
0, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
return;
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,8 @@ void
test_writesame16_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -35,13 +38,11 @@ test_writesame16_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size);
ret = writesame16_lbaoutofrange(iscsic, tgt_lun, num_blocks - i + 1,
block_size, i,
0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
return;
}
@@ -51,36 +52,27 @@ test_writesame16_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size);
ret = writesame16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000,
block_size, i,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size);
ret = writesame16_lbaoutofrange(iscsic, tgt_lun, -1,
block_size, i,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITESAME16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size);
ret = writesame16_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
block_size, i,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,9 @@ void
test_writesame16_simple(void)
{
int i, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -37,13 +40,11 @@ test_writesame16_simple(void)
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size);
ret = writesame16(iscsic, tgt_lun, 0,
block_size, i,
0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
return;
}
@@ -52,12 +53,9 @@ 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++) {
unsigned char *buf = malloc(block_size );
ret = writesame16(iscsic, tgt_lun, num_blocks - i,
block_size, i,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -17,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -31,6 +31,8 @@ test_writesame16_unmap(void)
{
int i, ret;
unsigned int j;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -40,19 +42,21 @@ 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");
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);
ret = write16(iscsic, tgt_lun, 0,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
ret = writesame16(iscsic, tgt_lun, 0,
block_size, i,
0, 1, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks and verify they are now zero", i);
@@ -64,14 +68,11 @@ test_writesame16_unmap(void)
CU_ASSERT_EQUAL(buf[j], 0);
}
}
free(buf);
}
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
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);
ret = write16(iscsic, tgt_lun, num_blocks - i,
@@ -94,7 +95,6 @@ test_writesame16_unmap(void)
CU_ASSERT_EQUAL(buf[j], 0);
}
}
free(buf);
}
logging(LOG_VERBOSE, "Verify that WRITESAME16 ANCHOR==1 + UNMAP==0 is invalid");

View File

@@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -39,11 +38,17 @@ test_writesame16_unmap_unaligned(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that unaligned WRITESAME16 Unmap fails. LBPPB==%d", lbppb);
for (i = 1; i < lbppb; i++) {
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16 at LBA:%d", lbppb - i, i);
ret = writesame16_invalidfieldincdb(iscsic, tgt_lun, i,
block_size, lbppb - i,
0, 1, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -30,6 +31,7 @@ test_writesame16_unmap_until_end(void)
{
int i, ret;
unsigned int j;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -39,19 +41,21 @@ 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");
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);
ret = write16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
ret = writesame16(iscsic, tgt_lun, num_blocks - i,
0, i,
0, 1, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks and verify they are now zero", i);
@@ -63,6 +67,5 @@ test_writesame16_unmap_until_end(void)
CU_ASSERT_EQUAL(buf[j], 0);
}
}
free(buf);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_writesame16_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -40,12 +41,16 @@ test_writesame16_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = writesame16_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, 1,
0, 0, i, 0, buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_writeverify10_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -39,12 +41,12 @@ test_writeverify10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE1VERIFY10 is not implemented.");
CU_PASS("WRITEVERIFY10 is not implemented.");
@@ -56,35 +58,35 @@ test_writeverify10_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITEVERIFY10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,14 +30,13 @@ void
test_writeverify10_flags(void)
{
int ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 flags");
buf = malloc(block_size);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1");
ret = writeverify10(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -53,6 +53,4 @@ test_writeverify10_flags(void)
block_size, block_size,
0, 0, 1, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,6 +30,7 @@ void
test_writeverify10_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -36,12 +38,13 @@ test_writeverify10_simple(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify10(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITEVERIFY10. Skipping test");
return;
}
@@ -50,11 +53,11 @@ test_writeverify10_simple(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify10(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_writeverify10_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
@@ -39,7 +40,6 @@ test_writeverify10_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = writeverify10_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -51,5 +51,4 @@ test_writeverify10_wrprotect(void)
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_writeverify12_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -39,12 +41,12 @@ test_writeverify12_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE1VERIFY12 is not implemented.");
CU_PASS("WRITEVERIFY12 is not implemented.");
@@ -56,35 +58,35 @@ test_writeverify12_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size,
block_size, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITEVERIFY12 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify12_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,14 +30,13 @@ void
test_writeverify12_flags(void)
{
int ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 flags");
buf = malloc(block_size);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1");
ret = writeverify12(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -53,6 +53,4 @@ test_writeverify12_flags(void)
block_size, block_size,
0, 0, 1, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,6 +30,7 @@ void
test_writeverify12_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
@@ -36,11 +38,11 @@ test_writeverify12_simple(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY12 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify12(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE1VERIFY12 is not implemented.");
CU_PASS("WRITEVERIFY12 is not implemented.");
@@ -51,11 +53,11 @@ test_writeverify12_simple(void)
logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify12(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,7 +30,7 @@ void
test_writeverify12_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
@@ -39,7 +40,6 @@ test_writeverify12_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = writeverify12_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -51,5 +51,4 @@ test_writeverify12_wrprotect(void)
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -28,6 +29,7 @@ void
test_writeverify16_beyond_eol(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -35,13 +37,14 @@ test_writeverify16_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
num_blocks + 1 - i,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE1VERIFY16 is not implemented.");
CU_PASS("WRITEVERIFY16 is not implemented.");
@@ -53,39 +56,42 @@ test_writeverify16_beyond_eol(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
0x8000000000000000,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
-1,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test WRITEVERIFY16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify16_lbaoutofrange(iscsic, tgt_lun,
num_blocks - 1,
i * block_size, block_size,
0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,14 +30,13 @@ void
test_writeverify16_flags(void)
{
int ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 flags");
buf = malloc(block_size);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1");
ret = writeverify16(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -53,6 +53,4 @@ test_writeverify16_flags(void)
block_size, block_size,
0, 0, 1, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
free(buf);
}

View File

@@ -47,6 +47,7 @@ test_writeverify16_residuals(void)
ret = writeverify16(iscsic, tgt_lun, 0, 0,
block_size, 0, 0, 0, 0, NULL);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE1VERIFY16 is not implemented.");
CU_PASS("[SKIPPED] Target does not support WRITEVERIFY16. Skipping test");
return;
}

View File

@@ -16,6 +16,7 @@
*/
#include <stdio.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -29,6 +30,7 @@ void
test_writeverify16_simple(void)
{
int i, ret;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -37,11 +39,12 @@ test_writeverify16_simple(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify16(iscsic, tgt_lun, 0, i * block_size,
block_size, 0, 0, 0, 0, buf);
free(buf);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE1VERIFY16 is not implemented.");
CU_PASS("WRITEVERIFY16 is not implemented.");
@@ -52,11 +55,12 @@ test_writeverify16_simple(void)
logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
unsigned char *buf = malloc(block_size * i);
if (maximum_transfer_length && maximum_transfer_length < i) {
break;
}
ret = writeverify16(iscsic, tgt_lun, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, buf);
free(buf);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <alloca.h>
#include <CUnit/CUnit.h>
@@ -25,11 +26,13 @@
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
void
test_writeverify16_wrprotect(void)
{
int i, ret;
unsigned char *buf;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -40,7 +43,6 @@ test_writeverify16_wrprotect(void)
*/
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 with non-zero WRPROTECT");
buf = malloc(block_size);
for (i = 1; i < 8; i++) {
ret = writeverify16_invalidfieldincdb(iscsic, tgt_lun, 0,
block_size, block_size,
@@ -52,5 +54,4 @@ test_writeverify16_wrprotect(void)
}
CU_ASSERT_EQUAL(ret, 0);
}
free(buf);
}