ExecutableBaseTest
public
abstract
class
ExecutableBaseTest
extends Object
implements
IAbiReceiver,
IConfigurationReceiver,
IDiscoverDependencies,
IRemoteTest,
IRuntimeHintProvider,
IShardableTest,
ITestCollector,
ITestFilterReceiver
| java.lang.Object | |
| ↳ | com.android.tradefed.testtype.binary.ExecutableBaseTest |
可执行样式测试的基类。例如:二进制文件、shell 脚本。
摘要
常量 | |
|---|---|
String |
NO_BINARY_ERROR
|
公共构造函数 | |
|---|---|
ExecutableBaseTest()
|
|
公共方法 | |
|---|---|
void
|
addAllExcludeFilters(Set<String> filters)
添加用于指定要排除哪些测试的过滤条件 |
void
|
addAllIncludeFilters(Set<String> filters)
添加用于指定要包含哪些测试的过滤条件 |
void
|
addExcludeFilter(String filter)
添加用于指定要排除哪些测试的过滤条件。 |
void
|
addIncludeFilter(String filter)
添加用于指定要包含哪些测试的过滤条件。 |
void
|
clearExcludeFilters()
删除当前跟踪的所有排除过滤条件。 |
void
|
clearIncludeFilters()
删除当前跟踪的所有包含过滤条件。 |
abstract
String
|
findBinary(String binary)
搜索二进制文件,以便能够运行它。 |
IAbi
|
getAbi()
|
boolean
|
getCollectTestsOnly()
|
Set<String>
|
getExcludeFilters()
返回当前的排除过滤条件 |
Set<String>
|
getIncludeFilters()
返回当前的包含过滤条件 |
final
long
|
getRuntimeHint()
返回测试的预期运行时长(以毫秒为单位)。 |
Set<String>
|
reportDependencies()
|
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
运行测试,并将结果报告给监听器。 |
abstract
void
|
runBinary(String binaryPath, ITestInvocationListener listener, TestDescription description)
实际运行给定路径中的二进制文件。 |
final
void
|
setAbi(IAbi abi)
|
final
void
|
setCollectTestsOnly(boolean shouldCollectTest)
启用或停用测试收集模式 |
void
|
setConfiguration(IConfiguration configuration)
注入正在使用的 |
FailureDescription
|
shouldAbortRun(TestDescription description)
检查 testRun 是否应提前结束。 |
final
Collection<IRemoteTest>
|
split(int shardHint)
|
受保护的方法 | |
|---|---|
boolean
|
doesRunBinaryGenerateTestResults()
|
boolean
|
doesRunBinaryGenerateTestRuns()
|
Map<String, String>
|
getAllTestCommands()
将 mBinaryPaths 转换为 mTestCommands 以保持一致性。 |
IConfiguration
|
getConfiguration()
返回测试配置。 |
TestDescription[]
|
getFilterDescriptions(Map<String, String> testCommands)
|
String
|
getModuleId(IInvocationContext context)
|
long
|
getTimeoutPerBinaryMs()
|
boolean
|
isTestFailed(String testName)
|
常量
NO_BINARY_ERROR
public static final String NO_BINARY_ERROR
常量值: "二进制文件 %s 不存在。"
公共构造函数
ExecutableBaseTest
public ExecutableBaseTest ()
公共方法
addAllExcludeFilters
public void addAllExcludeFilters (Set<String> filters)
添加用于指定要排除哪些测试的过滤条件Set。
| 参数 | |
|---|---|
filters |
Set |
addAllIncludeFilters
public void addAllIncludeFilters (Set<String> filters)
添加用于指定要包含哪些测试的过滤条件Set。
| 参数 | |
|---|---|
filters |
Set |
addExcludeFilter
public void addExcludeFilter (String filter)
添加用于指定要排除哪些测试的过滤条件。
| 参数 | |
|---|---|
filter |
String |
addIncludeFilter
public void addIncludeFilter (String filter)
添加用于指定要包含哪些测试的过滤条件。
| 参数 | |
|---|---|
filter |
String |
clearExcludeFilters
public void clearExcludeFilters ()
删除当前跟踪的所有排除过滤条件。
clearIncludeFilters
public void clearIncludeFilters ()
删除当前跟踪的所有包含过滤条件。
findBinary
public abstract String findBinary (String binary)
搜索二进制文件,以便能够运行它。
| 参数 | |
|---|---|
binary |
String:二进制文件的路径或仅为二进制文件名称。 |
| 返回 | |
|---|---|
String |
二进制文件的路径,如果未找到,则为 null。 |
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
getCollectTestsOnly
public boolean getCollectTestsOnly ()
| 返回 | |
|---|---|
boolean |
|
getRuntimeHint
public final long getRuntimeHint ()
以毫秒为单位返回测试的预期运行时长。 该时间用于对分片执行进行负载均衡
| 返回 | |
|---|---|
long |
|
reportDependencies
public Set<String> reportDependencies ()
| 返回 | |
|---|---|
Set<String> |
|
run
public void run (TestInformation testInfo, ITestInvocationListener listener)
运行测试,并将结果报告给监听器。
| 参数 | |
|---|---|
testInfo |
TestInformation:包含用于运行测试的实用信息的 TestInformation 对象。 |
listener |
ITestInvocationListener:测试结果的 ITestInvocationListener |
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
runBinary
public abstract void runBinary (String binaryPath,
ITestInvocationListener listener,
TestDescription description)实际运行给定路径中的二进制文件。
| 参数 | |
|---|---|
binaryPath |
String:二进制文件的路径。 |
listener |
ITestInvocationListener:用于报告结果的监听器。 |
description |
TestDescription:正在进行的测试。 |
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
IOException |
|
setCollectTestsOnly
public final void setCollectTestsOnly (boolean shouldCollectTest)
启用或停用测试收集模式
setConfiguration
public void setConfiguration (IConfiguration configuration)
注入正在使用的 IConfiguration。
| 参数 | |
|---|---|
configuration |
IConfiguration |
shouldAbortRun
public FailureDescription shouldAbortRun (TestDescription description)
检查 testRun 是否应提前结束。
| 参数 | |
|---|---|
description |
TestDescription:正在进行的测试。 |
| 返回 | |
|---|---|
FailureDescription |
如果运行循环应终止,则为 FailureDescription。 |
分解
public final Collection<IRemoteTest> split (int shardHint)
split() 的替代版本,还提供尝试运行的 shardCount。这对于有时无法任意决定的某些测试运行程序非常有用。
| 参数 | |
|---|---|
shardHint |
int:尝试分片的数量。 |
| 返回 | |
|---|---|
Collection<IRemoteTest> |
要单独执行的子测试集合,如果测试目前无法分片,则为 null |
受保护的方法
doesRunBinaryGenerateTestResults
protected boolean doesRunBinaryGenerateTestResults ()
| 返回 | |
|---|---|
boolean |
|
doesRunBinaryGenerateTestRuns
protected boolean doesRunBinaryGenerateTestRuns ()
| 返回 | |
|---|---|
boolean |
|
getAllTestCommands
protected Map<String, String> getAllTestCommands ()
将 mBinaryPaths 转换为 mTestCommands,以保持一致性。
| 返回 | |
|---|---|
Map<String, String> |
testCommands 的 MapLinkedHashMap<string, string="">。</string,> |
getConfiguration
protected IConfiguration getConfiguration ()
返回测试配置。
| 返回 | |
|---|---|
IConfiguration |
IConfiguration |
getFilterDescriptions
protected TestDescription[] getFilterDescriptions (Map<String, String> testCommands)
| 参数 | |
|---|---|
testCommands |
Map |
| 返回 | |
|---|---|
TestDescription[] |
|
getModuleId
protected String getModuleId (IInvocationContext context)
| 参数 | |
|---|---|
context |
IInvocationContext |
| 返回 | |
|---|---|
String |
|
getTimeoutPerBinaryMs
protected long getTimeoutPerBinaryMs ()
| 返回 | |
|---|---|
long |
应用于每个二进制文件以供执行的超时时间。 |
isTestFailed
protected boolean isTestFailed (String testName)
| 参数 | |
|---|---|
testName |
String |
| 返回值 | |
|---|---|
boolean |
|