SecurityTestCase
public
class
SecurityTestCase
extends StsExtraBusinessLogicHostTestBase
| java.lang.Object | |||||
| ↳ | com.android.tradefed.testtype.junit4.BaseHostJUnit4Test | ||||
| ↳ | com.android.compatibility.common.tradefed.testtype.BusinessLogicHostTestBase | ||||
| ↳ | com.android.compatibility.common.tradefed.testtype.ExtraBusinessLogicHostTestBase | ||||
| ↳ | com.android.sts.common.tradefed.testtype.StsExtraBusinessLogicHostTestBase | ||||
| ↳ | com.android.sts.common.tradefed.testtype.SecurityTestCase | ||||
所有 STS 测试的基准测试类。
请改为使用 RootSecurityTestCase 或 NonRootSecurityTestCase。
摘要
常量 | |
|---|---|
int |
TIMEOUT_DEFAULT
|
int |
TIMEOUT_NONDETERMINISTIC
|
字段 | |
|---|---|
public
PocPusher |
pocPusher
|
public
TestName |
testName
|
公共构造函数 | |
|---|---|
SecurityTestCase()
|
|
公共方法 | |
|---|---|
void
|
assertMatches(String pattern, String input)
|
void
|
assertMatchesMultiLine(String pattern, String input)
|
void
|
assertNotKernelPointer(Callable<String> getPtrFunction, ITestDevice deviceToReboot)
运行提供的函数,用于收集字符串以针对内核指针泄露进行测试。 |
void
|
assertNotMatches(String pattern, String input)
|
void
|
assertNotMatchesMultiLine(String pattern, String input)
|
void
|
assertWifiConnected(ITestDevice device)
断言 Wi-Fi 连接状态为已连接。 |
void
|
assumeIsSupportedNfcDevice(ITestDevice device)
|
static
MetricsReportLog
|
buildMetricsReportLog(ITestDevice device)
|
WifiHelper
|
createWifiHelper()
|
static
IAbi
|
getAbi(ITestDevice device)
|
static
IBuildInfo
|
getBuildInfo(ITestDevice device)
|
static
PocPusher
|
getPocPusher(ITestDevice device)
|
static
String
|
getTestName(ITestDevice device)
|
boolean
|
moduleIsPlayManaged(String modulePackageName)
如果模块由 Play 管理,则返回 true。 |
void
|
safeReboot()
|
void
|
setUp()
等待设备上线,标记设备的最近启动时间 |
void
|
tearDown()
确保手机已联网,并检查设备是否发生了崩溃 |
void
|
updateKernelStartTime()
如果在计划的重新启动后调用,则允许测试通过。 |
受保护的方法 | |
|---|---|
boolean
|
containsDriver(ITestDevice device, String driver, boolean checkReadable)
检查计算机上是否存在驱动程序。 |
boolean
|
containsDriver(ITestDevice device, String driver)
检查驱动程序是否存在且可读。 |
常量
TIMEOUT_DEFAULT
protected static final int TIMEOUT_DEFAULT
常量值: 60 (0x0000003c)
TIMEOUT_NONDETERMINISTIC
public static final int TIMEOUT_NONDETERMINISTIC
常量值: 315 (0x0000013b)
字段
testName
public TestName testName
公共构造函数
SecurityTestCase
public SecurityTestCase ()
公共方法
assertMatches
public void assertMatches (String pattern,
String input)| 参数 | |
|---|---|
pattern |
String |
input |
String |
| 抛出 | |
|---|---|
Exception |
|
assertMatchesMultiLine
public void assertMatchesMultiLine (String pattern,
String input)| 参数 | |
|---|---|
pattern |
String |
input |
String |
| 抛出 | |
|---|---|
Exception |
|
assertNotKernelPointer
public void assertNotKernelPointer (Callable<String> getPtrFunction,
ITestDevice deviceToReboot)运行提供的函数,用于收集字符串以针对内核指针泄露进行测试。getPtrFunction 函数实现必须返回以指针开头的字符串。例如“01234567”。允许使用尾随字符,但 [0-9a-fA-F] 除外。如果指针似乎存在漏洞,系统会抛出 JUnit 断言。由于内核指针可以进行哈希处理,因此经过哈希处理的指针可能会与正常内核空间重叠。系统会重新运行测试,以使假正例在统计上不显著。如果内核指针在未重启的情况下不会更改,请提供要重启的设备。
| 参数 | |
|---|---|
getPtrFunction |
Callable:一个函数,用于返回以指针开头的字符串 |
deviceToReboot |
ITestDevice:当内核指针不会更改时,设备会重启
|
| 抛出 | |
|---|---|
Exception |
|
assertNotMatches
public void assertNotMatches (String pattern,
String input)| 参数 | |
|---|---|
pattern |
String |
input |
String |
| 抛出 | |
|---|---|
Exception |
|
assertNotMatchesMultiLine
public void assertNotMatchesMultiLine (String pattern,
String input)| 参数 | |
|---|---|
pattern |
String |
input |
String |
| 抛出 | |
|---|---|
Exception |
|
assertWifiConnected
public void assertWifiConnected (ITestDevice device)
断言 Wi-Fi 连接状态为已连接。由于 STS 可以在运行测试之前立即重启设备,因此在测试运行之前可能无法连接到 Wi-Fi。我们会轮询 Wi-Fi,直到超时或 Wi-Fi 连接为止。
| 参数 | |
|---|---|
device |
ITestDevice:要运行的设备
|
| 抛出 | |
|---|---|
Exception |
|
assumeIsSupportedNfcDevice
public void assumeIsSupportedNfcDevice (ITestDevice device)
| 参数 | |
|---|---|
device |
ITestDevice |
| 抛出 | |
|---|---|
Exception |
|
buildMetricsReportLog
public static MetricsReportLog buildMetricsReportLog (ITestDevice device)
| 参数 | |
|---|---|
device |
ITestDevice |
| 返回 | |
|---|---|
MetricsReportLog |
|
createWifiHelper
public WifiHelper createWifiHelper ()
| 返回 | |
|---|---|
WifiHelper |
|
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
getAbi
public static IAbi getAbi (ITestDevice device)
| 参数 | |
|---|---|
device |
ITestDevice |
| 返回 | |
|---|---|
IAbi |
|
getBuildInfo
public static IBuildInfo getBuildInfo (ITestDevice device)
| 参数 | |
|---|---|
device |
ITestDevice |
| 返回 | |
|---|---|
IBuildInfo |
|
getPocPusher
public static PocPusher getPocPusher (ITestDevice device)
| 参数 | |
|---|---|
device |
ITestDevice |
| 返回 | |
|---|---|
PocPusher |
|
getTestName
public static String getTestName (ITestDevice device)
| 参数 | |
|---|---|
device |
ITestDevice |
| 返回 | |
|---|---|
String |
|
moduleIsPlayManaged
public boolean moduleIsPlayManaged (String modulePackageName)
如果模块由 Play 管理,则返回 true。
基于 Mainline 模块跳过测试的示例:
@Test
public void testPocCVE_1234_5678() throws Exception {
// This will skip the test if MODULE_METADATA mainline module is play managed.
assumeFalse(moduleIsPlayManaged("com.google.android.captiveportallogin"));
// Do testing...
}
| 参数 | |
|---|---|
modulePackageName |
String |
| 返回 | |
|---|---|
boolean |
|
| 抛出 | |
|---|---|
Exception |
|
safeReboot
public void safeReboot ()
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
setUp
public void setUp ()
等待设备上线,标记设备的最近启动时间
| 抛出 | |
|---|---|
Exception |
|
tearDown
public void tearDown ()
确保手机已联网,并检查设备是否发生了崩溃
| 抛出 | |
|---|---|
Exception |
|
updateKernelStartTime
public void updateKernelStartTime ()
如果在计划的重新启动后调用,则允许测试通过。
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
受保护的方法
containsDriver
protected boolean containsDriver (ITestDevice device,
String driver,
boolean checkReadable)检查计算机上是否存在驱动程序。
| 参数 | |
|---|---|
device |
ITestDevice |
driver |
String |
checkReadable |
boolean |
| 返回 | |
|---|---|
boolean |
|
| 抛出 | |
|---|---|
Exception |
|
containsDriver
protected boolean containsDriver (ITestDevice device,
String driver)检查驱动程序是否存在且可读。
| 参数 | |
|---|---|
device |
ITestDevice |
driver |
String |
| 返回 | |
|---|---|
boolean |
|
| 抛出 | |
|---|---|
Exception |
|