Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
70279eeb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
70279eeb
编写于
12月 19, 2021
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-12194 pull-in cpp-stub
上级
5787ec5b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
8 deletion
+49
-8
cmake/stub_CMakeLists.txt.in
cmake/stub_CMakeLists.txt.in
+12
-0
contrib/CMakeLists.txt
contrib/CMakeLists.txt
+6
-0
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+25
-2
source/libs/parser/test/mockCatalog.h
source/libs/parser/test/mockCatalog.h
+2
-2
source/libs/planner/test/plannerTests.cpp
source/libs/planner/test/plannerTests.cpp
+4
-4
未找到文件。
cmake/stub_CMakeLists.txt.in
0 → 100644
浏览文件 @
70279eeb
# stub
ExternalProject_Add(stub
GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git
GIT_SUBMODULES "src"
SOURCE_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub"
BINARY_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub/src"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
contrib/CMakeLists.txt
浏览文件 @
70279eeb
...
...
@@ -12,6 +12,7 @@ configure_file("${CMAKE_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}
# googletest
if
(
${
BUILD_TEST
}
)
cat
(
"
${
CMAKE_SUPPORT_DIR
}
/gtest_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
cat
(
"
${
CMAKE_SUPPORT_DIR
}
/stub_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
endif
(
${
BUILD_TEST
}
)
# lz4
...
...
@@ -73,6 +74,11 @@ execute_process(COMMAND "${CMAKE_COMMAND}" --build .
# googletest
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
googletest
)
target_include_directories
(
gtest
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src>
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/cpp-stub/src_linux>
)
endif
(
${
BUILD_TEST
}
)
# cJson
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
70279eeb
...
...
@@ -17,6 +17,9 @@
#include <iostream>
#include "stub.h"
#include "addr_any.h"
namespace
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
...
...
@@ -38,16 +41,36 @@ void generateTestST1(MockCatalogService* mcs) {
}
int32_t
catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
)
{
int32_t
__
catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
)
{
return
mockCatalogService
->
catalogGetHandle
(
clusterId
,
catalogHandle
);
}
int32_t
catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTableName
,
STableMeta
**
pTableMeta
)
{
int32_t
__
catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTableName
,
STableMeta
**
pTableMeta
)
{
return
mockCatalogService
->
catalogGetTableMeta
(
pCatalog
,
pRpc
,
pMgmtEps
,
pDBName
,
pTableName
,
pTableMeta
);
}
void
initMetaDataEnv
()
{
mockCatalogService
.
reset
(
new
MockCatalogService
());
static
Stub
stub
;
stub
.
set
(
catalogGetHandle
,
__catalogGetHandle
);
stub
.
set
(
catalogGetTableMeta
,
__catalogGetTableMeta
);
{
AddrAny
any
(
"libcatalog.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^catalogGetHandle$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
__catalogGetHandle
);
}
}
{
AddrAny
any
(
"libcatalog.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^catalogGetTableMeta$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
__catalogGetTableMeta
);
}
}
}
void
generateMetaData
()
{
...
...
source/libs/parser/test/mockCatalog.h
浏览文件 @
70279eeb
...
...
@@ -23,7 +23,7 @@ void generateMetaData();
void
destroyMetaDataEnv
();
// mock
int32_t
catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
);
int32_t
catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
const
char
*
pTableName
,
STableMeta
**
pTableMeta
);
//
int32_t catalogGetHandle(const char *clusterId, struct SCatalog** catalogHandle);
//
int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta);
#endif // MOCK_CATALOG_H
source/libs/planner/test/plannerTests.cpp
浏览文件 @
70279eeb
...
...
@@ -28,7 +28,7 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
class
P
ars
erEnv
:
public
testing
::
Environment
{
class
P
lann
erEnv
:
public
testing
::
Environment
{
public:
virtual
void
SetUp
()
{
initMetaDataEnv
();
...
...
@@ -39,12 +39,12 @@ public:
destroyMetaDataEnv
();
}
P
ars
erEnv
()
{}
virtual
~
P
ars
erEnv
()
{}
P
lann
erEnv
()
{}
virtual
~
P
lann
erEnv
()
{}
};
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
AddGlobalTestEnvironment
(
new
P
ars
erEnv
());
testing
::
AddGlobalTestEnvironment
(
new
P
lann
erEnv
());
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录