diff --git a/thin-provisioning/superblock_validator.cc b/thin-provisioning/superblock_validator.cc index 3369054..2d59d65 100644 --- a/thin-provisioning/superblock_validator.cc +++ b/thin-provisioning/superblock_validator.cc @@ -11,7 +11,7 @@ namespace { unsigned const SECTOR_TO_BLOCK_SHIFT = 3; uint32_t const SUPERBLOCK_CSUM_SEED = 160774; - struct validator : public block_manager<>::validator { + struct sb_validator : public block_manager<>::validator { virtual void check(buffer<> const &b, block_address location) const { superblock_disk const *sbd = reinterpret_cast(&b); crc32c sum(SUPERBLOCK_CSUM_SEED); @@ -34,7 +34,7 @@ namespace { block_manager<>::validator::ptr thin_provisioning::superblock_validator() { - return block_manager<>::validator::ptr(new validator); + return block_manager<>::validator::ptr(new sb_validator); } //---------------------------------------------------------------- diff --git a/unit-tests/Makefile.in b/unit-tests/Makefile.in index 0e8bfa7..101efc8 100644 --- a/unit-tests/Makefile.in +++ b/unit-tests/Makefile.in @@ -40,6 +40,7 @@ lib/libgmock.a: $(GMOCK_DEPS) TEST_SOURCE=\ unit-tests/gmock_main.cc \ + unit-tests/test_utils.cc \ \ unit-tests/array_block_t.cc \ unit-tests/array_t.cc \ diff --git a/unit-tests/metadata_checker_t.cc b/unit-tests/metadata_checker_t.cc index 36e5c2c..d2a169c 100644 --- a/unit-tests/metadata_checker_t.cc +++ b/unit-tests/metadata_checker_t.cc @@ -120,8 +120,7 @@ namespace { } void corrupt_superblock() { - block_manager<>::write_ref wr = bm_->write_lock(0); - wr.data()[57] = 0; + zero_block(bm_, SUPERBLOCK_LOCATION); } with_temp_directory dir_; diff --git a/unit-tests/test_utils.cc b/unit-tests/test_utils.cc new file mode 100644 index 0000000..9e82df1 --- /dev/null +++ b/unit-tests/test_utils.cc @@ -0,0 +1,11 @@ +#include "test_utils.h" + +//---------------------------------------------------------------- + +void test::zero_block(block_manager<>::ptr bm, block_address b) +{ + block_manager<>::write_ref wr = bm->write_lock(b); + memset(&wr.data(), 0, sizeof(wr.data())); +} + +//---------------------------------------------------------------- diff --git a/unit-tests/test_utils.h b/unit-tests/test_utils.h index 8d68b65..a773e09 100644 --- a/unit-tests/test_utils.h +++ b/unit-tests/test_utils.h @@ -35,6 +35,8 @@ namespace test { new block_manager(path, nr, MAX_HELD_LOCKS, block_io::CREATE)); } + + void zero_block(block_manager<>::ptr bm, block_address b); } //----------------------------------------------------------------