fixup tests following the stricter block checking
This commit is contained in:
parent
a683979585
commit
5c66593d11
@ -112,9 +112,10 @@ block_manager<BlockSize>::write_lock_zero(block_address location)
|
||||
|
||||
buffer buf;
|
||||
zero_buffer(buf);
|
||||
register_lock(location, WRITE_LOCK);
|
||||
typename block::ptr b(new block(location, buf, lock_count_, ordinary_count_),
|
||||
bind(&block_manager<BlockSize>::write_release, this, _1));
|
||||
register_lock(location, WRITE_LOCK);
|
||||
|
||||
return write_ref(b);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,6 @@ BOOST_AUTO_TEST_CASE(different_block_sizes)
|
||||
BOOST_CHECK_EQUAL(sizeof(rr.data()), 4096);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
block_manager<64 * 1024> bm("./test.data", 64);
|
||||
auto rr = bm.read_lock(0);
|
||||
|
@ -11,7 +11,7 @@ using namespace persistent_data;
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
block_address const NR_BLOCKS = 1023;
|
||||
block_address const NR_BLOCKS = 10237;
|
||||
block_address const SUPERBLOCK = 0;
|
||||
unsigned const BLOCK_SIZE = 4096;
|
||||
|
||||
@ -105,4 +105,18 @@ BOOST_AUTO_TEST_CASE(test_set_count)
|
||||
BOOST_CHECK_EQUAL(sm->get_count(43), 5);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_set_effects_nr_allocated)
|
||||
{
|
||||
auto sm = create_sm_disk();
|
||||
for (unsigned i = 0; i < NR_BLOCKS; i++) {
|
||||
sm->set_count(i, 1);
|
||||
BOOST_CHECK_EQUAL(sm->get_nr_free(), NR_BLOCKS - i - 1);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < NR_BLOCKS; i++) {
|
||||
sm->set_count(i, 0);
|
||||
BOOST_CHECK_EQUAL(sm->get_nr_free(), i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -18,6 +18,7 @@ namespace {
|
||||
block_manager<4096>::ptr bm(new block_manager<4096>("./test.data", NR_BLOCKS));
|
||||
space_map::ptr sm(new core_map(NR_BLOCKS));
|
||||
transaction_manager<4096>::ptr tm(new transaction_manager<4096>(bm, sm));
|
||||
tm->get_sm()->inc(0);
|
||||
return tm;
|
||||
}
|
||||
}
|
||||
@ -37,20 +38,29 @@ BOOST_AUTO_TEST_CASE(shadowing)
|
||||
|
||||
auto sm = tm->get_sm();
|
||||
sm->inc(1);
|
||||
block_address b;
|
||||
|
||||
{
|
||||
auto p = tm->shadow(1);
|
||||
auto b = p.first.get_location();
|
||||
b = p.first.get_location();
|
||||
BOOST_CHECK(b != 1);
|
||||
BOOST_CHECK(!p.second);
|
||||
BOOST_CHECK(sm->get_count(1) == 0);
|
||||
}
|
||||
|
||||
p = tm->shadow(b);
|
||||
{
|
||||
auto p = tm->shadow(b);
|
||||
BOOST_CHECK(p.first.get_location() == b);
|
||||
BOOST_CHECK(!p.second);
|
||||
}
|
||||
|
||||
sm->inc(b);
|
||||
p = tm->shadow(b);
|
||||
|
||||
{
|
||||
auto p = tm->shadow(b);
|
||||
BOOST_CHECK(p.first.get_location() != b);
|
||||
BOOST_CHECK(p.second);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multiple_shadowing)
|
||||
|
Loading…
Reference in New Issue
Block a user