Tests: Add a helper for the all_zero checker
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -127,7 +127,7 @@ static const unsigned char zeroBlock[4096];
|
||||
/**
|
||||
* Returns 1 if and only if buf[0..size-1] is zero.
|
||||
*/
|
||||
int all_zeroes(const unsigned char *buf, unsigned size)
|
||||
int all_zero(const unsigned char *buf, unsigned size)
|
||||
{
|
||||
unsigned j, e;
|
||||
|
||||
|
||||
@@ -686,6 +686,17 @@ do { \
|
||||
CU_ASSERT_EQUAL(_r, 0); \
|
||||
} while (0);
|
||||
|
||||
#define ALL_ZERO(...) \
|
||||
do { \
|
||||
if (all_zero(__VA_ARGS__) == 0) { \
|
||||
logging(LOG_NORMAL, "[FAILED] Blocks did not " \
|
||||
"read back as zero"); \
|
||||
CU_FAIL("[FAILED] Blocks did not read back " \
|
||||
"as zero"); \
|
||||
return; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
extern struct scsi_inquiry_standard *inq;
|
||||
extern struct scsi_inquiry_logical_block_provisioning *inq_lbp;
|
||||
extern struct scsi_inquiry_block_device_characteristics *inq_bdc;
|
||||
@@ -763,7 +774,7 @@ static inline int pr_type_is_all_registrants(
|
||||
}
|
||||
}
|
||||
|
||||
int all_zeroes(const unsigned char *buf, unsigned size);
|
||||
int all_zero(const unsigned char *buf, unsigned size);
|
||||
|
||||
int prin_task(struct scsi_device *sdev, int service_action,
|
||||
int success_expected);
|
||||
|
||||
@@ -207,7 +207,7 @@ check_lun_is_wiped(unsigned char *buf, uint64_t lba)
|
||||
if (rc16->lbprz) {
|
||||
logging(LOG_VERBOSE, "LBPRZ==1 All blocks "
|
||||
"should read back as 0");
|
||||
if (all_zeroes(rbuf, 256 * block_size) == 0) {
|
||||
if (all_zero(rbuf, 256 * block_size) == 0) {
|
||||
logging(LOG_NORMAL, "[FAILED] Blocks did not "
|
||||
"read back as zero");
|
||||
CU_FAIL("[FAILED] Blocks did not read back "
|
||||
|
||||
@@ -64,15 +64,7 @@ test_unmap_simple(void)
|
||||
if (rc16 && rc16->lbprz) {
|
||||
logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
|
||||
"should read back as 0");
|
||||
if (all_zeroes(scratch, i * block_size) == 0) {
|
||||
logging(LOG_NORMAL, "[FAILED] Blocks did not "
|
||||
"read back as zero");
|
||||
CU_FAIL("[FAILED] Blocks did not read back "
|
||||
"as zero");
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
|
||||
"back as zero");
|
||||
}
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,15 +92,7 @@ test_unmap_simple(void)
|
||||
if (rc16 && rc16->lbprz) {
|
||||
logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
|
||||
"should read back as 0");
|
||||
if (all_zeroes(scratch, i * block_size) == 0) {
|
||||
logging(LOG_NORMAL, "[FAILED] Blocks did not "
|
||||
"read back as zero");
|
||||
CU_FAIL("[FAILED] Blocks did not read back "
|
||||
"as zero");
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
|
||||
"back as zero");
|
||||
}
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ test_writesame10_unmap(void)
|
||||
READ10(sd, NULL, 0, i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
@@ -95,7 +95,7 @@ test_writesame10_unmap(void)
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
@@ -155,7 +155,7 @@ test_writesame10_unmap(void)
|
||||
READ10(sd, NULL, 0, i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
|
||||
@@ -66,7 +66,7 @@ test_writesame10_unmap_until_end(void)
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
|
||||
@@ -58,7 +58,7 @@ test_writesame16_unmap(void)
|
||||
READ16(sd, NULL, 0, i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
@@ -89,7 +89,7 @@ test_writesame16_unmap(void)
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
@@ -147,7 +147,7 @@ test_writesame16_unmap(void)
|
||||
READ16(sd, NULL, 0, i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
@@ -191,7 +191,7 @@ test_writesame16_unmap(void)
|
||||
READ16(sd, NULL, 0, i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
|
||||
@@ -69,7 +69,7 @@ test_writesame16_unmap_until_end(void)
|
||||
i * block_size, block_size,
|
||||
0, 0, 0, 0, 0, scratch,
|
||||
EXPECT_STATUS_GOOD);
|
||||
CU_ASSERT(all_zeroes(scratch, i * block_size));
|
||||
ALL_ZERO(scratch, i * block_size);
|
||||
} else {
|
||||
logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
|
||||
"and verify zero test");
|
||||
|
||||
Reference in New Issue
Block a user