Test space_map_transactional
This commit is contained in:
parent
4ea3476c97
commit
3d9f91eee2
@ -24,8 +24,10 @@
|
|||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
namespace persistent_data {
|
namespace persistent_data {
|
||||||
class core_map : public space_map {
|
class core_map : public checked_space_map {
|
||||||
public:
|
public:
|
||||||
|
typedef boost::shared_ptr<core_map> ptr;
|
||||||
|
|
||||||
core_map(block_address nr_blocks)
|
core_map(block_address nr_blocks)
|
||||||
: counts_(nr_blocks, 0),
|
: counts_(nr_blocks, 0),
|
||||||
nr_free_(nr_blocks) {
|
nr_free_(nr_blocks) {
|
||||||
@ -93,6 +95,20 @@ namespace persistent_data {
|
|||||||
throw std::runtime_error("not implemented");
|
throw std::runtime_error("not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: meaningless, but this class is only used for testing
|
||||||
|
size_t root_size() const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: meaningless, but this class is only used for testing
|
||||||
|
virtual void copy_root(void *dest, size_t len) const {
|
||||||
|
throw std::runtime_error("not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
checked_space_map::ptr clone() const {
|
||||||
|
return ptr(new core_map(*this));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ref_t> counts_;
|
std::vector<ref_t> counts_;
|
||||||
unsigned nr_free_;
|
unsigned nr_free_;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "persistent-data/space_map_disk.h"
|
#include "persistent-data/space_map_disk.h"
|
||||||
#include "persistent-data/space_map_core.h"
|
#include "persistent-data/space_map_core.h"
|
||||||
|
#include "persistent-data/space_map_transactional.h"
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE SpaceMapDiskTests
|
#define BOOST_TEST_MODULE SpaceMapDiskTests
|
||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
@ -37,7 +38,7 @@ namespace {
|
|||||||
create_tm() {
|
create_tm() {
|
||||||
block_manager<>::ptr bm(
|
block_manager<>::ptr bm(
|
||||||
new block_manager<>("./test.data", NR_BLOCKS, MAX_LOCKS, true));
|
new block_manager<>("./test.data", NR_BLOCKS, MAX_LOCKS, true));
|
||||||
space_map::ptr sm(new core_map(1024));
|
space_map::ptr sm(new core_map(NR_BLOCKS));
|
||||||
transaction_manager::ptr tm(
|
transaction_manager::ptr tm(
|
||||||
new transaction_manager(bm, sm));
|
new transaction_manager(bm, sm));
|
||||||
return tm;
|
return tm;
|
||||||
@ -51,6 +52,16 @@ namespace {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class sm_transactional_creator {
|
||||||
|
public:
|
||||||
|
static space_map::ptr
|
||||||
|
create() {
|
||||||
|
return create_transactional_sm(
|
||||||
|
checked_space_map::ptr(
|
||||||
|
new core_map(NR_BLOCKS)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class sm_disk_creator {
|
class sm_disk_creator {
|
||||||
public:
|
public:
|
||||||
static persistent_space_map::ptr
|
static persistent_space_map::ptr
|
||||||
@ -248,6 +259,11 @@ BOOST_AUTO_TEST_CASE(test_sm_core)
|
|||||||
do_tests<sm_core_creator>(space_map_tests);
|
do_tests<sm_core_creator>(space_map_tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(test_sm_transactional)
|
||||||
|
{
|
||||||
|
do_tests<sm_transactional_creator>(space_map_tests);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_sm_disk)
|
BOOST_AUTO_TEST_CASE(test_sm_disk)
|
||||||
{
|
{
|
||||||
do_tests<sm_disk_creator>(space_map_tests);
|
do_tests<sm_disk_creator>(space_map_tests);
|
||||||
|
Loading…
Reference in New Issue
Block a user