Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
1cd13044
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1cd13044
编写于
2月 18, 2020
作者:
C
Chinmay Garde
提交者:
GitHub
2月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Control test timeouts based on debugger status or command line flags. (#16375)
上级
c264e1cf
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
142 addition
and
4 deletion
+142
-4
testing/BUILD.gn
testing/BUILD.gn
+2
-0
testing/debugger_detection.cc
testing/debugger_detection.cc
+71
-0
testing/debugger_detection.h
testing/debugger_detection.h
+23
-0
testing/run_all_unittests.cc
testing/run_all_unittests.cc
+41
-1
testing/test_timeout_listener.cc
testing/test_timeout_listener.cc
+4
-1
testing/test_timeout_listener.h
testing/test_timeout_listener.h
+1
-2
未找到文件。
testing/BUILD.gn
浏览文件 @
1cd13044
...
...
@@ -27,6 +27,8 @@ source_set("testing") {
testonly = true
sources = [
"debugger_detection.cc",
"debugger_detection.h",
"run_all_unittests.cc",
"test_timeout_listener.cc",
"test_timeout_listener.h",
...
...
testing/debugger_detection.cc
0 → 100644
浏览文件 @
1cd13044
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/testing/debugger_detection.h"
#include "flutter/fml/build_config.h"
#include "flutter/fml/logging.h"
#if OS_MACOSX
#include <assert.h>
#include <stdbool.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <unistd.h>
#endif // OS_MACOSX
#if OS_WIN
#include <windows.h>
#endif // OS_WIN
namespace
flutter
{
namespace
testing
{
DebuggerStatus
GetDebuggerStatus
()
{
#if OS_MACOSX
// From Technical Q&A QA1361 Detecting the Debugger
// https://developer.apple.com/library/archive/qa/qa1361/_index.html
int
management_info_base
[
4
];
struct
kinfo_proc
info
;
size_t
size
;
// Initialize the flags so that, if sysctl fails for some bizarre
// reason, we get a predictable result.
info
.
kp_proc
.
p_flag
=
0
;
// Initialize management_info_base, which tells sysctl the info we want, in
// this case we're looking for information about a specific process ID.
management_info_base
[
0
]
=
CTL_KERN
;
management_info_base
[
1
]
=
KERN_PROC
;
management_info_base
[
2
]
=
KERN_PROC_PID
;
management_info_base
[
3
]
=
getpid
();
// Call sysctl.
size
=
sizeof
(
info
);
auto
status
=
::
sysctl
(
management_info_base
,
sizeof
(
management_info_base
)
/
sizeof
(
*
management_info_base
),
&
info
,
&
size
,
NULL
,
0
);
FML_CHECK
(
status
==
0
);
// We're being debugged if the P_TRACED flag is set.
return
((
info
.
kp_proc
.
p_flag
&
P_TRACED
)
!=
0
)
?
DebuggerStatus
::
kAttached
:
DebuggerStatus
::
kDontKnow
;
#elif OS_WIN
return
::
IsDebuggerPresent
()
?
DebuggerStatus
::
kAttached
:
DebuggerStatus
::
kDontKnow
;
#else
return
DebuggerStatus
::
kDontKnow
;
#endif
}
// namespace testing
}
// namespace testing
}
// namespace flutter
testing/debugger_detection.h
0 → 100644
浏览文件 @
1cd13044
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_TESTING_DEBUGGER_DETECTION_H_
#define FLUTTER_TESTING_DEBUGGER_DETECTION_H_
#include "flutter/fml/macros.h"
namespace
flutter
{
namespace
testing
{
enum
class
DebuggerStatus
{
kDontKnow
,
kAttached
,
};
DebuggerStatus
GetDebuggerStatus
();
}
// namespace testing
}
// namespace flutter
#endif // FLUTTER_TESTING_DEBUGGER_DETECTION_H_
testing/run_all_unittests.cc
浏览文件 @
1cd13044
...
...
@@ -2,7 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <iostream>
#include <optional>
#include <string>
#include "flutter/fml/build_config.h"
#include "flutter/fml/command_line.h"
#include "flutter/testing/debugger_detection.h"
#include "flutter/testing/test_timeout_listener.h"
#include "gtest/gtest.h"
...
...
@@ -10,6 +16,24 @@
#include <asl.h>
#endif // OS_IOS
std
::
optional
<
fml
::
TimeDelta
>
GetTestTimeoutFromArgs
(
int
argc
,
char
**
argv
)
{
const
auto
command_line
=
fml
::
CommandLineFromArgcArgv
(
argc
,
argv
);
std
::
string
timeout_seconds
;
if
(
!
command_line
.
GetOptionValue
(
"timeout"
,
&
timeout_seconds
))
{
// No timeout specified. Default to 30s.
return
fml
::
TimeDelta
::
FromSeconds
(
30u
);
}
const
auto
seconds
=
std
::
stoi
(
timeout_seconds
);
if
(
seconds
<
1
)
{
return
std
::
nullopt
;
}
return
fml
::
TimeDelta
::
FromSeconds
(
seconds
);
}
int
main
(
int
argc
,
char
**
argv
)
{
#ifdef OS_IOS
asl_log_descriptor
(
NULL
,
NULL
,
ASL_LEVEL_NOTICE
,
STDOUT_FILENO
,
...
...
@@ -19,7 +43,23 @@ int main(int argc, char** argv) {
#endif // OS_IOS
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
auto
timeout_listener
=
new
flutter
::
testing
::
TestTimeoutListener
();
// Check if the user has specified a timeout.
const
auto
timeout
=
GetTestTimeoutFromArgs
(
argc
,
argv
);
if
(
!
timeout
.
has_value
())
{
FML_LOG
(
INFO
)
<<
"Timeouts disabled via a command line flag."
;
return
RUN_ALL_TESTS
();
}
// Check if the user is debugging the process.
if
(
flutter
::
testing
::
GetDebuggerStatus
()
==
flutter
::
testing
::
DebuggerStatus
::
kAttached
)
{
FML_LOG
(
INFO
)
<<
"Debugger is attached. Suspending test timeouts."
;
return
RUN_ALL_TESTS
();
}
auto
timeout_listener
=
new
flutter
::
testing
::
TestTimeoutListener
(
timeout
.
value
());
auto
&
listeners
=
::
testing
::
UnitTest
::
GetInstance
()
->
listeners
();
listeners
.
Append
(
timeout_listener
);
auto
result
=
RUN_ALL_TESTS
();
...
...
testing/test_timeout_listener.cc
浏览文件 @
1cd13044
...
...
@@ -72,7 +72,10 @@ TestTimeoutListener::TestTimeoutListener(fml::TimeDelta timeout)
:
timeout_
(
timeout
),
listener_thread_
(
"test_timeout_listener"
),
listener_thread_runner_
(
listener_thread_
.
GetTaskRunner
()),
pending_tests_
(
PendingTests
::
Create
(
listener_thread_runner_
,
timeout_
))
{}
pending_tests_
(
PendingTests
::
Create
(
listener_thread_runner_
,
timeout_
))
{
FML_LOG
(
INFO
)
<<
"Test timeout of "
<<
timeout_
.
ToSeconds
()
<<
" seconds per test case will be enforced."
;
}
TestTimeoutListener
::~
TestTimeoutListener
()
{
listener_thread_runner_
->
PostTask
(
...
...
testing/test_timeout_listener.h
浏览文件 @
1cd13044
...
...
@@ -19,8 +19,7 @@ class PendingTests;
class
TestTimeoutListener
:
public
::
testing
::
EmptyTestEventListener
{
public:
TestTimeoutListener
(
fml
::
TimeDelta
timeout
=
fml
::
TimeDelta
::
FromSeconds
(
30u
));
TestTimeoutListener
(
fml
::
TimeDelta
timeout
);
~
TestTimeoutListener
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录