安全測試用例
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
。
概括
受保護的方法 |
---|
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)
領域
測試名稱
public TestName testName
公共構造函數
安全測試用例
public SecurityTestCase ()
公共方法
斷言匹配
public void assertMatches (String pattern,
String input)
參數 |
---|
pattern | String |
input | String |
斷言匹配多行
public void assertMatchesMultiLine (String pattern,
String input)
參數 |
---|
pattern | String |
input | String |
assertNotKernelPointer
public void assertNotKernelPointer (Callable<String> getPtrFunction,
ITestDevice deviceToReboot)
運行提供的函數,該函數收集 String 以測試內核指針洩漏。 getPtrFunction 函數實現必須返回一個以指針開頭的字符串。即“01234567”。除了 [0-9a-fA-F] 之外,允許使用尾隨字符。如果指針似乎易受攻擊,則會拋出 JUnit 斷言。由於可以對內核指針進行散列處理,因此散列指針有可能重疊到正常的內核空間中。重新運行測試以使誤報在統計上不顯著。當內核指針在不重啟的情況下不會改變時,提供一個設備來重啟。
參數 |
---|
getPtrFunction | Callable :返回以指針開頭的字符串的函數 |
deviceToReboot | ITestDevice :當內核指針不會改變時重啟的設備 |
斷言不匹配
public void assertNotMatches (String pattern,
String input)
參數 |
---|
pattern | String |
input | String |
assertNotMatchesMultiLine
public void assertNotMatchesMultiLine (String pattern,
String input)
參數 |
---|
pattern | String |
input | String |
斷言 Wifi 已連接
public void assertWifiConnected (ITestDevice device)
斷言 wifi 連接狀態已連接。由於 STS 可以在運行測試之前立即重啟設備,因此在測試運行之前可能無法連接 wifi。我們輪詢 wifi,直到超時或 wifi 已連接。
參數 |
---|
device | ITestDevice :要運行的設備 |
assumeIsSupportedNfcDevice
public void assumeIsSupportedNfcDevice (ITestDevice device)
buildMetricsReportLog
public static MetricsReportLog buildMetricsReportLog (ITestDevice device)
創建WifiHelper
public WifiHelper createWifiHelper ()
投擲 |
---|
DeviceNotAvailableException | |
得到阿比
public static IAbi getAbi (ITestDevice device)
獲取構建信息
public static IBuildInfo getBuildInfo (ITestDevice device)
獲取PocPusher
public static PocPusher getPocPusher (ITestDevice device)
獲取測試名稱
public static String getTestName (ITestDevice device)
moduleIsPlayManaged
public boolean moduleIsPlayManaged (String modulePackageName)
如果模塊是播放管理的,則返回 true。
基於主線模塊跳過測試的示例:
@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 |
安全重啟
public void safeReboot ()
投擲 |
---|
DeviceNotAvailableException | |
設置
public void setUp ()
等待設備上線,標記設備的最近啟動時間
拆除
public void tearDown ()
確保手機在線並檢查設備是否崩潰
更新內核啟動時間
public void updateKernelStartTime ()
如果在計劃重啟後調用,則允許測試通過。
投擲 |
---|
DeviceNotAvailableException | |
受保護的方法
包含驅動程序
protected boolean containsDriver (ITestDevice device,
String driver,
boolean checkReadable)
檢查機器上是否存在驅動程序。
參數 |
---|
device | ITestDevice |
driver | String |
checkReadable | boolean |
包含驅動程序
protected boolean containsDriver (ITestDevice device,
String driver)
檢查驅動程序是否存在且可讀。
參數 |
---|
device | ITestDevice |
driver | String |