diff --git a/test-tool/test_compareandwrite_miscompare.c b/test-tool/test_compareandwrite_miscompare.c index 5da9727..c56c305 100644 --- a/test-tool/test_compareandwrite_miscompare.c +++ b/test-tool/test_compareandwrite_miscompare.c @@ -31,7 +31,7 @@ void test_compareandwrite_miscompare(void) { - int i, ret; + int i; unsigned j; int maxbl; @@ -53,16 +53,9 @@ test_compareandwrite_miscompare(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = write16(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented."); - CU_PASS("WRITE16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); - + WRITE16(sd, 0, i * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match."); scratch[i * block_size - 27] = 'C'; @@ -90,10 +83,9 @@ test_compareandwrite_miscompare(void) logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify " "they are still unchanged as 'A'", i); - ret = read16(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + read16(sd, NULL, 0, i * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); for (j = 0; j < i * block_size; j++) { if (scratch[j] != 'A') { @@ -115,10 +107,9 @@ test_compareandwrite_miscompare(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = write16(sd, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITE16(sd, num_blocks - i, i * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match."); scratch[i * block_size - 27] = 'C'; @@ -148,10 +139,9 @@ test_compareandwrite_miscompare(void) logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64 "they are still unchanged as 'A'", i, num_blocks - i); - ret = read16(sd, NULL, num_blocks - i, i * block_size, + read16(sd, NULL, num_blocks - i, i * block_size, block_size, 0, 0, 0, 0, 0, scratch, EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); for (j = 0; j < i * block_size; j++) { if (scratch[j] != 'A') { diff --git a/test-tool/test_compareandwrite_simple.c b/test-tool/test_compareandwrite_simple.c index 3b08cf7..dffa249 100644 --- a/test-tool/test_compareandwrite_simple.c +++ b/test-tool/test_compareandwrite_simple.c @@ -54,15 +54,9 @@ test_compareandwrite_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = write16(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented."); - CU_PASS("WRITE16 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + WRITE16(sd, 0, i * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (i > maxbl) { logging(LOG_VERBOSE, "Number of blocks %d is greater than " @@ -113,10 +107,9 @@ test_compareandwrite_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = write16(sd, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITE16(sd, num_blocks - i, i * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); if (i > maxbl) { logging(LOG_VERBOSE, "Number of blocks %d is greater than " diff --git a/test-tool/test_orwrite_verify.c b/test-tool/test_orwrite_verify.c index 47e01e9..9216d31 100644 --- a/test-tool/test_orwrite_verify.c +++ b/test-tool/test_orwrite_verify.c @@ -83,10 +83,9 @@ test_orwrite_verify(void) CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Read %d blocks back", i); - ret = read10(sd, NULL, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, readbuf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + read10(sd, NULL, 0, i * block_size, + block_size, 0, 0, 0, 0, 0, readbuf, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Verify that the blocks are all 0xff"); memset(buf, 0xff, block_size * i); @@ -102,10 +101,9 @@ test_orwrite_verify(void) logging(LOG_VERBOSE, "Write %d blocks of all-zero", i); memset(buf, 0, block_size * i); - ret = write16(sd, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + WRITE16(sd, num_blocks - i, i * block_size, + block_size, 0, 0, 0, 0, 0, buf, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i); memset(buf, 0xa5, block_size * i); diff --git a/test-tool/test_sanitize_block_erase.c b/test-tool/test_sanitize_block_erase.c index 9a791f1..b5cd743 100644 --- a/test-tool/test_sanitize_block_erase.c +++ b/test-tool/test_sanitize_block_erase.c @@ -192,18 +192,6 @@ check_unmap(void) scsi_free_scsi_task(task_ret); } -static void -init_lun_with_data(unsigned char *buf, uint64_t lba) -{ - int ret; - - memset(buf, 'a', 256 * block_size); - ret = write16(sd, lba, 256 * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); -} - static void check_lun_is_wiped(unsigned char *buf, uint64_t lba) { @@ -316,9 +304,14 @@ test_sanitize_block_erase(void) logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs"); - init_lun_with_data(buf, 0); + memset(scratch, 'a', 256 * block_size); + WRITE16(sd, 0, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs"); - init_lun_with_data(buf, num_blocks - 256); + WRITE16(sd, num_blocks - 256, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE"); diff --git a/test-tool/test_sanitize_crypto_erase.c b/test-tool/test_sanitize_crypto_erase.c index c3b3392..cf95ed0 100644 --- a/test-tool/test_sanitize_crypto_erase.c +++ b/test-tool/test_sanitize_crypto_erase.c @@ -101,18 +101,6 @@ check_wacereq(void) scsi_free_scsi_task(task_ret); } -static void -init_lun_with_data(unsigned char *buf, uint64_t lba) -{ - int ret; - - memset(buf, 'a', 256 * block_size); - ret = write16(sd, lba, 256 * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); -} - static void check_lun_is_wiped(unsigned char *buf, uint64_t lba) { @@ -178,9 +166,14 @@ test_sanitize_crypto_erase(void) logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs"); - init_lun_with_data(buf, 0); + memset(scratch, 'a', 256 * block_size); + WRITE16(sd, 0, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs"); - init_lun_with_data(buf, num_blocks - 256); + WRITE16(sd, num_blocks - 256, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE"); diff --git a/test-tool/test_sanitize_overwrite.c b/test-tool/test_sanitize_overwrite.c index a39d086..138a888 100644 --- a/test-tool/test_sanitize_overwrite.c +++ b/test-tool/test_sanitize_overwrite.c @@ -27,19 +27,6 @@ #include "scsi-lowlevel.h" #include "iscsi-test-cu.h" -static void -init_lun_with_data(uint64_t lba) -{ - int ret; - unsigned char *buf = alloca(256 * block_size); - - memset(buf, 'a', 256 * block_size); - ret = write16(sd, lba, 256 * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); -} - static void check_lun_is_wiped(uint64_t lba, unsigned char c) { @@ -110,9 +97,14 @@ test_sanitize_overwrite(void) } logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs"); - init_lun_with_data(0); + memset(scratch, 'a', 256 * block_size); + WRITE16(sd, 0, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs"); - init_lun_with_data(num_blocks - 256); + WRITE16(sd, num_blocks - 256, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of one full block"); data.size = block_size + 4; diff --git a/test-tool/test_unmap_simple.c b/test-tool/test_unmap_simple.c index 55c432c..49c3c75 100644 --- a/test-tool/test_unmap_simple.c +++ b/test-tool/test_unmap_simple.c @@ -26,18 +26,6 @@ #include "iscsi-support.h" #include "iscsi-test-cu.h" -static void -init_lun_with_data(uint64_t lba) -{ - int ret; - - memset(scratch, 'a', 256 * block_size); - ret = write10(sd, lba, 256 * block_size, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); -} - void test_unmap_simple(void) { @@ -56,7 +44,10 @@ test_unmap_simple(void) "LUN as a single descriptor"); logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs"); - init_lun_with_data(0); + memset(scratch, 'a', 256 * block_size); + WRITE10(sd, 0, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); for (i = 1; i <= 256; i++) { logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i); @@ -91,7 +82,10 @@ test_unmap_simple(void) "LUN with one descriptor per block"); logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs"); - init_lun_with_data(0); + memset(scratch, 'a', 256 * block_size); + WRITE10(sd, 0, 256 * block_size, + block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); for (i = 0; i < 256; i++) {