TestInvocation

public class TestInvocation
extends Object implements ITestInvocation

java.lang.Object
   ↳ com.android.tradefed.invoker.TestInvocation


Default implementation of ITestInvocation.

Loads major objects based on IConfiguration - retrieves build - prepares target - runs tests - reports results

Summary

Nested classes

enum TestInvocation.Stage

 

Constants

String BATT_TAG

String BUILD_ERROR_BUGREPORT_NAME

String DEVICE_LOG_NAME_PREFIX

String DEVICE_UNRESPONSIVE_BUGREPORT_NAME

String EMULATOR_LOG_NAME_PREFIX

String INVOCATION_ENDED_BUGREPORT_NAME

String TARGET_SETUP_ERROR_BUGREPORT_NAME

String TRADEFED_LOG_NAME

Public constructors

TestInvocation()

Public methods

void cleanUpBuilds(IInvocationContext context, IConfiguration config)

Execute the build_provider clean up step.

void doCleanUp(IInvocationContext context, IConfiguration config, Throwable exception)

Execute the target_preparer and multi_target_preparer cleanUp step.

void doSetup(IInvocationContext context, IConfiguration config, ITestInvocationListener listener)

Execute the target_preparer and multi_target_preparer setUp step.

void doTeardown(IInvocationContext context, IConfiguration config, Throwable exception)

Execute the target_preparer and multi_target_preparer teardown step.

boolean fetchBuild(IInvocationContext context, IConfiguration config, IRescheduler rescheduler, ITestInvocationListener listener)

Execute the build_provider step of the invocation.

static String getDeviceLogName(TestInvocation.Stage stage)
static String getEmulatorLogName(TestInvocation.Stage stage)
void invoke(IInvocationContext context, IConfiguration config, IRescheduler rescheduler, ITestInvocationListener... extraListeners)

Perform the test invocation.

void notifyInvocationStopped()

Notify the TestInvocation that TradeFed has been requested to stop.

boolean shardConfig(IConfiguration config, IInvocationContext context, IRescheduler rescheduler)

Attempt to shard the configuration into sub-configurations, to be re-scheduled to run on multiple resources in parallel.

String toString()

Protected methods

IShardHelper createShardHelper()

Create an return the IShardHelper to be used.

void setExitCode(CommandRunner.ExitCode code, Throwable stack)

Helper to set the exit code.

Constants

BATT_TAG

String BATT_TAG

Constant Value: "[battery level]"

BUILD_ERROR_BUGREPORT_NAME

String BUILD_ERROR_BUGREPORT_NAME

Constant Value: "build_error_bugreport"

DEVICE_LOG_NAME_PREFIX

String DEVICE_LOG_NAME_PREFIX

Constant Value: "device_logcat_"

DEVICE_UNRESPONSIVE_BUGREPORT_NAME

String DEVICE_UNRESPONSIVE_BUGREPORT_NAME

Constant Value: "device_unresponsive_bugreport"

EMULATOR_LOG_NAME_PREFIX

String EMULATOR_LOG_NAME_PREFIX

Constant Value: "emulator_log_"

INVOCATION_ENDED_BUGREPORT_NAME

String INVOCATION_ENDED_BUGREPORT_NAME

Constant Value: "invocation_ended_bugreport"

TARGET_SETUP_ERROR_BUGREPORT_NAME

String TARGET_SETUP_ERROR_BUGREPORT_NAME

Constant Value: "target_setup_error_bugreport"

TRADEFED_LOG_NAME

String TRADEFED_LOG_NAME

Constant Value: "host_log"

Public constructors

TestInvocation

TestInvocation ()

Public methods

cleanUpBuilds

void cleanUpBuilds (IInvocationContext context, 
                IConfiguration config)

Execute the build_provider clean up step. Associated with the build fetching.

Parameters
context IInvocationContext: the IInvocationContext of the invocation.

config IConfiguration: the IConfiguration of this test run.

doCleanUp

