Start device_checker

This commit is contained in:
Joe Thornber 2013-04-29 13:24:19 +01:00
parent c0b14ce280
commit 1a8b1b29e8
6 changed files with 72 additions and 8 deletions

View File

@ -48,6 +48,7 @@ SOURCE=\
\
cache/metadata_disk_structures.cc \
\
thin-provisioning/device_checker.cc \
thin-provisioning/file_utils.cc \
thin-provisioning/human_readable_format.cc \
thin-provisioning/metadata.cc \
@ -55,10 +56,11 @@ SOURCE=\
thin-provisioning/metadata_disk_structures.cc \
thin-provisioning/metadata_dumper.cc \
thin-provisioning/restore_emitter.cc \
thin-provisioning/superblock_validator.cc \
thin-provisioning/superblock_checker.cc \
thin-provisioning/superblock_validator.cc \
thin-provisioning/thin_pool.cc \
thin-provisioning/xml_format.cc
PDATA_OBJECTS=$(subst .cc,.o,$(SOURCE))
PROGRAM_SOURCE=\

View File

@ -0,0 +1,19 @@
#include "thin-provisioning/device_checker.h"
using namespace thin_provisioning;
//----------------------------------------------------------------
device_checker::device_checker(block_manager::ptr bm)
: bm_(bm)
{
}
damage_list_ptr
device_checker::check()
{
// FIXME: finish.
return damage_list_ptr(new damage_list);
}
//----------------------------------------------------------------

View File

@ -0,0 +1,22 @@
#ifndef THIN_DEVICE_CHECKER_H
#define THIN_DEVICE_CHECKER_H
#include "thin-provisioning/metadata_checker.h"
//----------------------------------------------------------------
namespace thin_provisioning {
class device_checker : public checker {
public:
device_checker(block_manager::ptr bm);
damage_list_ptr check();
private:
block_manager::ptr bm_;
damage_list_ptr damage_;
};
}
//----------------------------------------------------------------
#endif

View File

@ -153,6 +153,7 @@ namespace thin_provisioning {
class checker {
public:
typedef persistent_data::block_manager<> block_manager;
typedef boost::shared_ptr<checker> ptr;
virtual ~checker() {};

View File

@ -8,12 +8,11 @@
namespace thin_provisioning {
class superblock_checker : public checker {
public:
typedef persistent_data::block_manager<> block_manager;
superblock_checker(block_manager::ptr bm);
boost::shared_ptr<damage_list> check();
damage_list_ptr check();
private:
// FIXME: surely we can push these down to the base class?
block_manager::ptr bm_;
damage_list_ptr damage;
};

View File

@ -3,6 +3,7 @@
#include "test_utils.h"
#include "persistent-data/block.h"
#include "thin-provisioning/device_checker.h"
#include "thin-provisioning/restore_emitter.h"
#include "thin-provisioning/superblock_checker.h"
@ -110,21 +111,34 @@ namespace {
block_manager<>::ptr bm_;
};
class SuperBlockCheckerTests : public Test {
//--------------------------------
class MetadataCheckerTests : public Test {
public:
SuperBlockCheckerTests()
MetadataCheckerTests()
: bm_(create_bm<BLOCK_SIZE>()) {
metadata_builder builder(bm_);
builder.build();
}
with_temp_directory dir_;
block_manager<>::ptr bm_;
};
class SuperBlockCheckerTests : public MetadataCheckerTests {
public:
void corrupt_superblock() {
zero_block(bm_, SUPERBLOCK_LOCATION);
}
};
with_temp_directory dir_;
block_manager<>::ptr bm_;
//--------------------------------
class DevicesCheckerTests : public MetadataCheckerTests {
public:
};
}
@ -155,3 +169,10 @@ TEST_F(SuperBlockCheckerTests, fails_with_bad_checksum)
}
//----------------------------------------------------------------
TEST_F(DevicesCheckerTests, create_require_a_block_manager)
{
device_checker dc(bm_);
}
//----------------------------------------------------------------