diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index bb67d50..a686266 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -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; diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 88326b4..c037800 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -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); diff --git a/test-tool/test_sanitize_block_erase.c b/test-tool/test_sanitize_block_erase.c index 6017ae0..082b067 100644 --- a/test-tool/test_sanitize_block_erase.c +++ b/test-tool/test_sanitize_block_erase.c @@ -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 " diff --git a/test-tool/test_unmap_simple.c b/test-tool/test_unmap_simple.c index b751f95..3572afc 100644 --- a/test-tool/test_unmap_simple.c +++ b/test-tool/test_unmap_simple.c @@ -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); } } } diff --git a/test-tool/test_writesame10_unmap.c b/test-tool/test_writesame10_unmap.c index 349beb0..4da6a95 100644 --- a/test-tool/test_writesame10_unmap.c +++ b/test-tool/test_writesame10_unmap.c @@ -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"); diff --git a/test-tool/test_writesame10_unmap_until_end.c b/test-tool/test_writesame10_unmap_until_end.c index 3b6c47f..1a12a2d 100644 --- a/test-tool/test_writesame10_unmap_until_end.c +++ b/test-tool/test_writesame10_unmap_until_end.c @@ -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"); diff --git a/test-tool/test_writesame16_unmap.c b/test-tool/test_writesame16_unmap.c index e5ccb55..dc06892 100644 --- a/test-tool/test_writesame16_unmap.c +++ b/test-tool/test_writesame16_unmap.c @@ -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"); diff --git a/test-tool/test_writesame16_unmap_until_end.c b/test-tool/test_writesame16_unmap_until_end.c index 62a4205..079a8ee 100644 --- a/test-tool/test_writesame16_unmap_until_end.c +++ b/test-tool/test_writesame16_unmap_until_end.c @@ -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");