ITestSuite

public abstract class ITestSuite
extends Object implements IRemoteTest, IDeviceTest, IMultiDeviceTest, IBuildReceiver, ISystemStatusCheckerReceiver, IShardableTest, ITestCollector, IInvocationContextReceiver, IRuntimeHintProvider, IMetricCollectorReceiver, IConfigurationReceiver

java.lang.Object
   ↳ com.android.tradefed.testtype.suite.ITestSuite


Abstract class used to run Test Suite. This class provide the base of how the Suite will be run. Each implementation can define the list of tests via the loadTests() method.

Summary

Constants

String ABI_OPTION

String MODULE_CHECKER_POST

String MODULE_CHECKER_PRE

String PREPARER_WHITELIST

String PRIMARY_ABI_RUN

String RUNNER_WHITELIST

String SKIP_HOST_ARCH_CHECK

String SKIP_SYSTEM_STATUS_CHECKER

Public constructors

ITestSuite()

Public methods

Set<IAbi> getAbis(ITestDevice device)

Gets the set of ABIs supported by both Compatibility testing AbiUtils.getAbisSupportedByCompatibility() and the device under test.

IBuildInfo getBuildInfo()

Implementation of ITestSuite may require the build info to load the tests.

ITestDevice getDevice()

Get the device under test.

ModuleDefinition getDirectModule()

Returns the ModuleDefinition to be executed directly, or null if none yet (when the ITestSuite has not been sharded yet).

final String getRequestedAbi()

Returns the abi requested with the option -a or --abi.

long getRuntimeHint()

Return the expected runtime of the test in milliseconds.

abstract LinkedHashMap<String, IConfiguration> loadTests()

Abstract method to load the tests configuration that will be run.

final void run(ITestInvocationListener listener)

Generic run method for all test loaded from loadTests().

void setAbiName(String abiName)

Set the value of mAbiName

void setBuild(IBuildInfo buildInfo)

void setCollectTestsOnly(boolean shouldCollectTest)

Run the test suite in collector only mode, this requires all the sub-tests to implements this interface too.

void setConfiguration(IConfiguration configuration)

Injects the IConfiguration in use.

void setDevice(ITestDevice device)

Inject the device under test.

void setDeviceInfos(Map<ITestDeviceIBuildInfo> deviceInfos)

void setInvocationContext(IInvocationContext invocationContext)

void setMetricCollectors(List<IMetricCollector> collectors)

Sets the list of IMetricCollectors defined for the test run.

void setPrimaryAbiRun(boolean primaryAbiRun)

Set the value of mPrimaryAbiRun

void setShouldMakeDynamicModule(boolean dynamicModule)

When doing distributed sharding, we cannot have ModuleDefinition that shares tests in a pool otherwise intra-module sharding will not work, so we allow to disable it.

void setSystemStatusChecker(List<ISystemStatusChecker> systemCheckers)

Sets the ISystemStatusCheckers from the configuration for the test.

Collection<IRemoteTest> split(int shardCountHint)

Alternative version of split() which also provides the shardCount that is attempted to be run.

Protected methods

List<ITestInvocationListener> createModuleListeners()

Returns the list of ITestInvocationListener applicable to the ModuleListener level.

boolean filterByConfigMetadata(IConfiguration config, MultiMap<String, String> include, MultiMap<String, String> exclude)

Apply the metadata filter to the config and see if the config should run.

boolean filterByRunnerType(IConfiguration config, Set<String> allowedRunners)

Apply the Runner whitelist filtering, removing any runner that was not whitelisted.

Set<String> getAbisForBuildTargetArch()

Return the abis supported by the Host build target architecture.

Constants

ABI_OPTION

public static final String ABI_OPTION

Constant Value: "abi"

MODULE_CHECKER_POST

public static final String MODULE_CHECKER_POST

Constant Value: "PostModuleChecker"

MODULE_CHECKER_PRE

public static final String MODULE_CHECKER_PRE

Constant Value: "PreModuleChecker"

PREPARER_WHITELIST

public static final String PREPARER_WHITELIST

Constant Value: "preparer-whitelist"

PRIMARY_ABI_RUN

public static final String PRIMARY_ABI_RUN

Constant Value: "primary-abi-only"

RUNNER_WHITELIST

public static final String RUNNER_WHITELIST

Constant Value: "runner-whitelist"

SKIP_HOST_ARCH_CHECK

public static final String SKIP_HOST_ARCH_CHECK

Constant Value: "skip-host-arch-check"

SKIP_SYSTEM_STATUS_CHECKER

public static final String SKIP_SYSTEM_STATUS_CHECKER

Constant Value: "skip-system-status-check"

Public constructors

ITestSuite

public ITestSuite ()

Public methods

getAbis

public Set<IAbi> getAbis (ITestDevice device)

