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

@@ -31,7 +31,6 @@ void
test_writeatomic16_wrprotect(void)
{
int i, gran, ret;
unsigned char *buf = alloca(block_size);
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -44,10 +43,10 @@ test_writeatomic16_wrprotect(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE);
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
memset(buf, 0, block_size);
memset(scratch, 0, block_size);
ret = writeatomic16(sd, 0,
block_size * gran,
block_size, 0, 0, 0, 0, buf,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -59,13 +58,13 @@ test_writeatomic16_wrprotect(void)
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with non-zero WRPROTECT");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = writeatomic16(sd, 0,
gran * block_size, block_size,
i, 0, 0, 0, buf,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");