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_compareandwrite_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 = alloca(2 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test COMPAREANDWRITE DPO/FUA flags");
@@ -54,13 +53,13 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Read the first block");
ret = read10(sd, NULL, 0, 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);
if (ret == 0)
memcpy(buf + block_size, buf, block_size);
memcpy(scratch + block_size, scratch, block_size);
else
memset(buf, 0xa6, 2 * block_size);
memset(scratch, 0xa6, 2 * block_size);
if (dpofua) {
logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
@@ -72,11 +71,11 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1");
if (dpofua) {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 0, 0,
EXPECT_STATUS_GOOD);
} else {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
}
@@ -89,12 +88,12 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Test COMPAREANDWRITE with FUA==1");
if (dpofua) {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 0, 1, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);
@@ -102,12 +101,12 @@ test_compareandwrite_dpofua(void)
logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1 FUA==1");
if (dpofua) {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} else {
ret = compareandwrite(sd, 0, buf, 2 * block_size,
ret = compareandwrite(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 1, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0);