GTestBase

public abstract class GTestBase
extends Object implements IAbiReceiver, IConfigurationReceiver, IRemoteTest, IRuntimeHintProvider, IShardableTest, ITestCollector, ITestFilterReceiver

java.lang.Object
   ↳ com.android.tradefed.testtype.GTestBase


gTest 的基礎類別

摘要

欄位

protected static final String FILTER_EXTENSION

protected static final String GTEST_FLAG_FILE

protected static final String GTEST_FLAG_FILTER

protected static final String GTEST_FLAG_LIST_TESTS

protected static final String GTEST_FLAG_PRINT_TIME

protected static final String GTEST_FLAG_RUN_DISABLED_TESTS

protected static final String GTEST_XML_OUTPUT

公用建構函式

GTestBase()

公用方法

void addAllExcludeFilters( filters)

新增要排除測試的篩選器 ERROR(/Set)

void addAllIncludeFilters( filters)

新增要納入測試的篩選器 ERROR(/Set)

void addExcludeFilter(String filter)

新增篩選器,篩選出要排除的測試。

void addIncludeFilter(String filter)

新增篩選器,選取要納入的測試。

String cleanFilter(String filter)
void clearExcludeFilters()

刪除目前追蹤的所有「排除」篩選器。

void clearIncludeFilters()

刪除目前追蹤的所有「包含」篩選器。

IAbi getAbi()
getAfterTestCmd()

取得要在 GTest 之後執行的殼層指令。

getBeforeTestCmd()

取得要在 GTest 之前執行的殼層指令。

getExcludeFilters()

傳回目前 ERROR(/Set) 的「排除」篩選器。

getFileExclusionFilterRegex()

取得規則運算式,禁止特定檔案執行。

getGTestFlags()

取得要傳遞至原生測試 shell 指令的其他旗標值。

getIncludeFilters()

傳回「包含」篩選器的目前 ERROR(/Set)

long getMaxTestTimeMs()

取得執行 gtest 的時間上限。

String getModuleName()

取得要執行的 Android 原生測試模組。

boolean getRunDisabledTests()

確認 GTest 是否應執行停用的測試。

long getRuntimeHint()

傳回測試的預期執行階段, 毫秒。

int getShardCount()

傳回目前的資料分割計數。

int getShardIndex()

取得這項測試的資料分割索引。

String getTestFilterKey()

取得測試篩選器金鑰。

String getTestModule()

取得模組名稱。

boolean isCollectTestsOnly()

僅叫用測試二進位檔,以收集適用測試案例的清單。

boolean isEnableXmlOutput()

取得測試結果是否使用 gtest XML 輸出內容。

boolean isSharded()

Getssharded 標記。

void notifyTestExecution(boolean incompleteTestFound, failedTests)

通知測試執行作業的父項,讓系統能夠正確處理包含/排除篩選器 供重試。

void setAbi(IAbi abi)
void setCollectTestsOnly(boolean shouldCollectTest)

啟用或停用測試收集模式

void setConfiguration(IConfiguration configuration)

插入使用中的 IConfiguration

void setModuleName(String moduleName)

設定要執行的 Android 原生測試模組。

void setShardCount(int shardCount)

設定這項測試的資料分割數量。

void setShardIndex(int shardIndex)

設定這項測試的資料分割索引。

split(int shardCountHint)

split() 的替代版本,該版本也提供要嘗試的 shardCount 要在哪個 Pod 執行

保護方法

String createFlagFile(String filter)

建立含有篩選器的檔案,該檔案將透過 --gtest_flagfile 使用,以避免發生作業系統 引數大小的限制

void erasePrependedFileName( filters, String filename)
String getAllGTestFlags(String path)

協助取得所有 GTest 標記以傳遞至 ADB 殼層指令。

IConfiguration getConfiguration()

傳回測試設定。

String getExceptionMessage(Exception e)

盡量針對特定的 Exception

String getGTestCmdLine(String fullPath, String flags)

用於建構要執行的 gtest 指令的輔助方法。

String getGTestCmdLineWrapper(String fullPath, String flags)

此輔助程式可讓衍生類別納入其他工具 (chroot、 strace、gdb 等類似)。

String getGTestFilters(String path)

