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:
Bart Van Assche
2017-10-30 16:57:57 -07:00
parent fee9eb9423
commit 8f468b14fc
4 changed files with 38 additions and 20 deletions

View File

@@ -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];