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

@@ -34,7 +34,6 @@ test_writeatomic16_dpofua(void)
struct scsi_mode_sense *ms;
struct scsi_task *rso_task = NULL;
struct scsi_report_supported_op_codes_one_command *rsoc;
unsigned char *buf;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITEATOMIC16 DPO/FUA flags");
@@ -48,7 +47,6 @@ test_writeatomic16_dpofua(void)
}
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
buf = alloca(gran * block_size);
logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
@@ -69,10 +67,10 @@ test_writeatomic16_dpofua(void)
}
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1");
memset(buf, 0xa6, block_size);
memset(scratch, 0xa6, block_size);
if (dpofua) {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -82,7 +80,7 @@ test_writeatomic16_dpofua(void)
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 0, 0, buf,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
@@ -95,12 +93,12 @@ test_writeatomic16_dpofua(void)
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with FUA==1");
if (dpofua) {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 0, 1, 0, buf,
block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 0, 1, 0, buf,
block_size, 0, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}
@@ -108,12 +106,12 @@ test_writeatomic16_dpofua(void)
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1 FUA==1");
if (dpofua) {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 1, 0, buf,
block_size, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = writeatomic16(sd, 0, gran * block_size,
block_size, 0, 1, 1, 0, buf,
block_size, 0, 1, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
}