Skip to content

Commit

Permalink
fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzq50 committed Dec 22, 2023
1 parent 5a35f24 commit f984773
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/unit_test/storage/buffer/buffer_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,26 @@ import buffer_manager;
import data_file_worker;
import buffer_obj;
import infinity_exception;
import global_resource_usage;
import infinity_context;

class BufferHandleTest : public BaseTest {
void SetUp() override {
BaseTest::SetUp();
system("rm -rf /tmp/infinity/log /tmp/infinity/data /tmp/infinity/wal");
infinity::GlobalResourceUsage::Init();
std::shared_ptr<std::string> config_path = nullptr;
infinity::InfinityContext::instance().Init(config_path);
}

class BufferHandleTest : public BaseTest {};
void TearDown() override {
infinity::InfinityContext::instance().UnInit();
EXPECT_EQ(infinity::GlobalResourceUsage::GetObjectCount(), 0);
EXPECT_EQ(infinity::GlobalResourceUsage::GetRawMemoryCount(), 0);
infinity::GlobalResourceUsage::UnInit();
BaseTest::TearDown();
}
};

TEST_F(BufferHandleTest, test1) {
using namespace infinity;
Expand Down
18 changes: 17 additions & 1 deletion src/unit_test/storage/buffer/buffer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,25 @@ import buffer_manager;
import buffer_handle;
import buffer_obj;
import data_file_worker;
import global_resource_usage;
import infinity_context;

class BufferObjTest : public BaseTest {
void SetUp() override { system("rm -rf /tmp/infinity"); }
void SetUp() override {
BaseTest::SetUp();
system("rm -rf /tmp/infinity/log /tmp/infinity/data /tmp/infinity/wal");
infinity::GlobalResourceUsage::Init();
std::shared_ptr<std::string> config_path = nullptr;
infinity::InfinityContext::instance().Init(config_path);
}

void TearDown() override {
infinity::InfinityContext::instance().UnInit();
EXPECT_EQ(infinity::GlobalResourceUsage::GetObjectCount(), 0);
EXPECT_EQ(infinity::GlobalResourceUsage::GetRawMemoryCount(), 0);
infinity::GlobalResourceUsage::UnInit();
BaseTest::TearDown();
}
};

// Test status transfer of buffer handle.
Expand Down

0 comments on commit f984773

Please sign in to comment.