Tests: Convert remaining write16 to new helpers
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
void
|
void
|
||||||
test_compareandwrite_miscompare(void)
|
test_compareandwrite_miscompare(void)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i;
|
||||||
unsigned j;
|
unsigned j;
|
||||||
int maxbl;
|
int maxbl;
|
||||||
|
|
||||||
@@ -53,16 +53,9 @@ test_compareandwrite_miscompare(void)
|
|||||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = write16(sd, 0, i * block_size,
|
WRITE16(sd, 0, i * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, scratch,
|
block_size, 0, 0, 0, 0, 0, scratch,
|
||||||
EXPECT_STATUS_GOOD);
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
|
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
|
||||||
scratch[i * block_size - 27] = 'C';
|
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 "
|
logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
|
||||||
"they are still unchanged as 'A'", i);
|
"they are still unchanged as 'A'", i);
|
||||||
ret = read16(sd, NULL, 0, i * block_size,
|
read16(sd, NULL, 0, i * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, scratch,
|
block_size, 0, 0, 0, 0, 0, scratch,
|
||||||
EXPECT_STATUS_GOOD);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
for (j = 0; j < i * block_size; j++) {
|
for (j = 0; j < i * block_size; j++) {
|
||||||
if (scratch[j] != 'A') {
|
if (scratch[j] != 'A') {
|
||||||
@@ -115,10 +107,9 @@ test_compareandwrite_miscompare(void)
|
|||||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = write16(sd, num_blocks - i, i * block_size,
|
WRITE16(sd, num_blocks - i, i * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, scratch,
|
block_size, 0, 0, 0, 0, 0, scratch,
|
||||||
EXPECT_STATUS_GOOD);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
|
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
|
||||||
scratch[i * block_size - 27] = 'C';
|
scratch[i * block_size - 27] = 'C';
|
||||||
@@ -148,10 +139,9 @@ test_compareandwrite_miscompare(void)
|
|||||||
logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
|
logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
|
||||||
"they are still unchanged as 'A'",
|
"they are still unchanged as 'A'",
|
||||||
i, num_blocks - i);
|
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,
|
block_size, 0, 0, 0, 0, 0, scratch,
|
||||||
EXPECT_STATUS_GOOD);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
for (j = 0; j < i * block_size; j++) {
|
for (j = 0; j < i * block_size; j++) {
|
||||||
if (scratch[j] != 'A') {
|
if (scratch[j] != 'A') {
|
||||||
|
|||||||
@@ -54,15 +54,9 @@ test_compareandwrite_simple(void)
|
|||||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = write16(sd, 0, i * block_size,
|
WRITE16(sd, 0, i * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, scratch,
|
block_size, 0, 0, 0, 0, 0, scratch,
|
||||||
EXPECT_STATUS_GOOD);
|
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);
|
|
||||||
|
|
||||||
if (i > maxbl) {
|
if (i > maxbl) {
|
||||||
logging(LOG_VERBOSE, "Number of blocks %d is greater than "
|
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) {
|
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = write16(sd, num_blocks - i, i * block_size,
|
WRITE16(sd, num_blocks - i, i * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, scratch,
|
block_size, 0, 0, 0, 0, 0, scratch,
|
||||||
EXPECT_STATUS_GOOD);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
if (i > maxbl) {
|
if (i > maxbl) {
|
||||||
logging(LOG_VERBOSE, "Number of blocks %d is greater than "
|
logging(LOG_VERBOSE, "Number of blocks %d is greater than "
|
||||||
|
|||||||
@@ -83,10 +83,9 @@ test_orwrite_verify(void)
|
|||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Read %d blocks back", i);
|
logging(LOG_VERBOSE, "Read %d blocks back", i);
|
||||||
ret = read10(sd, NULL, 0, i * block_size,
|
read10(sd, NULL, 0, i * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, readbuf,
|
block_size, 0, 0, 0, 0, 0, readbuf,
|
||||||
EXPECT_STATUS_GOOD);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");
|
logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");
|
||||||
memset(buf, 0xff, block_size * i);
|
memset(buf, 0xff, block_size * i);
|
||||||
@@ -102,10 +101,9 @@ test_orwrite_verify(void)
|
|||||||
|
|
||||||
logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
|
logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
|
||||||
memset(buf, 0, block_size * i);
|
memset(buf, 0, block_size * i);
|
||||||
ret = write16(sd, num_blocks - i, i * block_size,
|
WRITE16(sd, num_blocks - i, i * block_size,
|
||||||
block_size, 0, 0, 0, 0, 0, buf,
|
block_size, 0, 0, 0, 0, 0, buf,
|
||||||
EXPECT_STATUS_GOOD);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
|
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
|
||||||
memset(buf, 0xa5, block_size * i);
|
memset(buf, 0xa5, block_size * i);
|
||||||
|
|||||||
@@ -192,18 +192,6 @@ check_unmap(void)
|
|||||||
scsi_free_scsi_task(task_ret);
|
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
|
static void
|
||||||
check_lun_is_wiped(unsigned char *buf, uint64_t lba)
|
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");
|
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");
|
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");
|
logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE");
|
||||||
|
|||||||
@@ -101,18 +101,6 @@ check_wacereq(void)
|
|||||||
scsi_free_scsi_task(task_ret);
|
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
|
static void
|
||||||
check_lun_is_wiped(unsigned char *buf, uint64_t lba)
|
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");
|
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");
|
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");
|
logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE");
|
||||||
|
|||||||
@@ -27,19 +27,6 @@
|
|||||||
#include "scsi-lowlevel.h"
|
#include "scsi-lowlevel.h"
|
||||||
#include "iscsi-test-cu.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
|
static void
|
||||||
check_lun_is_wiped(uint64_t lba, unsigned char c)
|
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");
|
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");
|
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");
|
logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of one full block");
|
||||||
data.size = block_size + 4;
|
data.size = block_size + 4;
|
||||||
|
|||||||
@@ -26,18 +26,6 @@
|
|||||||
#include "iscsi-support.h"
|
#include "iscsi-support.h"
|
||||||
#include "iscsi-test-cu.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
|
void
|
||||||
test_unmap_simple(void)
|
test_unmap_simple(void)
|
||||||
{
|
{
|
||||||
@@ -56,7 +44,10 @@ test_unmap_simple(void)
|
|||||||
"LUN as a single descriptor");
|
"LUN as a single descriptor");
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
|
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++) {
|
for (i = 1; i <= 256; i++) {
|
||||||
logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i);
|
logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i);
|
||||||
@@ -91,7 +82,10 @@ test_unmap_simple(void)
|
|||||||
"LUN with one descriptor per block");
|
"LUN with one descriptor per block");
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
|
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);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user