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:
@@ -30,17 +30,16 @@ void
|
||||
test_writesame16_beyond_eol(void)
|
||||
{
|
||||
int i, ret;
|
||||
unsigned char *buf = alloca(block_size);
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks one block beyond the end");
|
||||
memset(buf, 0, block_size);
|
||||
memset(scratch, 0, block_size);
|
||||
for (i = 1; i <= 256; i++) {
|
||||
ret = writesame16(sd, num_blocks - i + 1,
|
||||
block_size, i, 0, 0, 0, 0, buf,
|
||||
block_size, i, 0, 0, 0, 0, scratch,
|
||||
EXPECT_LBA_OOB);
|
||||
if (ret == -2) {
|
||||
logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
|
||||
@@ -54,7 +53,7 @@ test_writesame16_beyond_eol(void)
|
||||
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==2^63");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
ret = writesame16(sd, 0x8000000000000000ULL,
|
||||
block_size, i, 0, 0, 0, 0, buf,
|
||||
block_size, i, 0, 0, 0, 0, scratch,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
@@ -63,7 +62,7 @@ test_writesame16_beyond_eol(void)
|
||||
logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==-1");
|
||||
for (i = 1; i <= 256; i++) {
|
||||
ret = writesame16(sd, -1,
|
||||
block_size, i, 0, 0, 0, 0, buf,
|
||||
block_size, i, 0, 0, 0, 0, scratch,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
@@ -72,7 +71,7 @@ test_writesame16_beyond_eol(void)
|
||||
logging(LOG_VERBOSE, "Test WRITESAME16 2-256 blocks all but one block beyond the end");
|
||||
for (i = 2; i <= 256; i++) {
|
||||
ret = writesame16(sd, num_blocks - 1,
|
||||
block_size, i, 0, 0, 0, 0, buf,
|
||||
block_size, i, 0, 0, 0, 0, scratch,
|
||||
EXPECT_LBA_OOB);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user