Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
grow_shrink.cpp
Go to the documentation of this file.
1#include <boost/test/unit_test.hpp>
2#include <boost/test/data/test_case.hpp>
3#include <boost/test/data/monomorphic.hpp>
5
6using namespace chainbase;
7
8const pinnable_mapped_file::map_mode test_modes[] = {pinnable_mapped_file::map_mode::mapped, pinnable_mapped_file::map_mode::heap};
9
10BOOST_DATA_TEST_CASE(grow_shrink, boost::unit_test::data::make(test_modes), map_mode) {
11 boost::filesystem::path temp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
12 try {
13 const size_t db_start_size = 8u*1024u*1024u;
14 const size_t db_grow_size = 16u*1024u*1024u;
15 const size_t db_shrunk_size = 2u*1024u*1024u;
16
17 {
18 chainbase::database db(temp, database::read_write, db_start_size, false, map_mode);
19 }
20 {
21 chainbase::database db(temp, database::read_write, db_grow_size, false, map_mode);
22 BOOST_CHECK(db.get_free_memory() > db_start_size);
23 }
24 {
25 chainbase::database db(temp, database::read_write, db_shrunk_size, false, map_mode);
26 BOOST_CHECK(db.get_free_memory() > db_start_size);
27 }
28
29 } catch(...) {
30 bfs::remove_all(temp);
31 throw;
32 }
33 bfs::remove_all(temp);
34}
size_t get_free_memory() const
BOOST_DATA_TEST_CASE(grow_shrink, boost::unit_test::data::make(test_modes), map_mode)
const pinnable_mapped_file::map_mode test_modes[]