Gets the set of ABIs supported by both Compatibility testing AbiUtils.getAbisSupportedByCompatibility() and the device under test.

Parameters
device ITestDevice

Returns
Set<IAbi> The set of ABIs to run the tests on

Throws
DeviceNotAvailableException

getBuildInfo

public IBuildInfo getBuildInfo ()

Implementation of ITestSuite may require the build info to load the tests.

Returns
IBuildInfo

getDevice

public ITestDevice getDevice ()

Get the device under test.

Returns
ITestDevice the ITestDevice

getDirectModule

public ModuleDefinition getDirectModule ()

Returns the ModuleDefinition to be executed directly, or null if none yet (when the ITestSuite has not been sharded yet).

Returns
ModuleDefinition

getRequestedAbi

public final String getRequestedAbi ()

Returns the abi requested with the option -a or --abi.

Returns
String

getRuntimeHint

public long getRuntimeHint ()

Return the expected runtime of the test in milliseconds. The time is used to load balance sharded execution

Returns
long

loadTests

public abstract LinkedHashMap<String, IConfiguration> loadTests ()

Abstract method to load the tests configuration that will be run. Each tests is defined by a IConfiguration and a unique name under which it will report results.

Returns
LinkedHashMap<String, IConfiguration>

run

public final void run (ITestInvocationListener listener)

Generic run method for all test loaded from loadTests().

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results

Throws
DeviceNotAvailableException

setAbiName

public void setAbiName (String abiName)

Set the value of mAbiName

Parameters
abiName String

setBuild

public void setBuild (IBuildInfo buildInfo)

Parameters
buildInfo IBuildInfo

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

Run the test suite in collector only mode, this requires all the sub-tests to implements this interface too.

setConfiguration

public void setConfiguration (IConfiguration configuration)

Injects the IConfiguration in use.

Parameters
configuration IConfiguration

setDevice

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device ITestDevice: the ITestDevice to use

setDeviceInfos

public void setDeviceInfos (Map<ITestDeviceIBuildInfo> deviceInfos)

Parameters
deviceInfos Map

setInvocationContext

public void setInvocationContext (IInvocationContext invocationContext)

Parameters
invocationContext IInvocationContext

setMetricCollectors

public void setMetricCollectors (List<IMetricCollector> collectors)

Sets the list of IMetricCollectors defined for the test run.

Parameters
collectors List

setPrimaryAbiRun

public void setPrimaryAbiRun (boolean primaryAbiRun)

Set the value of mPrimaryAbiRun

Parameters
primaryAbiRun boolean

setShouldMakeDynamicModule

public void setShouldMakeDynamicModule (boolean dynamicModule)

When doing distributed sharding, we cannot have ModuleDefinition that shares tests in a pool otherwise intra-module sharding will not work, so we allow to disable it.

Parameters
dynamicModule boolean

setSystemStatusChecker

public void setSystemStatusChecker (List<ISystemStatusChecker> systemCheckers)

Sets the ISystemStatusCheckers from the configuration for the test.

Parameters
systemCheckers List

split

public Collection<IRemoteTest> split (int shardCountHint)

Alternative version of split() which also provides the shardCount that is attempted to be run. This is useful for some test runner that cannot arbitrarly decide sometimes.

Parameters
shardCountHint int: the attempted shard count.

Returns
Collection<IRemoteTest> a collection of subtests to be executed separately or null if test is not currently shardable

Protected methods

createModuleListeners

protected List<ITestInvocationListener> createModuleListeners ()

Returns the list of ITestInvocationListener applicable to the ModuleListener level. These listeners will be re-used for each module, they will not be re-instantiated so they should not assume an internal state.

Returns
List<ITestInvocationListener>

filterByConfigMetadata

protected boolean filterByConfigMetadata (IConfiguration config, 
                MultiMap<String, String> include, 
                MultiMap<String, String> exclude)

Apply the metadata filter to the config and see if the config should run.

Parameters
config IConfiguration: The IConfiguration being evaluated.

include MultiMap: the metadata include filter

exclude MultiMap: the metadata exclude filter

Returns
boolean True if the module should run, false otherwise.

filterByRunnerType

protected boolean filterByRunnerType (IConfiguration config, 
                Set<String> allowedRunners)

Apply the Runner whitelist filtering, removing any runner that was not whitelisted. If a configuration has several runners, some might be removed and the config will still run.

Parameters
config IConfiguration: The IConfiguration being evaluated.

allowedRunners Set: The current runner whitelist.

Returns
boolean True if the configuration module is allowed to run, false otherwise.

getAbisForBuildTargetArch

protected Set<String> getAbisForBuildTargetArch ()

Return the abis supported by the Host build target architecture. Exposed for testing.

Returns
Set<String>