協助取得執行測試的 g-test 篩選器。

ITestInvocationListener getGTestListener(ITestInvocationListener listener)

傳回提供額外偵錯資訊的 GTestListener,例如偵測和 如果 mDisabledDuplicateCheck 設為 false,則會回報重複的測試。

abstract String loadFilter(String path)

定義 get 篩選器方法。

void setRunDisabled(boolean runDisabled)

設定 GTest 是否應執行停用的測試。

欄位

篩選器

protected static final String FILTER_EXTENSION

GTEST_FLAG_FILE

protected static final String GTEST_FLAG_FILE

GTEST_FLAG_FILTER

protected static final String GTEST_FLAG_FILTER

GTEST_FLAG_LIST_TESTS

protected static final String GTEST_FLAG_LIST_TESTS

GTEST_FLAG_PRINT_TIME

protected static final String GTEST_FLAG_PRINT_TIME

GTEST_FLAG_RUN_DISABLED_TESTS

protected static final String GTEST_FLAG_RUN_DISABLED_TESTS

GTEST_XML_OUTPUT

protected static final String GTEST_XML_OUTPUT

公用建構函式

GTestBase

public GTestBase ()

公用方法

加入所有排除篩選器

public void addAllExcludeFilters ( filters)

新增要排除測試的篩選器 ERROR(/Set)

參數
filters

加入所有篩選器

public void addAllIncludeFilters ( filters)

新增要納入測試的篩選器 ERROR(/Set)

參數
filters

新增排除篩選器

public void addExcludeFilter (String filter)

新增篩選器,篩選出要排除的測試。

參數
filter String

加入篩選器

public void addIncludeFilter (String filter)

新增篩選器,選取要納入的測試。

參數
filter String

清理篩選器

public String cleanFilter (String filter)

參數
filter String

傳回
String

清除排除篩選器

public void clearExcludeFilters ()

刪除目前追蹤的所有「排除」篩選器。

ClearIncludeFilters

public void clearIncludeFilters ()

刪除目前追蹤的所有「包含」篩選器。

getAbi

public IAbi getAbi ()

傳回
IAbi

getAfterTestCmd

public  getAfterTestCmd ()

取得要在 GTest 之後執行的殼層指令。

傳回

getBeforeTestCmd

public  getBeforeTestCmd ()

取得要在 GTest 之前執行的殼層指令。

傳回

取得排除篩選器

public  getExcludeFilters ()

傳回目前 ERROR(/Set) 的「排除」篩選器。

傳回

取得檔案排除篩選器規則運算式

public  getFileExclusionFilterRegex ()

取得規則運算式,禁止特定檔案執行。

傳回

getGTestFlags

public  getGTestFlags ()

取得要傳遞至原生測試 shell 指令的其他旗標值。

傳回

getIncludeFilters

public  getIncludeFilters ()

傳回「包含」篩選器的目前 ERROR(/Set)

傳回

getMaxTestTimeMs

public long getMaxTestTimeMs ()

取得執行 gtest 的時間上限。

傳回
long

getModuleName

public String getModuleName ()

取得要執行的 Android 原生測試模組。

傳回
String 要執行的原生測試模組名稱;如未設定,則為空值

getRunDisabledTests

public boolean getRunDisabledTests ()

確認 GTest 是否應執行停用的測試。

傳回
boolean 如果應執行停用的測試,則為「true」,否則傳回「false」

getRuntimeHint

public long getRuntimeHint ()

傳回測試的預期執行階段, 毫秒。 這個時間可用來平衡資料分割執行作業

傳回
long

getShardCount

public int getShardCount ()

傳回目前的資料分割計數。

傳回
int

getShardIndex

public int getShardIndex ()

取得這項測試的資料分割索引。

傳回
int

getTestFilterKey

public String getTestFilterKey ()

取得測試篩選器金鑰。

傳回
String

getTestModule

public String getTestModule ()

取得模組名稱。

傳回
String

isCollectTestsOnly

public boolean isCollectTestsOnly ()

僅叫用測試二進位檔,以收集適用測試案例的清單。

傳回
boolean

isEnableXmlOutput

public boolean isEnableXmlOutput ()

取得測試結果是否使用 gtest XML 輸出內容。

傳回
boolean

