CtsTestLauncher

public class CtsTestLauncher
extends Object implements IBuildReceiver, IConfigurationReceiver, IDeviceTest, IInvocationContextReceiver, IMetricCollectorReceiver, IRemoteTest, IShardableTest

java.lang.Object
   ↳ com.google.android.tradefed.testtype.CtsTestLauncher


A IRemoteTest for running tests against a separate CTS installation.

Launches an external java process to run the tests. Used for running a specific downloaded version of CTS and its configuration It will use the current version of tradefed that launch it to complete missing jars

Summary

Public constructors

CtsTestLauncher()
CtsTestLauncher(int shardCount, int shardIndex)

Public methods

String buildClasspath()

Creates the classpath used by the sub process to run CTS

List<String> buildJavaCmd(String classpath)

Creates the java command line that will be run in a sub process.

String getConfigName()
ITestDevice getDevice()

Get the device under test.

CommandResult getResult()
void run(TestInformation testInfo, ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void setBuild(IBuildInfo buildInfo)

void setConfigName(String config)
void setConfiguration(IConfiguration configuration)

Injects the IConfiguration in use.

void setCtsVersion(int version)
void setDevice(ITestDevice device)

Inject the device under test.

void setInvocationContext(IInvocationContext invocationContext)
void setMetricCollectors(List<IMetricCollector> collectors)

Sets the list of IMetricCollectors defined for the test run.

Collection<IRemoteTest> split(int shardCountHint)

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

Protected methods

IRunUtil getRunUtil()
String getSystemJava()
void setRunAsRoot(boolean runAsRoot)

Public constructors

CtsTestLauncher

public CtsTestLauncher ()

CtsTestLauncher

public CtsTestLauncher (int shardCount, 
                int shardIndex)

Parameters
shardCount int

shardIndex int

Public methods

buildClasspath

public String buildClasspath ()

Creates the classpath used by the sub process to run CTS

Returns
String A String with the full classpath.

Throws
IOException

buildJavaCmd

public List<String> buildJavaCmd (String classpath)

Creates the java command line that will be run in a sub process.

Parameters
classpath String: java classpath to the jar files requires for CTS/XTS to run

Returns
List<String> An ArrayList with the java command line and parameters.

Throws
DeviceNotAvailableException

getConfigName

public String getConfigName ()

Returns
String

getDevice

public ITestDevice getDevice ()

Get the device under test.

Returns
ITestDevice the ITestDevice

getResult

public CommandResult getResult ()

Returns
CommandResult

run

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
testInfo TestInformation: The TestInformation object containing useful information to run tests.

listener ITestInvocationListener: the ITestInvocationListener of test results

Throws
DeviceNotAvailableException

setBuild

public void setBuild (IBuildInfo buildInfo)

Parameters
buildInfo IBuildInfo

setConfigName

public void setConfigName (String config)

Parameters
config String

setConfiguration

public void setConfiguration (IConfiguration configuration)

Injects the IConfiguration in use.

Parameters
configuration IConfiguration

setCtsVersion

public void setCtsVersion (int version)

Parameters
version int

setDevice

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device ITestDevice: the ITestDevice to use

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

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 arbitrarily 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

getRunUtil

protected IRunUtil getRunUtil ()

Returns
IRunUtil

getSystemJava

protected String getSystemJava ()

Returns
String

setRunAsRoot

protected void setRunAsRoot (boolean runAsRoot)

Parameters
runAsRoot boolean