From 2627a8845e61f73a04cf4f7d29d31cdf96e22619 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sat, 27 Apr 2013 09:59:59 -0700 Subject: [PATCH] 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 --- test-tool/iscsi-support.c | 1 + test-tool/iscsi-support.h | 1 + test-tool/iscsi-test-cu.c | 15 +++++++++- test-tool/test_orwrite_beyond_eol.c | 26 ++++++++-------- test-tool/test_orwrite_flags.c | 6 ++-- test-tool/test_orwrite_simple.c | 14 +++++---- test-tool/test_orwrite_verify.c | 31 ++++++++------------ test-tool/test_orwrite_wrprotect.c | 6 ++-- test-tool/test_read10_beyond_eol.c | 12 ++++++++ test-tool/test_read10_simple.c | 7 ++++- test-tool/test_read12_beyond_eol.c | 12 ++++++++ test-tool/test_read12_simple.c | 6 ++++ test-tool/test_read16_beyond_eol.c | 16 ++++++++++ test-tool/test_read16_simple.c | 9 +++++- test-tool/test_readcapacity16_simple.c | 1 - test-tool/test_verify10_0blocks.c | 1 + test-tool/test_verify10_beyond_eol.c | 31 ++++++++++++-------- test-tool/test_verify10_flags.c | 2 +- test-tool/test_verify10_mismatch.c | 13 ++++---- test-tool/test_verify10_mismatch_no_cmp.c | 15 ++++++---- test-tool/test_verify10_simple.c | 18 +++++++----- test-tool/test_verify10_vrprotect.c | 8 ++--- test-tool/test_verify12_0blocks.c | 1 + test-tool/test_verify12_beyond_eol.c | 31 ++++++++++++-------- test-tool/test_verify12_flags.c | 9 +++--- test-tool/test_verify12_mismatch.c | 17 ++++++----- test-tool/test_verify12_mismatch_no_cmp.c | 18 +++++++----- test-tool/test_verify12_simple.c | 20 +++++++------ test-tool/test_verify12_vrprotect.c | 9 +++--- test-tool/test_verify16_0blocks.c | 1 + test-tool/test_verify16_beyond_eol.c | 28 +++++++++++++----- test-tool/test_verify16_flags.c | 7 ++--- test-tool/test_verify16_mismatch.c | 17 +++++++---- test-tool/test_verify16_mismatch_no_cmp.c | 17 +++++++---- test-tool/test_verify16_simple.c | 20 +++++++------ test-tool/test_verify16_vrprotect.c | 9 +++--- test-tool/test_write10_0blocks.c | 22 +++++++------- test-tool/test_write10_beyond_eol.c | 26 ++++++++-------- test-tool/test_write10_flags.c | 5 ++-- test-tool/test_write10_simple.c | 15 ++++++---- test-tool/test_write10_wrprotect.c | 5 ++-- test-tool/test_write12_beyond_eol.c | 26 ++++++++-------- test-tool/test_write12_flags.c | 5 ++-- test-tool/test_write12_simple.c | 14 +++++---- test-tool/test_write12_wrprotect.c | 5 ++-- test-tool/test_write16_beyond_eol.c | 26 +++++++++------- test-tool/test_write16_flags.c | 5 ++-- test-tool/test_write16_simple.c | 15 ++++++---- test-tool/test_write16_wrprotect.c | 5 ++-- test-tool/test_writesame16_0blocks.c | 1 + test-tool/test_writesame16_beyond_eol.c | 16 +++------- test-tool/test_writesame16_simple.c | 10 +++---- test-tool/test_writesame16_unmap.c | 16 +++++----- test-tool/test_writesame16_unmap_unaligned.c | 7 ++++- test-tool/test_writesame16_unmap_until_end.c | 11 ++++--- test-tool/test_writesame16_wrprotect.c | 11 +++++-- test-tool/test_writeverify10_beyond_eol.c | 26 ++++++++-------- test-tool/test_writeverify10_flags.c | 6 ++-- test-tool/test_writeverify10_simple.c | 15 ++++++---- test-tool/test_writeverify10_wrprotect.c | 5 ++-- test-tool/test_writeverify12_beyond_eol.c | 26 ++++++++-------- test-tool/test_writeverify12_flags.c | 6 ++-- test-tool/test_writeverify12_simple.c | 14 +++++---- test-tool/test_writeverify12_wrprotect.c | 5 ++-- test-tool/test_writeverify16_beyond_eol.c | 24 +++++++++------ test-tool/test_writeverify16_flags.c | 6 ++-- test-tool/test_writeverify16_residuals.c | 1 + test-tool/test_writeverify16_simple.c | 12 +++++--- test-tool/test_writeverify16_wrprotect.c | 7 +++-- 69 files changed, 500 insertions(+), 354 deletions(-) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 35ff78f..3190cef 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -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); diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index ca5ae06..613081c 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -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); diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index 6c5511d..874257b 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -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); diff --git a/test-tool/test_orwrite_beyond_eol.c b/test-tool/test_orwrite_beyond_eol.c index 0d73bde..81c905b 100644 --- a/test-tool/test_orwrite_beyond_eol.c +++ b/test-tool/test_orwrite_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_orwrite_flags.c b/test-tool/test_orwrite_flags.c index 759c68e..6f4ee85 100644 --- a/test-tool/test_orwrite_flags.c +++ b/test-tool/test_orwrite_flags.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_orwrite_simple.c b/test-tool/test_orwrite_simple.c index 7336de0..abf620c 100644 --- a/test-tool/test_orwrite_simple.c +++ b/test-tool/test_orwrite_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_orwrite_verify.c b/test-tool/test_orwrite_verify.c index ed7fd02..57c8327 100644 --- a/test-tool/test_orwrite_verify.c +++ b/test-tool/test_orwrite_verify.c @@ -17,6 +17,7 @@ #include #include +#include #include @@ -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); } } diff --git a/test-tool/test_orwrite_wrprotect.c b/test-tool/test_orwrite_wrprotect.c index 5354c1c..5ca5a1f 100644 --- a/test-tool/test_orwrite_wrprotect.c +++ b/test-tool/test_orwrite_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_read10_beyond_eol.c b/test-tool/test_read10_beyond_eol.c index c0a459b..213cc83 100644 --- a/test-tool/test_read10_beyond_eol.c +++ b/test-tool/test_read10_beyond_eol.c @@ -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); diff --git a/test-tool/test_read10_simple.c b/test-tool/test_read10_simple.c index 6aa7095..663a2e2 100644 --- a/test-tool/test_read10_simple.c +++ b/test-tool/test_read10_simple.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2012 by Lee Duncan @@ -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); diff --git a/test-tool/test_read12_beyond_eol.c b/test-tool/test_read12_beyond_eol.c index 4efa32b..5de1699 100644 --- a/test-tool/test_read12_beyond_eol.c +++ b/test-tool/test_read12_beyond_eol.c @@ -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); diff --git a/test-tool/test_read12_simple.c b/test-tool/test_read12_simple.c index 65e999f..ce886cf 100644 --- a/test-tool/test_read12_simple.c +++ b/test-tool/test_read12_simple.c @@ -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); diff --git a/test-tool/test_read16_beyond_eol.c b/test-tool/test_read16_beyond_eol.c index 571ef52..c8f30be 100644 --- a/test-tool/test_read16_beyond_eol.c +++ b/test-tool/test_read16_beyond_eol.c @@ -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); diff --git a/test-tool/test_read16_simple.c b/test-tool/test_read16_simple.c index 04746ee..ad92ec8 100644 --- a/test-tool/test_read16_simple.c +++ b/test-tool/test_read16_simple.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -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); diff --git a/test-tool/test_readcapacity16_simple.c b/test-tool/test_readcapacity16_simple.c index 2b541e1..8aedd11 100644 --- a/test-tool/test_readcapacity16_simple.c +++ b/test-tool/test_readcapacity16_simple.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 by Ronnie Sahlberg diff --git a/test-tool/test_verify10_0blocks.c b/test-tool/test_verify10_0blocks.c index 1411671..f30cf85 100644 --- a/test-tool/test_verify10_0blocks.c +++ b/test-tool/test_verify10_0blocks.c @@ -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; } diff --git a/test-tool/test_verify10_beyond_eol.c b/test-tool/test_verify10_beyond_eol.c index ac5f14a..189f005 100644 --- a/test-tool/test_verify10_beyond_eol.c +++ b/test-tool/test_verify10_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify10_flags.c b/test-tool/test_verify10_flags.c index a8431fa..993d276 100644 --- a/test-tool/test_verify10_flags.c +++ b/test-tool/test_verify10_flags.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -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; diff --git a/test-tool/test_verify10_mismatch.c b/test-tool/test_verify10_mismatch.c index f7f5ef2..7cd4583 100644 --- a/test-tool/test_verify10_mismatch.c +++ b/test-tool/test_verify10_mismatch.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify10_mismatch_no_cmp.c b/test-tool/test_verify10_mismatch_no_cmp.c index f7f7e56..b255969 100644 --- a/test-tool/test_verify10_mismatch_no_cmp.c +++ b/test-tool/test_verify10_mismatch_no_cmp.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify10_simple.c b/test-tool/test_verify10_simple.c index 4dac5ce..a79f975 100644 --- a/test-tool/test_verify10_simple.c +++ b/test-tool/test_verify10_simple.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify10_vrprotect.c b/test-tool/test_verify10_vrprotect.c index 50828f3..c502134 100644 --- a/test-tool/test_verify10_vrprotect.c +++ b/test-tool/test_verify10_vrprotect.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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; } diff --git a/test-tool/test_verify12_0blocks.c b/test-tool/test_verify12_0blocks.c index ffa1e0b..b004f57 100644 --- a/test-tool/test_verify12_0blocks.c +++ b/test-tool/test_verify12_0blocks.c @@ -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; } diff --git a/test-tool/test_verify12_beyond_eol.c b/test-tool/test_verify12_beyond_eol.c index 74a0e04..3efc38f 100644 --- a/test-tool/test_verify12_beyond_eol.c +++ b/test-tool/test_verify12_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify12_flags.c b/test-tool/test_verify12_flags.c index e8e14d2..8da86aa 100644 --- a/test-tool/test_verify12_flags.c +++ b/test-tool/test_verify12_flags.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_verify12_mismatch.c b/test-tool/test_verify12_mismatch.c index 7b59425..879a42c 100644 --- a/test-tool/test_verify12_mismatch.c +++ b/test-tool/test_verify12_mismatch.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify12_mismatch_no_cmp.c b/test-tool/test_verify12_mismatch_no_cmp.c index 4ca1076..13734e3 100644 --- a/test-tool/test_verify12_mismatch_no_cmp.c +++ b/test-tool/test_verify12_mismatch_no_cmp.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify12_simple.c b/test-tool/test_verify12_simple.c index cb71626..99a4e8d 100644 --- a/test-tool/test_verify12_simple.c +++ b/test-tool/test_verify12_simple.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify12_vrprotect.c b/test-tool/test_verify12_vrprotect.c index 14d24dd..f6e38d3 100644 --- a/test-tool/test_verify12_vrprotect.c +++ b/test-tool/test_verify12_vrprotect.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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; } diff --git a/test-tool/test_verify16_0blocks.c b/test-tool/test_verify16_0blocks.c index b091a39..0abf23a 100644 --- a/test-tool/test_verify16_0blocks.c +++ b/test-tool/test_verify16_0blocks.c @@ -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; } diff --git a/test-tool/test_verify16_beyond_eol.c b/test-tool/test_verify16_beyond_eol.c index c87155d..f11f2c8 100644 --- a/test-tool/test_verify16_beyond_eol.c +++ b/test-tool/test_verify16_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify16_flags.c b/test-tool/test_verify16_flags.c index 0520114..af38f2b 100644 --- a/test-tool/test_verify16_flags.c +++ b/test-tool/test_verify16_flags.c @@ -17,6 +17,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_verify16_mismatch.c b/test-tool/test_verify16_mismatch.c index fbceb98..e21e3e0 100644 --- a/test-tool/test_verify16_mismatch.c +++ b/test-tool/test_verify16_mismatch.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify16_mismatch_no_cmp.c b/test-tool/test_verify16_mismatch_no_cmp.c index f5f633e..31e7c6c 100644 --- a/test-tool/test_verify16_mismatch_no_cmp.c +++ b/test-tool/test_verify16_mismatch_no_cmp.c @@ -17,6 +17,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify16_simple.c b/test-tool/test_verify16_simple.c index bb62466..1c020e1 100644 --- a/test-tool/test_verify16_simple.c +++ b/test-tool/test_verify16_simple.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_verify16_vrprotect.c b/test-tool/test_verify16_vrprotect.c index 60ca4a0..332cc7f 100644 --- a/test-tool/test_verify16_vrprotect.c +++ b/test-tool/test_verify16_vrprotect.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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; } diff --git a/test-tool/test_write10_0blocks.c b/test-tool/test_write10_0blocks.c index 426c850..57f6666 100644 --- a/test-tool/test_write10_0blocks.c +++ b/test-tool/test_write10_0blocks.c @@ -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); diff --git a/test-tool/test_write10_beyond_eol.c b/test-tool/test_write10_beyond_eol.c index 1c8c93e..e810c60 100644 --- a/test-tool/test_write10_beyond_eol.c +++ b/test-tool/test_write10_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_write10_flags.c b/test-tool/test_write10_flags.c index 3d24c08..e880435 100644 --- a/test-tool/test_write10_flags.c +++ b/test-tool/test_write10_flags.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_write10_simple.c b/test-tool/test_write10_simple.c index e79edb8..0c25224 100644 --- a/test-tool/test_write10_simple.c +++ b/test-tool/test_write10_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_write10_wrprotect.c b/test-tool/test_write10_wrprotect.c index 683f1bd..678b9fe 100644 --- a/test-tool/test_write10_wrprotect.c +++ b/test-tool/test_write10_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_write12_beyond_eol.c b/test-tool/test_write12_beyond_eol.c index deb3f2e..b569698 100644 --- a/test-tool/test_write12_beyond_eol.c +++ b/test-tool/test_write12_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_write12_flags.c b/test-tool/test_write12_flags.c index c212ed5..711ec69 100644 --- a/test-tool/test_write12_flags.c +++ b/test-tool/test_write12_flags.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_write12_simple.c b/test-tool/test_write12_simple.c index 580d61b..3fcc1e7 100644 --- a/test-tool/test_write12_simple.c +++ b/test-tool/test_write12_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_write12_wrprotect.c b/test-tool/test_write12_wrprotect.c index 1bb7845..d02dc73 100644 --- a/test-tool/test_write12_wrprotect.c +++ b/test-tool/test_write12_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_write16_beyond_eol.c b/test-tool/test_write16_beyond_eol.c index 210963a..b4d0b01 100644 --- a/test-tool/test_write16_beyond_eol.c +++ b/test-tool/test_write16_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_write16_flags.c b/test-tool/test_write16_flags.c index 69bfec4..76fc653 100644 --- a/test-tool/test_write16_flags.c +++ b/test-tool/test_write16_flags.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_write16_simple.c b/test-tool/test_write16_simple.c index 42c9a39..c1e2c90 100644 --- a/test-tool/test_write16_simple.c +++ b/test-tool/test_write16_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_write16_wrprotect.c b/test-tool/test_write16_wrprotect.c index c839bfa..5c83646 100644 --- a/test-tool/test_write16_wrprotect.c +++ b/test-tool/test_write16_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_writesame16_0blocks.c b/test-tool/test_writesame16_0blocks.c index ae9e77d..3120a32 100644 --- a/test-tool/test_writesame16_0blocks.c +++ b/test-tool/test_writesame16_0blocks.c @@ -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; } diff --git a/test-tool/test_writesame16_beyond_eol.c b/test-tool/test_writesame16_beyond_eol.c index ac0f56f..468a146 100644 --- a/test-tool/test_writesame16_beyond_eol.c +++ b/test-tool/test_writesame16_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_writesame16_simple.c b/test-tool/test_writesame16_simple.c index bee4255..719eb0d 100644 --- a/test-tool/test_writesame16_simple.c +++ b/test-tool/test_writesame16_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_writesame16_unmap.c b/test-tool/test_writesame16_unmap.c index a2d29e0..6df98ea 100644 --- a/test-tool/test_writesame16_unmap.c +++ b/test-tool/test_writesame16_unmap.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -17,6 +16,7 @@ */ #include +#include #include @@ -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"); diff --git a/test-tool/test_writesame16_unmap_unaligned.c b/test-tool/test_writesame16_unmap_unaligned.c index 1d55835..d1bc44f 100644 --- a/test-tool/test_writesame16_unmap_unaligned.c +++ b/test-tool/test_writesame16_unmap_unaligned.c @@ -1,4 +1,3 @@ - /* Copyright (C) 2013 Ronnie Sahlberg @@ -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); } } diff --git a/test-tool/test_writesame16_unmap_until_end.c b/test-tool/test_writesame16_unmap_until_end.c index 2dff894..e2f1176 100644 --- a/test-tool/test_writesame16_unmap_until_end.c +++ b/test-tool/test_writesame16_unmap_until_end.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_writesame16_wrprotect.c b/test-tool/test_writesame16_wrprotect.c index a75e9f5..ed256be 100644 --- a/test-tool/test_writesame16_wrprotect.c +++ b/test-tool/test_writesame16_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify10_beyond_eol.c b/test-tool/test_writeverify10_beyond_eol.c index 3b3aac6..cd61478 100644 --- a/test-tool/test_writeverify10_beyond_eol.c +++ b/test-tool/test_writeverify10_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_writeverify10_flags.c b/test-tool/test_writeverify10_flags.c index 39fa3c0..3cd1f6b 100644 --- a/test-tool/test_writeverify10_flags.c +++ b/test-tool/test_writeverify10_flags.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify10_simple.c b/test-tool/test_writeverify10_simple.c index ff8080b..2b8731b 100644 --- a/test-tool/test_writeverify10_simple.c +++ b/test-tool/test_writeverify10_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify10_wrprotect.c b/test-tool/test_writeverify10_wrprotect.c index a705d91..4a89a0e 100644 --- a/test-tool/test_writeverify10_wrprotect.c +++ b/test-tool/test_writeverify10_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify12_beyond_eol.c b/test-tool/test_writeverify12_beyond_eol.c index 5a60227..1fa3c32 100644 --- a/test-tool/test_writeverify12_beyond_eol.c +++ b/test-tool/test_writeverify12_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_writeverify12_flags.c b/test-tool/test_writeverify12_flags.c index 0cecb2f..a091af7 100644 --- a/test-tool/test_writeverify12_flags.c +++ b/test-tool/test_writeverify12_flags.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify12_simple.c b/test-tool/test_writeverify12_simple.c index 46c6302..1ca406b 100644 --- a/test-tool/test_writeverify12_simple.c +++ b/test-tool/test_writeverify12_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify12_wrprotect.c b/test-tool/test_writeverify12_wrprotect.c index e50fc35..8d6de1d 100644 --- a/test-tool/test_writeverify12_wrprotect.c +++ b/test-tool/test_writeverify12_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify16_beyond_eol.c b/test-tool/test_writeverify16_beyond_eol.c index a8030e1..de27d96 100644 --- a/test-tool/test_writeverify16_beyond_eol.c +++ b/test-tool/test_writeverify16_beyond_eol.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } } diff --git a/test-tool/test_writeverify16_flags.c b/test-tool/test_writeverify16_flags.c index b9abeb0..26a6ea4 100644 --- a/test-tool/test_writeverify16_flags.c +++ b/test-tool/test_writeverify16_flags.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify16_residuals.c b/test-tool/test_writeverify16_residuals.c index 32e2cc9..4e1efb8 100644 --- a/test-tool/test_writeverify16_residuals.c +++ b/test-tool/test_writeverify16_residuals.c @@ -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; } diff --git a/test-tool/test_writeverify16_simple.c b/test-tool/test_writeverify16_simple.c index d10f8a9..5a9021d 100644 --- a/test-tool/test_writeverify16_simple.c +++ b/test-tool/test_writeverify16_simple.c @@ -16,6 +16,7 @@ */ #include +#include #include @@ -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); } diff --git a/test-tool/test_writeverify16_wrprotect.c b/test-tool/test_writeverify16_wrprotect.c index 3f29e62..f627f96 100644 --- a/test-tool/test_writeverify16_wrprotect.c +++ b/test-tool/test_writeverify16_wrprotect.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -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); }