rename range<> -> run<>
This commit is contained in:
parent
83d6b609eb
commit
e64dda95f6
@ -11,13 +11,13 @@ namespace persistent_data {
|
|||||||
struct damage {
|
struct damage {
|
||||||
typedef boost::shared_ptr<damage> ptr;
|
typedef boost::shared_ptr<damage> ptr;
|
||||||
|
|
||||||
damage(range<uint64_t> lost_keys,
|
damage(run<uint64_t> lost_keys,
|
||||||
std::string const &desc)
|
std::string const &desc)
|
||||||
: lost_keys_(lost_keys),
|
: lost_keys_(lost_keys),
|
||||||
desc_(desc) {
|
desc_(desc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
range<uint64_t> lost_keys_;
|
run<uint64_t> lost_keys_;
|
||||||
std::string desc_;
|
std::string desc_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,18 +36,18 @@ namespace persistent_data {
|
|||||||
damage_begin_(0) {
|
damage_begin_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef range<block_address> range64;
|
typedef run<block_address> run64;
|
||||||
typedef boost::optional<range64> maybe_range64;
|
typedef boost::optional<run64> maybe_run64;
|
||||||
|
|
||||||
void bad_node() {
|
void bad_node() {
|
||||||
damaged_ = true;
|
damaged_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
maybe_range64 good_internal(block_address begin) {
|
maybe_run64 good_internal(block_address begin) {
|
||||||
maybe_range64 r;
|
maybe_run64 r;
|
||||||
|
|
||||||
if (damaged_) {
|
if (damaged_) {
|
||||||
r = maybe_range64(range64(damage_begin_, begin));
|
r = maybe_run64(run64(damage_begin_, begin));
|
||||||
damaged_ = false;
|
damaged_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,11 +57,11 @@ namespace persistent_data {
|
|||||||
|
|
||||||
// remember 'end' is the one-past-the-end value, so
|
// remember 'end' is the one-past-the-end value, so
|
||||||
// take the last key in the leaf and add one.
|
// take the last key in the leaf and add one.
|
||||||
maybe_range64 good_leaf(block_address begin, block_address end) {
|
maybe_run64 good_leaf(block_address begin, block_address end) {
|
||||||
maybe_range64 r;
|
maybe_run64 r;
|
||||||
|
|
||||||
if (damaged_) {
|
if (damaged_) {
|
||||||
r = maybe_range64(range64(damage_begin_, begin));
|
r = maybe_run64(run64(damage_begin_, begin));
|
||||||
damaged_ = false;
|
damaged_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,11 +69,11 @@ namespace persistent_data {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
maybe_range64 end() {
|
maybe_run64 end() {
|
||||||
if (damaged_)
|
if (damaged_)
|
||||||
return maybe_range64(damage_begin_);
|
return maybe_run64(damage_begin_);
|
||||||
else
|
else
|
||||||
return maybe_range64();
|
return maybe_run64();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -133,8 +133,8 @@ namespace persistent_data {
|
|||||||
class btree_damage_visitor : public btree<Levels, ValueTraits>::visitor {
|
class btree_damage_visitor : public btree<Levels, ValueTraits>::visitor {
|
||||||
public:
|
public:
|
||||||
typedef btree_detail::node_location node_location;
|
typedef btree_detail::node_location node_location;
|
||||||
typedef range<block_address> range64;
|
typedef run<block_address> run64;
|
||||||
typedef boost::optional<range64> maybe_range64;
|
typedef boost::optional<run64> maybe_run64;
|
||||||
|
|
||||||
btree_damage_visitor(block_counter &counter,
|
btree_damage_visitor(block_counter &counter,
|
||||||
ValueVisitor &value_visitor,
|
ValueVisitor &value_visitor,
|
||||||
@ -389,13 +389,13 @@ namespace persistent_data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void good_internal(block_address b) {
|
void good_internal(block_address b) {
|
||||||
maybe_range64 mr = dt_.good_internal(b);
|
maybe_run64 mr = dt_.good_internal(b);
|
||||||
if (mr)
|
if (mr)
|
||||||
issue_damage(path_tracker_.current_path(), *mr);
|
issue_damage(path_tracker_.current_path(), *mr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void good_leaf(block_address b, block_address e) {
|
void good_leaf(block_address b, block_address e) {
|
||||||
maybe_range64 mr = dt_.good_leaf(b, e);
|
maybe_run64 mr = dt_.good_leaf(b, e);
|
||||||
|
|
||||||
if (mr)
|
if (mr)
|
||||||
issue_damage(path_tracker_.current_path(), *mr);
|
issue_damage(path_tracker_.current_path(), *mr);
|
||||||
@ -405,7 +405,7 @@ namespace persistent_data {
|
|||||||
maybe_issue_damage(path_tracker_.current_path());
|
maybe_issue_damage(path_tracker_.current_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
void issue_damage(btree_path const &path, range64 const &r) {
|
void issue_damage(btree_path const &path, run64 const &r) {
|
||||||
damage d(r, build_damage_desc());
|
damage d(r, build_damage_desc());
|
||||||
clear_damage_desc();
|
clear_damage_desc();
|
||||||
damage_visitor_.visit(path, d);
|
damage_visitor_.visit(path, d);
|
||||||
@ -426,7 +426,7 @@ namespace persistent_data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void maybe_issue_damage(btree_path const &path) {
|
void maybe_issue_damage(btree_path const &path) {
|
||||||
maybe_range64 mr = dt_.end();
|
maybe_run64 mr = dt_.end();
|
||||||
if (mr)
|
if (mr)
|
||||||
issue_damage(path, *mr);
|
issue_damage(path, *mr);
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,16 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class range {
|
class run {
|
||||||
public:
|
public:
|
||||||
typedef boost::optional<T> maybe;
|
typedef boost::optional<T> maybe;
|
||||||
|
|
||||||
explicit range(maybe begin = maybe(), maybe end = maybe())
|
explicit run(maybe begin = maybe(), maybe end = maybe())
|
||||||
: begin_(begin),
|
: begin_(begin),
|
||||||
end_(end) {
|
end_(end) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator ==(range<T> const &r) const {
|
bool operator ==(run<T> const &r) const {
|
||||||
return (begin_ == r.begin_ && end_ == r.end_);
|
return (begin_ == r.begin_ && end_ == r.end_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ namespace base {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::ostream &
|
std::ostream &
|
||||||
operator <<(std::ostream &out, range<T> const &r) {
|
operator <<(std::ostream &out, run<T> const &r) {
|
||||||
if (r.begin_)
|
if (r.begin_)
|
||||||
out << "[" << *r.begin_;
|
out << "[" << *r.begin_;
|
||||||
else
|
else
|
||||||
|
@ -53,7 +53,7 @@ namespace thin_provisioning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
missing_devices::missing_devices(std::string const &desc,
|
missing_devices::missing_devices(std::string const &desc,
|
||||||
range<uint64_t> const &keys)
|
run<uint64_t> const &keys)
|
||||||
: desc_(desc),
|
: desc_(desc),
|
||||||
keys_(keys) {
|
keys_(keys) {
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,11 @@ namespace thin_provisioning {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct missing_devices : public damage {
|
struct missing_devices : public damage {
|
||||||
missing_devices(std::string const &desc, range<uint64_t> const &keys);
|
missing_devices(std::string const &desc, run<uint64_t> const &keys);
|
||||||
virtual void visit(damage_visitor &v) const;
|
virtual void visit(damage_visitor &v) const;
|
||||||
|
|
||||||
std::string desc_;
|
std::string desc_;
|
||||||
range<uint64_t> keys_;
|
run<uint64_t> keys_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class damage_visitor {
|
class damage_visitor {
|
||||||
|
@ -95,7 +95,7 @@ namespace thin_provisioning {
|
|||||||
|
|
||||||
//--------------------------------
|
//--------------------------------
|
||||||
|
|
||||||
missing_devices::missing_devices(std::string const &desc, range<uint64_t> const &keys)
|
missing_devices::missing_devices(std::string const &desc, run<uint64_t> const &keys)
|
||||||
: desc_(desc),
|
: desc_(desc),
|
||||||
keys_(keys)
|
keys_(keys)
|
||||||
{
|
{
|
||||||
@ -110,7 +110,7 @@ namespace thin_provisioning {
|
|||||||
//--------------------------------
|
//--------------------------------
|
||||||
|
|
||||||
missing_mappings::missing_mappings(std::string const &desc, uint64_t thin_dev,
|
missing_mappings::missing_mappings(std::string const &desc, uint64_t thin_dev,
|
||||||
range<uint64_t> const &keys)
|
run<uint64_t> const &keys)
|
||||||
: desc_(desc),
|
: desc_(desc),
|
||||||
thin_dev_(thin_dev),
|
thin_dev_(thin_dev),
|
||||||
keys_(keys)
|
keys_(keys)
|
||||||
|
@ -73,21 +73,21 @@ namespace thin_provisioning {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct missing_devices : public damage {
|
struct missing_devices : public damage {
|
||||||
missing_devices(std::string const &desc, range<uint64_t> const &keys);
|
missing_devices(std::string const &desc, run<uint64_t> const &keys);
|
||||||
virtual void visit(damage_visitor &v) const;
|
virtual void visit(damage_visitor &v) const;
|
||||||
|
|
||||||
std::string desc_;
|
std::string desc_;
|
||||||
range<uint64_t> keys_;
|
run<uint64_t> keys_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct missing_mappings : public damage {
|
struct missing_mappings : public damage {
|
||||||
missing_mappings(std::string const &desc, uint64_t thin_dev,
|
missing_mappings(std::string const &desc, uint64_t thin_dev,
|
||||||
range<uint64_t> const &keys);
|
run<uint64_t> const &keys);
|
||||||
virtual void visit(damage_visitor &v) const;
|
virtual void visit(damage_visitor &v) const;
|
||||||
|
|
||||||
std::string desc_;
|
std::string desc_;
|
||||||
uint64_t thin_dev_;
|
uint64_t thin_dev_;
|
||||||
range<uint64_t> keys_;
|
run<uint64_t> keys_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class damage_visitor {
|
class damage_visitor {
|
||||||
|
@ -66,31 +66,31 @@ namespace thin_provisioning {
|
|||||||
bool operator ==(super_block_corruption const &rhs) const;
|
bool operator ==(super_block_corruption const &rhs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef base::range<uint64_t> range64;
|
typedef base::run<uint64_t> run64;
|
||||||
|
|
||||||
struct missing_device_details : public metadata_damage {
|
struct missing_device_details : public metadata_damage {
|
||||||
missing_device_details(range64 missing);
|
missing_device_details(run64 missing);
|
||||||
virtual void visit(metadata_damage_visitor &visitor) const;
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
||||||
bool operator ==(missing_device_details const &rhs) const;
|
bool operator ==(missing_device_details const &rhs) const;
|
||||||
|
|
||||||
range64 missing_;
|
run64 missing_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct missing_devices : public metadata_damage {
|
struct missing_devices : public metadata_damage {
|
||||||
missing_devices(range64 missing);
|
missing_devices(run64 missing);
|
||||||
virtual void visit(metadata_damage_visitor &visitor) const;
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
||||||
bool operator ==(missing_devices const &rhs) const;
|
bool operator ==(missing_devices const &rhs) const;
|
||||||
|
|
||||||
range64 missing_;
|
run64 missing_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct missing_mappings : public metadata_damage {
|
struct missing_mappings : public metadata_damage {
|
||||||
missing_mappings(uint64_t dev, range64 missing);
|
missing_mappings(uint64_t dev, run64 missing);
|
||||||
virtual void visit(metadata_damage_visitor &visitor) const;
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
||||||
bool operator ==(missing_mappings const &rhs) const;
|
bool operator ==(missing_mappings const &rhs) const;
|
||||||
|
|
||||||
uint64_t dev_;
|
uint64_t dev_;
|
||||||
range64 missing_;
|
run64 missing_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bad_metadata_ref_count : public metadata_damage {
|
struct bad_metadata_ref_count : public metadata_damage {
|
||||||
@ -120,19 +120,19 @@ namespace thin_provisioning {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct missing_metadata_ref_counts : public metadata_damage {
|
struct missing_metadata_ref_counts : public metadata_damage {
|
||||||
missing_metadata_ref_counts(range64 missing);
|
missing_metadata_ref_counts(run64 missing);
|
||||||
virtual void visit(metadata_damage_visitor &visitor) const;
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
||||||
bool operator ==(missing_metadata_ref_counts const &rhs) const;
|
bool operator ==(missing_metadata_ref_counts const &rhs) const;
|
||||||
|
|
||||||
range64 missing_;
|
run64 missing_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct missing_data_ref_counts : public metadata_damage {
|
struct missing_data_ref_counts : public metadata_damage {
|
||||||
missing_data_ref_counts(range64 missing);
|
missing_data_ref_counts(run64 missing);
|
||||||
virtual void visit(metadata_damage_visitor &visitor) const;
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
||||||
bool operator ==(missing_data_ref_counts const &rhs) const;
|
bool operator ==(missing_data_ref_counts const &rhs) const;
|
||||||
|
|
||||||
range64 missing_;
|
run64 missing_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class metadata_damage_visitor {
|
class metadata_damage_visitor {
|
||||||
|
@ -16,7 +16,7 @@ namespace thin_provisioning {
|
|||||||
// iv) get the rmaps with get_rmap();
|
// iv) get the rmaps with get_rmap();
|
||||||
class rmap_visitor {
|
class rmap_visitor {
|
||||||
public:
|
public:
|
||||||
typedef range<block_address> region;
|
typedef run<block_address> region;
|
||||||
|
|
||||||
rmap_visitor();
|
rmap_visitor();
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include "persistent-data/data-structures/btree_damage_visitor.h"
|
#include "persistent-data/data-structures/btree_damage_visitor.h"
|
||||||
#include "persistent-data/range.h"
|
#include "persistent-data/run.h"
|
||||||
#include "persistent-data/space-maps/core.h"
|
#include "persistent-data/space-maps/core.h"
|
||||||
#include "thin-provisioning/file_utils.h"
|
#include "thin-provisioning/file_utils.h"
|
||||||
#include "thin-provisioning/superblock.h"
|
#include "thin-provisioning/superblock.h"
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
#include "persistent-data/endian_utils.h"
|
#include "persistent-data/endian_utils.h"
|
||||||
#include "persistent-data/space-maps/core.h"
|
#include "persistent-data/space-maps/core.h"
|
||||||
#include "persistent-data/transaction_manager.h"
|
#include "persistent-data/transaction_manager.h"
|
||||||
|
#include "persistent-data/run.h"
|
||||||
|
|
||||||
|
using namespace base;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace persistent_data;
|
using namespace persistent_data;
|
||||||
using namespace test;
|
using namespace test;
|
||||||
@ -71,7 +73,7 @@ namespace {
|
|||||||
bool leaf;
|
bool leaf;
|
||||||
unsigned depth;
|
unsigned depth;
|
||||||
block_address b;
|
block_address b;
|
||||||
range<uint64_t> keys;
|
run<uint64_t> keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
ostream &operator <<(ostream &out, node_info const &ni) {
|
ostream &operator <<(ostream &out, node_info const &ni) {
|
||||||
@ -227,12 +229,12 @@ namespace {
|
|||||||
ni->b = n.get_location();
|
ni->b = n.get_location();
|
||||||
|
|
||||||
if (n.get_nr_entries())
|
if (n.get_nr_entries())
|
||||||
ni->keys = range<uint64_t>(n.key_at(0));
|
ni->keys = run<uint64_t>(n.key_at(0));
|
||||||
else {
|
else {
|
||||||
if (loc.key)
|
if (loc.key)
|
||||||
ni->keys = range<uint64_t>(*loc.key);
|
ni->keys = run<uint64_t>(*loc.key);
|
||||||
else
|
else
|
||||||
ni->keys = range<uint64_t>();
|
ni->keys = run<uint64_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_node_at_depth_.size() > loc.depth) {
|
if (last_node_at_depth_.size() > loc.depth) {
|
||||||
@ -349,7 +351,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void expect_value_range(uint64_t begin, uint64_t end) {
|
void expect_value_run(uint64_t begin, uint64_t end) {
|
||||||
while (begin < end) {
|
while (begin < end) {
|
||||||
btree_path path;
|
btree_path path;
|
||||||
path.push_back(begin);
|
path.push_back(begin);
|
||||||
@ -359,7 +361,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void expect_nr_values(unsigned nr) {
|
void expect_nr_values(unsigned nr) {
|
||||||
expect_value_range(0, nr);
|
expect_value_run(0, nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void expect_value(uint64_t n) {
|
void expect_value(uint64_t n) {
|
||||||
@ -368,7 +370,7 @@ namespace {
|
|||||||
EXPECT_CALL(value_visitor_, visit(Eq(path), Eq(thing(n, n + 1234)))).Times(1);
|
EXPECT_CALL(value_visitor_, visit(Eq(path), Eq(thing(n, n + 1234)))).Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void expect_damage(range<uint64_t> keys) {
|
void expect_damage(base::run<uint64_t> const &keys) {
|
||||||
EXPECT_CALL(damage_visitor_, visit(EmptyPath(), DamagedKeys(keys))).Times(1);
|
EXPECT_CALL(damage_visitor_, visit(EmptyPath(), DamagedKeys(keys))).Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,13 +428,13 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void expect_values_except(unsigned nr_sub_trees, unsigned nr_values,
|
void expect_values_except(unsigned nr_sub_trees, unsigned nr_values,
|
||||||
btree_path const &path, range<uint64_t> keys) {
|
btree_path const &path, base::run<uint64_t> keys) {
|
||||||
for (unsigned i = 0; i < nr_sub_trees; i++)
|
for (unsigned i = 0; i < nr_sub_trees; i++)
|
||||||
expect_sub_tree_values_except(i, nr_values, path, keys);
|
expect_sub_tree_values_except(i, nr_values, path, keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
void expect_sub_tree_values_except(unsigned sub_tree, unsigned nr_values,
|
void expect_sub_tree_values_except(unsigned sub_tree, unsigned nr_values,
|
||||||
btree_path const &path, range<uint64_t> keys) {
|
btree_path const &path, base::run<uint64_t> keys) {
|
||||||
for (unsigned i = 0; i < nr_values; i++) {
|
for (unsigned i = 0; i < nr_values; i++) {
|
||||||
uint64_t key[2] = {sub_tree, i};
|
uint64_t key[2] = {sub_tree, i};
|
||||||
|
|
||||||
@ -446,7 +448,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void expect_damage(btree_path path, range<uint64_t> keys) {
|
void expect_damage(btree_path path, base::run<uint64_t> keys) {
|
||||||
EXPECT_CALL(damage_visitor_, visit(Eq(path), DamagedKeys(keys))).Times(1);
|
EXPECT_CALL(damage_visitor_, visit(Eq(path), DamagedKeys(keys))).Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +487,7 @@ TEST_F(BTreeDamageVisitorTests, tree_with_a_trashed_root)
|
|||||||
trash_block(tree_->get_root());
|
trash_block(tree_->get_root());
|
||||||
|
|
||||||
expect_no_values();
|
expect_no_values();
|
||||||
expect_damage(range<uint64_t>(0ull));
|
expect_damage(base::run<uint64_t>(0ull));
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
@ -508,8 +510,8 @@ TEST_F(BTreeDamageVisitorTests, populated_tree_with_a_damaged_leaf_node)
|
|||||||
node_info n = layout_->random_node(is_leaf);
|
node_info n = layout_->random_node(is_leaf);
|
||||||
|
|
||||||
trash_block(n.b);
|
trash_block(n.b);
|
||||||
expect_value_range(0, *n.keys.begin_);
|
expect_value_run(0, *n.keys.begin_);
|
||||||
expect_value_range(*n.keys.end_, 10000);
|
expect_value_run(*n.keys.end_, 10000);
|
||||||
expect_damage(n.keys);
|
expect_damage(n.keys);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
@ -529,9 +531,9 @@ TEST_F(BTreeDamageVisitorTests, populated_tree_with_a_sequence_of_damaged_leaf_n
|
|||||||
block_address begin = *nodes[0].keys.begin_;
|
block_address begin = *nodes[0].keys.begin_;
|
||||||
block_address end = *nodes[COUNT - 1].keys.end_;
|
block_address end = *nodes[COUNT - 1].keys.end_;
|
||||||
|
|
||||||
expect_value_range(0, *nodes[0].keys.begin_);
|
expect_value_run(0, *nodes[0].keys.begin_);
|
||||||
expect_value_range(*nodes[COUNT - 1].keys.end_, 10000);
|
expect_value_run(*nodes[COUNT - 1].keys.end_, 10000);
|
||||||
expect_damage(range<block_address>(begin, end));
|
expect_damage(base::run<block_address>(begin, end));
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
@ -546,8 +548,8 @@ TEST_F(BTreeDamageVisitorTests, damaged_first_leaf)
|
|||||||
block_address end = *n.keys.end_;
|
block_address end = *n.keys.end_;
|
||||||
trash_block(n.b);
|
trash_block(n.b);
|
||||||
|
|
||||||
expect_damage(range<block_address>(0ull, end));
|
expect_damage(base::run<block_address>(0ull, end));
|
||||||
expect_value_range(end, 10000);
|
expect_value_run(end, 10000);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
@ -563,8 +565,8 @@ TEST_F(BTreeDamageVisitorTests, damaged_last_leaf)
|
|||||||
block_address begin = *n.keys.begin_;
|
block_address begin = *n.keys.begin_;
|
||||||
trash_block(n.b);
|
trash_block(n.b);
|
||||||
|
|
||||||
expect_value_range(0, begin);
|
expect_value_run(0, begin);
|
||||||
expect_damage(range<block_address>(begin));
|
expect_damage(base::run<block_address>(begin));
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
@ -581,11 +583,11 @@ TEST_F(BTreeDamageVisitorTests, damaged_internal)
|
|||||||
|
|
||||||
trash_block(n.b);
|
trash_block(n.b);
|
||||||
|
|
||||||
expect_value_range(0, *begin);
|
expect_value_run(0, *begin);
|
||||||
expect_damage(range<block_address>(begin, end));
|
expect_damage(base::run<block_address>(begin, end));
|
||||||
|
|
||||||
if (end)
|
if (end)
|
||||||
expect_value_range(*end, 10000);
|
expect_value_run(*end, 10000);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
@ -609,7 +611,7 @@ TEST_F(BTreeDamageVisitor2Tests, tree_with_a_trashed_root)
|
|||||||
expect_no_values();
|
expect_no_values();
|
||||||
|
|
||||||
btree_path path;
|
btree_path path;
|
||||||
expect_damage(path, range<uint64_t>(0ull));
|
expect_damage(path, base::run<uint64_t>(0ull));
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ using namespace testing;
|
|||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
typedef range<block_address> range64;
|
typedef run<block_address> run64;
|
||||||
typedef damage_tracker::maybe_range64 mr64;
|
typedef damage_tracker::maybe_run64 mr64;
|
||||||
|
|
||||||
class DamageTrackerTests : public Test {
|
class DamageTrackerTests : public Test {
|
||||||
public:
|
public:
|
||||||
@ -21,7 +21,7 @@ namespace {
|
|||||||
ASSERT_THAT(mr, Eq(mr64()));
|
ASSERT_THAT(mr, Eq(mr64()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void assert_damage(mr64 const &mr, range64 const &expected) const {
|
void assert_damage(mr64 const &mr, run64 const &expected) const {
|
||||||
ASSERT_THAT(mr, Eq(mr64(expected)));
|
ASSERT_THAT(mr, Eq(mr64(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,27 +40,27 @@ TEST_F(DamageTrackerTests, good_leaf)
|
|||||||
TEST_F(DamageTrackerTests, bad_node)
|
TEST_F(DamageTrackerTests, bad_node)
|
||||||
{
|
{
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.end(), range64(0ull));
|
assert_damage(dt.end(), run64(0ull));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DamageTrackerTests, good_bad)
|
TEST_F(DamageTrackerTests, good_bad)
|
||||||
{
|
{
|
||||||
dt.good_leaf(0, 10);
|
dt.good_leaf(0, 10);
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.end(), range64(10ull));
|
assert_damage(dt.end(), run64(10ull));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DamageTrackerTests, bad_good)
|
TEST_F(DamageTrackerTests, bad_good)
|
||||||
{
|
{
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.good_leaf(10, 20), range64(0ull, 10ull));
|
assert_damage(dt.good_leaf(10, 20), run64(0ull, 10ull));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DamageTrackerTests, good_bad_good)
|
TEST_F(DamageTrackerTests, good_bad_good)
|
||||||
{
|
{
|
||||||
dt.good_leaf(0, 10);
|
dt.good_leaf(0, 10);
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.good_leaf(20, 30), range64(10ull, 20ull));
|
assert_damage(dt.good_leaf(20, 30), run64(10ull, 20ull));
|
||||||
assert_no_damage(dt.end());
|
assert_no_damage(dt.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,14 +69,14 @@ TEST_F(DamageTrackerTests, bad_good_bad)
|
|||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
dt.good_leaf(10, 20);
|
dt.good_leaf(10, 20);
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.end(), range64(20ull));
|
assert_damage(dt.end(), run64(20ull));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DamageTrackerTests, gi_bl_gl)
|
TEST_F(DamageTrackerTests, gi_bl_gl)
|
||||||
{
|
{
|
||||||
dt.good_internal(0);
|
dt.good_internal(0);
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.good_leaf(10, 20), range64(0ull, 10ull));
|
assert_damage(dt.good_leaf(10, 20), run64(0ull, 10ull));
|
||||||
assert_no_damage(dt.end());
|
assert_no_damage(dt.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,16 +86,16 @@ TEST_F(DamageTrackerTests, gi_gl_bl_bi)
|
|||||||
dt.good_leaf(0, 10);
|
dt.good_leaf(0, 10);
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.end(), range64(10ull));
|
assert_damage(dt.end(), run64(10ull));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DamageTrackerTests, gi_bi_gi_bl_gl)
|
TEST_F(DamageTrackerTests, gi_bi_gi_bl_gl)
|
||||||
{
|
{
|
||||||
dt.good_internal(0);
|
dt.good_internal(0);
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.good_internal(10), range64(0ull, 10ull));
|
assert_damage(dt.good_internal(10), run64(0ull, 10ull));
|
||||||
dt.bad_node();
|
dt.bad_node();
|
||||||
assert_damage(dt.good_leaf(15, 20), range64(10ull, 15ull));
|
assert_damage(dt.good_leaf(15, 20), run64(10ull, 15ull));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user