Tests: Create a global scratch buffer and avoid allocating memory in the tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -31,7 +31,6 @@ 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");
|
||||
@@ -42,15 +41,15 @@ test_verify10_mismatch(void)
|
||||
break;
|
||||
}
|
||||
ret = read10(sd, NULL, 0, i * block_size,
|
||||
block_size, 0, 0, 0, 0, 0, buf,
|
||||
block_size, 0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
/* flip a random byte in the data */
|
||||
buf[offset] ^= 'X';
|
||||
scratch[offset] ^= 'X';
|
||||
logging(LOG_VERBOSE, "Flip some bits in the data");
|
||||
|
||||
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, buf,
|
||||
VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
|
||||
EXPECT_MISCOMPARE);
|
||||
}
|
||||
|
||||
@@ -62,16 +61,16 @@ test_verify10_mismatch(void)
|
||||
break;
|
||||
}
|
||||
ret = read10(sd, NULL, num_blocks - i,
|
||||
i * block_size, block_size, 0, 0, 0, 0, 0, buf,
|
||||
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
/* flip a random byte in the data */
|
||||
buf[offset] ^= 'X';
|
||||
scratch[offset] ^= 'X';
|
||||
logging(LOG_VERBOSE, "Flip some bits in the data");
|
||||
|
||||
VERIFY10(sd, num_blocks - i,
|
||||
i * block_size, block_size, 0, 0, 1, buf,
|
||||
i * block_size, block_size, 0, 0, 1, scratch,
|
||||
EXPECT_MISCOMPARE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user