diff --git a/tests/unit_tests/lmdb_tests.cpp b/tests/unit_tests/lmdb_tests.cpp index 5d89ea4a..10dc1229 100644 --- a/tests/unit_tests/lmdb_tests.cpp +++ b/tests/unit_tests/lmdb_tests.cpp @@ -17,14 +17,20 @@ namespace lmdb_test bool r = false; epee::shared_recursive_mutex rw_lock; + epee::log_space::log_singletone::enable_channels("lmdb"); + static const uint64_t buffer_size = 64 * 1024; // 64 KB - static const uint64_t db_total_size = static_cast(2.1 * 1024 * 1024 * 1024); // 2.1 GB + static const uint64_t db_total_size = static_cast(2.1 * 1024 * 1024 * 1024); // 2.1 GB -- a bit more than 2GB to test 2GB boundary + static const std::string db_file_path = "2gb_lmdb_test"; std::shared_ptr lmdb_ptr = std::make_shared(); db::basic_db_accessor bdba(lmdb_ptr, rw_lock); + // + // write data + // - r = bdba.open("2gb_lmdb_test", CACHE_SIZE); + r = bdba.open(db_file_path, CACHE_SIZE); ASSERT_TRUE(r); db::container_handle h; @@ -46,7 +52,12 @@ namespace lmdb_test total_data += buffer_size; if (key % 1024 == 0) + { + ASSERT_TRUE(lmdb_ptr->commit_transaction()); + ASSERT_TRUE(lmdb_ptr->resize_if_needed()); + ASSERT_TRUE(lmdb_ptr->begin_transaction()); std::cout << total_data / 1024 / 1024 << " MB written to DB" << ENDL; + } } ASSERT_TRUE(lmdb_ptr->commit_transaction()); @@ -55,9 +66,11 @@ namespace lmdb_test ASSERT_TRUE(r); + // + // read data and check + // - - r = bdba.open("2gb_lmdb_test"); + r = bdba.open(db_file_path); ASSERT_TRUE(r); r = lmdb_ptr->open_container("c1", h); ASSERT_TRUE(r); @@ -84,6 +97,8 @@ namespace lmdb_test r = bdba.close(); ASSERT_TRUE(r); + boost::filesystem::remove_all(db_file_path); + } } diff --git a/tests/unit_tests/main.cpp b/tests/unit_tests/main.cpp index c6780fa8..9b62eef2 100644 --- a/tests/unit_tests/main.cpp +++ b/tests/unit_tests/main.cpp @@ -16,5 +16,6 @@ int main(int argc, char** argv) ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + int ret = RUN_ALL_TESTS(); + return ret; }