This commit is contained in:
Hongze Cheng 2021-11-08 13:49:26 +08:00
parent 5704d5e2ee
commit 244b346f1c
4 changed files with 12 additions and 29 deletions

View File

@ -1,9 +1,7 @@
# vnodeMemAllocatorTest
add_executable(VMATest "")
target_sources(VMATest
# Vnode API test
add_executable(vnodeApiTests "")
target_sources(vnodeApiTests
PRIVATE
"../src/vnodeMemAllocator.c"
"vnodeMemAllocatorTest.cpp"
"vnodeApiTests.cpp"
)
target_include_directories(VMATest PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../inc")
target_link_libraries(VMATest os gtest_main vnode)
target_link_libraries(vnodeApiTests vnode gtest gtest_main)

View File

@ -0,0 +1,7 @@
#include <gtest/gtest.h>
#include <iostream>
TEST(vnodeApiTest, vnodeOpen_test) {
// TODO
std::cout << "This is in vnodeApiTest" << std::endl;
}

View File

@ -1,22 +0,0 @@
#include <gtest/gtest.h>
#include <iostream>
#include "vnodeMemAllocator.h"
TEST(VMATest, basic_create_and_destroy_test) {
SVnodeMemAllocator *vma = VMACreate(1024, 512, 64);
EXPECT_TRUE(vma != nullptr);
EXPECT_EQ(vma->full, false);
EXPECT_EQ(vma->ssize, 512);
EXPECT_EQ(vma->threshold, 64);
EXPECT_EQ(vma->inuse->tsize, 1024);
VMADestroy(vma);
vma = VMACreate(1024, 512, 1024);
EXPECT_TRUE(vma != nullptr);
VMADestroy(vma);
vma = VMACreate(1024, 512, 1025);
EXPECT_TRUE(vma == nullptr);
VMADestroy(vma);
}