Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
opencurve
Curve
提交
d436082a
Curve
项目概览
opencurve
/
Curve
10 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Curve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d436082a
编写于
6月 25, 2023
作者:
H
Hanqing Wu
提交者:
Hanqing Wu
6月 26, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade googletest to v1.12.1
Signed-off-by:
N
Hanqing Wu
<
wuhanqing@corp.netease.com
>
上级
6e00652b
变更
24
显示空白变更内容
内联
并排
Showing
24 changed file
with
38 addition
and
95 deletion
+38
-95
WORKSPACE
WORKSPACE
+7
-4
curvefs/test/client/client_operator_test.cpp
curvefs/test/client/client_operator_test.cpp
+1
-0
curvefs/test/client/lease/lease_executor_test.cpp
curvefs/test/client/lease/lease_executor_test.cpp
+1
-1
curvefs/test/client/test_fuse_s3_client.cpp
curvefs/test/client/test_fuse_s3_client.cpp
+1
-2
curvefs/test/client/test_fuse_volume_client.cpp
curvefs/test/client/test_fuse_volume_client.cpp
+1
-0
curvefs/test/mds/fs_manager_test2.cpp
curvefs/test/mds/fs_manager_test2.cpp
+1
-0
curvefs/test/mds/mock/mock_metaserver_client.h
curvefs/test/mds/mock/mock_metaserver_client.h
+0
-1
curvefs/test/mds/topology/test_topology.cpp
curvefs/test/mds/topology/test_topology.cpp
+1
-0
curvefs/test/metaserver/inode_storage_test.cpp
curvefs/test/metaserver/inode_storage_test.cpp
+0
-2
curvefs/test/metaserver/mock/mock_kv_storage.h
curvefs/test/metaserver/mock/mock_kv_storage.h
+0
-1
docs/cn/gmock.md
docs/cn/gmock.md
+16
-15
replace-curve-repo.sh
replace-curve-repo.sh
+0
-3
test/chunkserver/copyset_node_test.cpp
test/chunkserver/copyset_node_test.cpp
+0
-2
test/chunkserver/mock_node.h
test/chunkserver/mock_node.h
+0
-2
test/chunkserver/raftsnapshot/mock_file_reader.h
test/chunkserver/raftsnapshot/mock_file_reader.h
+0
-2
test/chunkserver/raftsnapshot/mock_snapshot_attachment.h
test/chunkserver/raftsnapshot/mock_snapshot_attachment.h
+0
-2
test/mds/chunkserverclient/test_chunkserver_client.cpp
test/mds/chunkserverclient/test_chunkserver_client.cpp
+2
-1
test/mds/chunkserverclient/test_copyset_client.cpp
test/mds/chunkserverclient/test_copyset_client.cpp
+2
-4
test/mds/snapshotcloneclient/test_snapshotclone_client.cpp
test/mds/snapshotcloneclient/test_snapshotclone_client.cpp
+1
-1
test/mds/topology/test_topology.cpp
test/mds/topology/test_topology.cpp
+1
-0
test/mds/topology/test_topology_metric.cpp
test/mds/topology/test_topology_metric.cpp
+1
-0
test/mds/topology/test_topology_service_manager.cpp
test/mds/topology/test_topology_service_manager.cpp
+1
-0
test/mds/topology/test_topology_stat.cpp
test/mds/topology/test_topology_stat.cpp
+1
-0
thirdparties/gmock.BUILD
thirdparties/gmock.BUILD
+0
-52
未找到文件。
WORKSPACE
浏览文件 @
d436082a
...
...
@@ -75,11 +75,14 @@ bind(
)
#import the gtest files.
new_git_repository
(
http_archive
(
name
=
"com_google_googletest"
,
build_file
=
"//:thirdparties/gmock.BUILD"
,
remote
=
"https://github.com/google/googletest"
,
tag
=
"release-1.8.0"
,
urls
=
[
"https://curve-build.nos-eastchina1.126.net/googletest-release-1.12.1.tar.gz"
,
"https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz"
,
],
sha256
=
"81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2"
,
strip_prefix
=
"googletest-release-1.12.1"
,
)
bind
(
...
...
curvefs/test/client/client_operator_test.cpp
浏览文件 @
d436082a
...
...
@@ -34,6 +34,7 @@ namespace curvefs {
namespace
client
{
using
::
testing
::
SetArgPointee
;
using
::
testing
::
DoAll
;
using
rpcclient
::
MockMetaServerClient
;
using
rpcclient
::
MockMdsClient
;
...
...
curvefs/test/client/lease/lease_executor_test.cpp
浏览文件 @
d436082a
...
...
@@ -36,7 +36,7 @@ using curvefs::mds::topology::PartitionTxId;
using
::
testing
::
AtLeast
;
using
::
testing
::
Return
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
DoAll
;
namespace
curvefs
{
namespace
client
{
...
...
curvefs/test/client/test_fuse_s3_client.cpp
浏览文件 @
d436082a
...
...
@@ -21,8 +21,6 @@
*/
#include <gmock/gmock-generated-actions.h>
#include <gmock/gmock-more-actions.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
...
...
@@ -75,6 +73,7 @@ namespace client {
using
::
curve
::
common
::
Configuration
;
using
::
curvefs
::
mds
::
topology
::
PartitionTxId
;
using
::
testing
::
_
;
using
::
testing
::
DoAll
;
using
::
testing
::
AtLeast
;
using
::
testing
::
Contains
;
using
::
testing
::
Invoke
;
...
...
curvefs/test/client/test_fuse_volume_client.cpp
浏览文件 @
d436082a
...
...
@@ -56,6 +56,7 @@ namespace client {
using
::
curve
::
common
::
Configuration
;
using
::
curvefs
::
mds
::
topology
::
PartitionTxId
;
using
::
testing
::
_
;
using
::
testing
::
DoAll
;
using
::
testing
::
Contains
;
using
::
testing
::
Invoke
;
using
::
testing
::
Return
;
...
...
curvefs/test/mds/fs_manager_test2.cpp
浏览文件 @
d436082a
...
...
@@ -69,6 +69,7 @@ using ::testing::_;
using
::
testing
::
Invoke
;
using
::
testing
::
Matcher
;
using
::
testing
::
Return
;
using
::
testing
::
DoAll
;
using
::
testing
::
SaveArg
;
using
::
testing
::
SetArgPointee
;
using
::
curvefs
::
common
::
S3Info
;
...
...
curvefs/test/mds/mock/mock_metaserver_client.h
浏览文件 @
d436082a
...
...
@@ -23,7 +23,6 @@
#ifndef CURVEFS_TEST_MDS_MOCK_MOCK_METASERVER_CLIENT_H_
#define CURVEFS_TEST_MDS_MOCK_MOCK_METASERVER_CLIENT_H_
#include <gmock/gmock-generated-function-mockers.h>
#include <gmock/gmock.h>
#include <set>
#include <string>
...
...
curvefs/test/mds/topology/test_topology.cpp
浏览文件 @
d436082a
...
...
@@ -36,6 +36,7 @@ using ::testing::_;
using
::
testing
::
AnyOf
;
using
::
testing
::
Contains
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
DoAll
;
using
::
curve
::
common
::
Configuration
;
class
TestTopology
:
public
::
testing
::
Test
{
...
...
curvefs/test/metaserver/inode_storage_test.cpp
浏览文件 @
d436082a
...
...
@@ -20,8 +20,6 @@
* @Author: chenwei
*/
#include <gmock/gmock-generated-matchers.h>
#include <gmock/gmock-spec-builders.h>
#include <gmock/gmock.h>
#include <google/protobuf/util/message_differencer.h>
#include <gtest/gtest.h>
...
...
curvefs/test/metaserver/mock/mock_kv_storage.h
浏览文件 @
d436082a
...
...
@@ -23,7 +23,6 @@
#ifndef CURVEFS_TEST_METASERVER_MOCK_MOCK_KV_STORAGE_H_
#define CURVEFS_TEST_METASERVER_MOCK_MOCK_KV_STORAGE_H_
#include <gmock/gmock-generated-function-mockers.h>
#include <gmock/gmock.h>
#include <memory>
...
...
docs/cn/gmock.md
浏览文件 @
d436082a
...
...
@@ -23,23 +23,24 @@
1.
从Turtle派生一个类MockTurtle。
2.
使用Turtle的虚函数,计算它有多少参数。
3.
在子类的public:部分,写MOCK_METHODn(); (或MOCK_CONST_METHODn();如果你是一个const方法),其中n是参数的数量;如果你计数错误,产生一个一个编译器错误。
4.
使用函数名作为宏的第一个参数,第二个参数是函数的类型。
3.
在子类的public:部分,使用
`MOCK_METHOD`
创建 mock 函数
例:
```
cpp
#include "gmock/gmock.h" // Brings in Google Mock.
#include "gmock/gmock.h" // Brings in Google Mock.
class MockTurtle : public Turtle {
class
MockTurtle
:
public
Turtle
{
public:
...
MOCK_METHOD0(PenUp, void());
MOCK_METHOD0(PenDown, void());
MOCK_METHOD1(Forward, void(int distance));
MOCK_METHOD1(Turn, void(int degrees));
MOCK_METHOD2(GoTo, void(int x, int y));
MOCK_CONST_METHOD0(GetX, int());
MOCK_CONST_METHOD0(GetY, int());
};
// ...
MOCK_METHOD
(
void
,
PenUp
,
(),
(
override
));
MOCK_METHOD
(
void
,
PenDown
,
(),
(
override
));
MOCK_METHOD
(
void
,
Forward
,
(
int
),
(
override
));
MOCK_METHOD
(
void
,
Turn
,
(
int
),
(
override
));
MOCK_METHOD
(
void
,
GoTo
,
(
int
,
int
),
(
override
));
MOCK_METHOD
(
int
,
GetX
,
(),
(
const
,
override
));
MOCK_METHOD
(
int
,
GetY
,
(),
(
const
,
override
));
};
```
### 在测试中使用mock类
...
...
replace-curve-repo.sh
浏览文件 @
d436082a
...
...
@@ -14,9 +14,6 @@ sed -i "s;https://zlib.net/zlib-1.2.11.tar.gz;https://curve-build.nos-eastchina1
# protobuf
sed
-i
"s;https://github.com/google/protobuf/archive/v3.6.1.3.zip;https://curve-build.nos-eastchina1.126.net/protobuf-3.6.1.3.zip;g"
WORKSPACE
# googletest
sed
-i
"s;https://github.com/google/googletest;https://gitee.com/mirrors/googletest;g"
WORKSPACE
# gflags
sed
-i
"s;https://github.com/gflags/gflags/archive/v2.2.2.tar.gz;https://curve-build.nos-eastchina1.126.net/gflags-2.2.2.tar.gz;g"
WORKSPACE
...
...
test/chunkserver/copyset_node_test.cpp
浏览文件 @
d436082a
...
...
@@ -23,8 +23,6 @@
#include <gtest/gtest.h>
#include <unistd.h>
#include <brpc/server.h>
#include <gmock/gmock-more-actions.h>
#include <gmock/gmock-generated-function-mockers.h>
#include <memory>
#include <cstdio>
...
...
test/chunkserver/mock_node.h
浏览文件 @
d436082a
...
...
@@ -24,8 +24,6 @@
#define TEST_CHUNKSERVER_MOCK_NODE_H_
#include <gmock/gmock.h>
#include <gmock/gmock-generated-function-mockers.h>
#include <gmock/internal/gmock-generated-internal-utils.h>
#include <braft/raft.h>
#include <string>
...
...
test/chunkserver/raftsnapshot/mock_file_reader.h
浏览文件 @
d436082a
...
...
@@ -24,8 +24,6 @@
#define TEST_CHUNKSERVER_RAFTSNAPSHOT_MOCK_FILE_READER_H_
#include <gmock/gmock.h>
#include <gmock/gmock-generated-function-mockers.h>
#include <gmock/internal/gmock-generated-internal-utils.h>
#include <string>
#include <vector>
#include "src/chunkserver/raftsnapshot/curve_snapshot_file_reader.h"
...
...
test/chunkserver/raftsnapshot/mock_snapshot_attachment.h
浏览文件 @
d436082a
...
...
@@ -24,8 +24,6 @@
#define TEST_CHUNKSERVER_RAFTSNAPSHOT_MOCK_SNAPSHOT_ATTACHMENT_H_
#include <gmock/gmock.h>
#include <gmock/gmock-generated-function-mockers.h>
#include <gmock/internal/gmock-generated-internal-utils.h>
#include <string>
#include <vector>
#include "src/chunkserver/raftsnapshot/curve_snapshot_attachment.h"
...
...
test/mds/chunkserverclient/test_chunkserver_client.cpp
浏览文件 @
d436082a
...
...
@@ -69,6 +69,8 @@ namespace curve {
namespace
mds
{
namespace
chunkserverclient
{
using
::
testing
::
DoAll
;
class
TestChunkServerClient
:
public
::
testing
::
Test
{
protected:
TestChunkServerClient
()
{}
...
...
@@ -796,4 +798,3 @@ TEST_F(TestChunkServerClient, TestDeleteChunkReturnNotLeader) {
}
// namespace chunkserverclient
}
// namespace mds
}
// namespace curve
test/mds/chunkserverclient/test_copyset_client.cpp
浏览文件 @
d436082a
...
...
@@ -66,6 +66,8 @@ namespace curve {
namespace
mds
{
namespace
chunkserverclient
{
using
::
testing
::
DoAll
;
class
TestCopysetClient
:
public
::
testing
::
Test
{
protected:
TestCopysetClient
()
{}
...
...
@@ -404,7 +406,3 @@ TEST_F(TestCopysetClient, TestDeleteChunkRedirectFail) {
}
// namespace chunkserverclient
}
// namespace mds
}
// namespace curve
test/mds/snapshotcloneclient/test_snapshotclone_client.cpp
浏览文件 @
d436082a
...
...
@@ -46,6 +46,7 @@ using ::testing::Return;
using
::
testing
::
_
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
Invoke
;
using
::
testing
::
DoAll
;
namespace
curve
{
namespace
mds
{
...
...
@@ -351,4 +352,3 @@ TEST_F(TestSnapshotCloneClient, TestGetCloneRefStatusSuccessNeedCheck) {
}
// namespace snapshotcloneclient
}
// namespace mds
}
// namespace curve
test/mds/topology/test_topology.cpp
浏览文件 @
d436082a
...
...
@@ -37,6 +37,7 @@ using ::testing::_;
using
::
testing
::
Contains
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
SaveArg
;
using
::
testing
::
DoAll
;
using
::
curve
::
common
::
Configuration
;
using
::
curve
::
common
::
kDefaultPoolsetId
;
using
::
curve
::
common
::
kDefaultPoolsetName
;
...
...
test/mds/topology/test_topology_metric.cpp
浏览文件 @
d436082a
...
...
@@ -38,6 +38,7 @@ using ::testing::_;
using
::
testing
::
AnyOf
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
Invoke
;
using
::
testing
::
DoAll
;
class
TestTopologyMetric
:
public
::
testing
::
Test
{
public:
...
...
test/mds/topology/test_topology_service_manager.cpp
浏览文件 @
d436082a
...
...
@@ -41,6 +41,7 @@ using ::testing::_;
using
::
testing
::
AnyOf
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
Invoke
;
using
::
testing
::
DoAll
;
using
::
curve
::
chunkserver
::
MockCopysetServiceImpl
;
using
::
curve
::
chunkserver
::
CopysetResponse2
;
...
...
test/mds/topology/test_topology_stat.cpp
浏览文件 @
d436082a
...
...
@@ -39,6 +39,7 @@ using ::testing::_;
using
::
testing
::
AnyOf
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
Invoke
;
using
::
testing
::
DoAll
;
class
TestTopologyStat
:
public
::
testing
::
Test
{
public:
...
...
thirdparties/gmock.BUILD
已删除
100644 → 0
浏览文件 @
6e00652b
#
# Copyright (c) 2020 NetEase Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package(default_visibility = ["//visibility:public"])
cc_library(
name = "gtest_prod",
hdrs = ["googletest/include/gtest/gtest_prod.h"],
includes = ["googletest/include"],
)
cc_library(
name = "gtest",
srcs = [
"googletest/src/gtest-all.cc",
"googlemock/src/gmock-all.cc",
],
hdrs = glob([
"**/*.h",
"googletest/src/*.cc",
"googlemock/src/*.cc",
]),
includes = [
"googlemock",
"googletest",
"googletest/include",
"googlemock/include",
],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
cc_library(
name = "gtest_main",
srcs = ["googlemock/src/gmock_main.cc"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
deps = [":gtest"],
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录