test-tool/test_compareandwrite_*: Stop at end of medium
Since the argument num_blocks - i is passed as the LBA argument to COMPAREANDWRITE(), avoid that a negative number is passed. Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
void
|
||||
test_compareandwrite_miscompare(void)
|
||||
{
|
||||
int i;
|
||||
int i, n;
|
||||
unsigned j;
|
||||
int maxbl;
|
||||
|
||||
@@ -44,10 +44,16 @@ test_compareandwrite_miscompare(void)
|
||||
/* Assume we are not limited */
|
||||
maxbl = 256;
|
||||
}
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"start of the LUN. One Byte miscompare in the final block.");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"start of the LUN. One Byte miscompare in the final block.",
|
||||
n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
@@ -98,9 +104,9 @@ test_compareandwrite_miscompare(void)
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"end of the LUN");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"end of the LUN", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
|
||||
i, num_blocks - i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
void
|
||||
test_compareandwrite_simple(void)
|
||||
{
|
||||
int i;
|
||||
int i, n;
|
||||
unsigned j;
|
||||
int maxbl;
|
||||
|
||||
@@ -45,10 +45,14 @@ test_compareandwrite_simple(void)
|
||||
maxbl = 256;
|
||||
}
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"start of the LUN");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"start of the LUN", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
if (maximum_transfer_length && maximum_transfer_length < i) {
|
||||
@@ -97,9 +101,9 @@ test_compareandwrite_simple(void)
|
||||
}
|
||||
|
||||
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"end of the LUN");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"end of the LUN", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
|
||||
i, num_blocks - i);
|
||||
memset(scratch, 'A', 2 * i * block_size);
|
||||
|
||||
@@ -32,15 +32,19 @@
|
||||
void
|
||||
test_compareandwrite_unwritten(void)
|
||||
{
|
||||
int i;
|
||||
int i, n;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"start of the LUN, 1 block at a time");
|
||||
for (i = 1; i < 256; i++) {
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-%d blocks at the "
|
||||
"start of the LUN, 1 block at a time", n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
int caw_ret;
|
||||
unsigned char read_buf[block_size];
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ test_multipathio_compareandwrite(void)
|
||||
{
|
||||
int io_bl = 1; /* 1 block CAW IOs */
|
||||
int path;
|
||||
int i, ret;
|
||||
int i, n, ret;
|
||||
int maxbl;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
@@ -52,6 +52,10 @@ test_multipathio_compareandwrite(void)
|
||||
return;
|
||||
}
|
||||
|
||||
n = 256;
|
||||
if (n + 0U > num_blocks)
|
||||
n = num_blocks;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Initialising data prior to COMPARE_AND_WRITE");
|
||||
|
||||
@@ -66,7 +70,7 @@ test_multipathio_compareandwrite(void)
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
logging(LOG_VERBOSE, "Test multipath COMPARE_AND_WRITE");
|
||||
for (i = 0; i < 256; i++) {
|
||||
for (i = 0; i <= n; i++) {
|
||||
|
||||
for (path = 0; path < mp_num_sds; path++) {
|
||||
logging(LOG_VERBOSE,
|
||||
|
||||
Reference in New Issue
Block a user