Small work on metadata_checker tests.
This commit is contained in:
parent
b1e0ca2207
commit
441cba7185
@ -11,7 +11,7 @@ namespace {
|
|||||||
unsigned const SECTOR_TO_BLOCK_SHIFT = 3;
|
unsigned const SECTOR_TO_BLOCK_SHIFT = 3;
|
||||||
uint32_t const SUPERBLOCK_CSUM_SEED = 160774;
|
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 {
|
virtual void check(buffer<> const &b, block_address location) const {
|
||||||
superblock_disk const *sbd = reinterpret_cast<superblock_disk const *>(&b);
|
superblock_disk const *sbd = reinterpret_cast<superblock_disk const *>(&b);
|
||||||
crc32c sum(SUPERBLOCK_CSUM_SEED);
|
crc32c sum(SUPERBLOCK_CSUM_SEED);
|
||||||
@ -34,7 +34,7 @@ namespace {
|
|||||||
block_manager<>::validator::ptr
|
block_manager<>::validator::ptr
|
||||||
thin_provisioning::superblock_validator()
|
thin_provisioning::superblock_validator()
|
||||||
{
|
{
|
||||||
return block_manager<>::validator::ptr(new validator);
|
return block_manager<>::validator::ptr(new sb_validator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
@ -40,6 +40,7 @@ lib/libgmock.a: $(GMOCK_DEPS)
|
|||||||
|
|
||||||
TEST_SOURCE=\
|
TEST_SOURCE=\
|
||||||
unit-tests/gmock_main.cc \
|
unit-tests/gmock_main.cc \
|
||||||
|
unit-tests/test_utils.cc \
|
||||||
\
|
\
|
||||||
unit-tests/array_block_t.cc \
|
unit-tests/array_block_t.cc \
|
||||||
unit-tests/array_t.cc \
|
unit-tests/array_t.cc \
|
||||||
|
@ -120,8 +120,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void corrupt_superblock() {
|
void corrupt_superblock() {
|
||||||
block_manager<>::write_ref wr = bm_->write_lock(0);
|
zero_block(bm_, SUPERBLOCK_LOCATION);
|
||||||
wr.data()[57] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
with_temp_directory dir_;
|
with_temp_directory dir_;
|
||||||
|
11
unit-tests/test_utils.cc
Normal file
11
unit-tests/test_utils.cc
Normal file
@ -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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
@ -35,6 +35,8 @@ namespace test {
|
|||||||
new block_manager<BlockSize>(path, nr, MAX_HELD_LOCKS,
|
new block_manager<BlockSize>(path, nr, MAX_HELD_LOCKS,
|
||||||
block_io<BlockSize>::CREATE));
|
block_io<BlockSize>::CREATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void zero_block(block_manager<>::ptr bm, block_address b);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user