to top
public class

GTest

extends Object
implements IDeviceTest IRemoteTest ITestFilterReceiver IRuntimeHintProvider @OptionClass(alias = "gtest")
java.lang.Object
   ↳ com.android.tradefed.testtype.GTest

Class Overview

A Test that runs a native test package on given device.

Summary

Constants
String DEFAULT_NATIVETEST_PATH
Fields
private List<String> mAfterTestCmd @Option(name = "after-test-cmd", description = "adb shell command(s) to run after GTest.")
private List<String> mBeforeTestCmd @Option(name = "before-test-cmd", description = "adb shell command(s) to run before GTest.")
private List<String> mExcludeFilters @Option(name = "exclude-filter", description = "The GTest-based negative filter of the test names to run.")
private List<String> mGTestFlags @Option(name = "native-test-flag", description = "Additional flag values to pass to the native test\'s shell command. Flags should be complete, including any necessary dashes: \"--flag=value\"")
private List<String> mIncludeFilters @Option(name = "include-filter", description = "The GTest-based positive filter of the test names to run.")
private String mLdLibraryPath @Option(name = "ld-library-path", description = "LD_LIBRARY_PATH value to include in the GTest execution command.")
private int mMaxTestTimeMs @Option(name = "native-test-timeout", description = "The max time in ms for a gtest to run. Test run will be aborted if any test takes longer.")
private String mNativeTestDevicePath @Option(name = "native-test-device-path", description = "The path on the device where native tests are located.")
private boolean mPrependFileName @Option(name = "prepend-filename", description = "Prepend filename as part of the classname for the tests.")
private long mRuntimeHint @Option(name = "runtime-hint", isTimeVal = true, description = "The hint about the test\'s runtime.")
private boolean mSendCoverage @Option(name = "send-coverage", description = "Send coverage target info to test listeners.")
private String mTestModule @Option(name = "module-name", description = "The name of the native test module to run.")
private String mTestNameNegativeFilter @Option(name = "negative-testname-filter", description = "The GTest-based negative filter of the test name to run.")
private String mTestNamePositiveFilter @Option(name = "positive-testname-filter", description = "The GTest-based positive filter of the test name to run.")
Public Constructors
GTest()
Public Methods
void addAllExcludeFilters(List<String> filters)
Adds the List of filters of which tests to exclude.
void addAllIncludeFilters(List<String> filters)
Adds the List of filters of which tests to include.
void addExcludeFilter(String filter)
Adds a filter of which tests to exclude.
void addIncludeFilter(String filter)
Adds a filter of which tests to include.
ITestDevice getDevice()
Get the device under test.
String getModuleName(String moduleName)
Get the Android native test module to run.
boolean getRunDisabledTests()
Get whether GTest should run disabled tests.
long getRuntimeHint()
Return the expected runtime of the test in milliseconds.
void run(ITestInvocationListener listener)
Runs the tests, and reports result to the listener.
void setDevice(ITestDevice device)
Inject the device under test.
void setModuleName(String moduleName)
Set the Android native test module to run.
void setRunDisabled(boolean runDisabled)
Set whether GTest should run disabled tests.
Protected Methods
String getGTestCmdLine(String fullPath, String flags)
Helper method to build the gtest command to run.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.testtype.IDeviceTest
From interface com.android.tradefed.testtype.IRemoteTest
From interface com.android.tradefed.testtype.ITestFilterReceiver
From interface com.android.tradefed.testtype.IRuntimeHintProvider

Constants

static final String DEFAULT_NATIVETEST_PATH

Constant Value: "/data/nativetest"

Fields

private List<String> mAfterTestCmd

private List<String> mBeforeTestCmd

private List<String> mExcludeFilters

private List<String> mGTestFlags

private List<String> mIncludeFilters

private String mLdLibraryPath

private int mMaxTestTimeMs

private String mNativeTestDevicePath

private boolean mPrependFileName

private long mRuntimeHint

private boolean mSendCoverage

private String mTestModule

private String mTestNameNegativeFilter

private String mTestNamePositiveFilter

Public Constructors

public GTest ()

Public Methods

public void addAllExcludeFilters (List<String> filters)

Adds the List of filters of which tests to exclude.

Parameters
filters List

public void addAllIncludeFilters (List<String> filters)

Adds the List of filters of which tests to include.

Parameters
filters List

public void addExcludeFilter (String filter)

Adds a filter of which tests to exclude.

Parameters
filter String

public void addIncludeFilter (String filter)

Adds a filter of which tests to include.

Parameters
filter String

public ITestDevice getDevice ()

Get the device under test.

Returns
ITestDevice the ITestDevice

public String getModuleName (String moduleName)

Get the Android native test module to run.

Parameters
moduleName String
Returns
String the name of the native test module to run, or null if not set

public boolean getRunDisabledTests ()

Get whether GTest should run disabled tests.

Returns
boolean True if disabled tests should be run, false otherwise

public long getRuntimeHint ()

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

Returns
long

public void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results
Throws
DeviceNotAvailableException

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device ITestDevice: the ITestDevice to use

public void setModuleName (String moduleName)

Set the Android native test module to run.

Parameters
moduleName String: The name of the native test module to run

public void setRunDisabled (boolean runDisabled)

Set whether GTest should run disabled tests.

Parameters
runDisabled boolean

Protected Methods

protected String getGTestCmdLine (String fullPath, String flags)

Helper method to build the gtest command to run.

Parameters
fullPath String: absolute file system path to gtest binary on device
flags String: gtest execution flags
Returns
String the shell command line to run for the gtest