已分割

public boolean isSharded ()

Getssharded 標記。

傳回
boolean

通知 TestExecution

public void notifyTestExecution (boolean incompleteTestFound, 
                 failedTests)

通知測試執行作業的父項,讓系統能夠正確處理包含/排除篩選器 供重試。

參數
incompleteTestFound boolean

failedTests

SetAbi

public void setAbi (IAbi abi)

參數
abi IAbi

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

啟用或停用測試收集模式

setConfiguration

public void setConfiguration (IConfiguration configuration)

插入使用中的 IConfiguration

參數
configuration IConfiguration

設定模組名稱

public void setModuleName (String moduleName)

設定要執行的 Android 原生測試模組。

參數
moduleName String:要執行的原生測試模組名稱

setShardCount

public void setShardCount (int shardCount)

設定這項測試的資料分割數量。

參數
shardCount int

setShardIndex

public void setShardIndex (int shardIndex)

設定這項測試的資料分割索引。

參數
shardIndex int

分割

public  split (int shardCountHint)

split() 的替代版本,該版本也提供要嘗試的 shardCount 要在哪個 Pod 執行這對於某些無法任意決定的測試執行器而言很實用。

參數
shardCountHint int:嘗試的資料分割數量。

傳回
一組要單獨執行的子測試,如為測試,則傳回 null 目前無法分割

保護方法

建立旗標檔案

protected String createFlagFile (String filter)

建立含有篩選器的檔案,該檔案將透過 --gtest_flagfile 使用,以避免發生作業系統 引數大小的限制

參數
filter String:篩選器字串

傳回
String 包含篩選器的檔案路徑。

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

ClearPrependedFileName

protected void erasePrependedFileName ( filters, 
                String filename)

參數
filters

filename String

getAllGTestFlags

protected String getAllGTestFlags (String path)

協助取得所有 GTest 標記以傳遞至 ADB 殼層指令。

參數
path String:裝置上二進位檔的完整路徑。

傳回
String 應傳遞至 GTest 的所有 GTest 標記 String

擲回
DeviceNotAvailableException

getConfiguration

protected IConfiguration getConfiguration ()

傳回測試設定。

傳回
IConfiguration 一個 IConfiguration

getExceptionMessage

protected String getExceptionMessage (Exception e)

盡量針對特定的 Exception

參數
e ExceptionException

傳回
String 一則簡短的訊息

getGTestCmdLine

protected String getGTestCmdLine (String fullPath, 
                String flags)

用於建構要執行的 gtest 指令的輔助方法。

參數
fullPath String:裝置上的 gtest 二進位檔絕對檔案系統路徑

flags String:Gtest 執行標記

傳回
String 要執行 gtest 的殼層指令列

getGTestCmdLineWrapper

protected String getGTestCmdLineWrapper (String fullPath, 
                String flags)

此輔助程式可讓衍生類別納入其他工具 (chroot、 strace、gdb 等類似)。

參數
fullPath String

flags String

傳回
String

getGTestFilters

protected String getGTestFilters (String path)

協助取得執行測試的 g-test 篩選器。

請注意,篩選器只會篩選函式名稱 (例如:Google Test "Test")。所有 Google 測試「測試案例」

參數
path String:裝置上二進位檔的完整路徑。

傳回
String 要傳遞至 g-test 的完整篩選器旗標,如果沒有任何篩選器,則為空白字串 已指定

擲回
DeviceNotAvailableException

getGTestListener

protected ITestInvocationListener getGTestListener (ITestInvocationListener listener)

傳回提供額外偵錯資訊的 GTestListener,例如偵測和 如果 mDisabledDuplicateCheck 設為 false,則會回報重複的測試。否則,則會傳回傳入的 接聽程式。

參數
listener ITestInvocationListener

傳回
ITestInvocationListener

loadFilter

protected abstract String loadFilter (String path)

定義 get 篩選器方法。

子類別必須實作如何取得自己的篩選器。

參數
path String:篩選器檔案的完整路徑。

傳回
String 篩選器字串。

擲回
DeviceNotAvailableException

setRunDisabled

protected void setRunDisabled (boolean runDisabled)

設定 GTest 是否應執行停用的測試。

參數
runDisabled boolean