void doCleanUp (IInvocationContext context, 
                IConfiguration config, 
                Throwable exception)

Execute the target_preparer and multi_target_preparer cleanUp step. Does the devices clean up.

Parameters
context IInvocationContext: the IInvocationContext of the invocation.

config IConfiguration: the IConfiguration of this test run.

exception Throwable: the original exception thrown by the test running.

doSetup

void doSetup (IInvocationContext context, 
                IConfiguration config, 
                ITestInvocationListener listener)

Execute the target_preparer and multi_target_preparer setUp step. Does all the devices setup required for the test to run.

Parameters
context IInvocationContext: the IInvocationContext of the invocation.

config IConfiguration: the IConfiguration of this test run.

listener ITestInvocationListener: the ITestInvocation to report setup failures.

Throws
TargetSetupError
BuildError
DeviceNotAvailableException

doTeardown

void doTeardown (IInvocationContext context, 
                IConfiguration config, 
                Throwable exception)

Execute the target_preparer and multi_target_preparer teardown step. Does the devices tear down associated with the setup.

Parameters
context IInvocationContext: the IInvocationContext of the invocation.

config IConfiguration: the IConfiguration of this test run.

exception Throwable: the original exception thrown by the test running.

Throws
Throwable

fetchBuild

boolean fetchBuild (IInvocationContext context, 
                IConfiguration config, 
                IRescheduler rescheduler, 
                ITestInvocationListener listener)

Execute the build_provider step of the invocation.

Parameters
context IInvocationContext: the IInvocationContext of the invocation.

config IConfiguration: the IConfiguration of this test run.

rescheduler IRescheduler: the IRescheduler, for rescheduling portions of the invocation for execution on another resource(s)

listener ITestInvocationListener: the ITestInvocation to report build download failures.

Returns
boolean True if we successfully downloaded the build, false otherwise.

Throws
DeviceNotAvailableException

getDeviceLogName

String getDeviceLogName (TestInvocation.Stage stage)

Parameters
stage TestInvocation.Stage

Returns
String

getEmulatorLogName

String getEmulatorLogName (TestInvocation.Stage stage)

Parameters
stage TestInvocation.Stage

Returns
String

invoke

void invoke (IInvocationContext context, 
                IConfiguration config, 
                IRescheduler rescheduler, 
                ITestInvocationListener... extraListeners)

Perform the test invocation.

Parameters
context IInvocationContext: the IInvocationContext to perform tests.

config IConfiguration: the IConfiguration of this test run.

rescheduler IRescheduler: the IRescheduler, for rescheduling portions of the invocation for execution on another resource(s)

extraListeners ITestInvocationListener: ITestInvocationListeners to notify, in addition to those in config

Throws
DeviceNotAvailableException
Throwable

notifyInvocationStopped

void notifyInvocationStopped ()

Notify the TestInvocation that TradeFed has been requested to stop.

shardConfig

boolean shardConfig (IConfiguration config, 
                IInvocationContext context, 
                IRescheduler rescheduler)

Attempt to shard the configuration into sub-configurations, to be re-scheduled to run on multiple resources in parallel.

If a shard count is greater than 1, it will simply create configs for each shard by setting shard indices and reschedule them. If a shard count is not set,it would fallback to shardConfig(IConfiguration, IInvocationContext, IRescheduler).

Parameters
config IConfiguration: the current IConfiguration.

context IInvocationContext: the IInvocationContext holding the info of the tests.

rescheduler IRescheduler: the IRescheduler

Returns
boolean true if test was sharded. Otherwise return false

toString

String toString ()

Returns
String

Protected methods

createShardHelper

IShardHelper createShardHelper ()

Create an return the IShardHelper to be used.

Returns
IShardHelper

setExitCode

void setExitCode (CommandRunner.ExitCode code, 
                Throwable stack)

Helper to set the exit code. Exposed for testing.

Parameters
code CommandRunner.ExitCode

stack Throwable