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:
Ronnie Sahlberg
2016-02-21 07:56:47 -08:00
parent b4e4649ae5
commit f88bcf61cc
89 changed files with 454 additions and 545 deletions

View File

@@ -32,7 +32,6 @@ test_writesame16_unmap_until_end(void)
{
int ret;
unsigned int i;
unsigned char *buf = alloca(256 * block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING;
@@ -47,18 +46,18 @@ test_writesame16_unmap_until_end(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0");
memset(buf, 0xa6, 256 * block_size);
memset(scratch, 0xa6, 256 * block_size);
for (i = 1; i <= 256; i++) {
logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
memset(buf, 0xff, block_size * i);
memset(scratch, 0xff, block_size * i);
WRITE16(sd, 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);
logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writesame16(sd, num_blocks - i,
block_size, 0, 0, 1, 0, 0, buf,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
@@ -75,9 +74,9 @@ test_writesame16_unmap_until_end(void)
"are now zero", i);
ret = read16(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT(all_zeroes(buf, i * block_size));
CU_ASSERT(all_zeroes(scratch, i * block_size));
} else {
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
"and verify zero test");