GTestResultParser

public class GTestResultParser
extends MultiLineReceiver

java.lang.Object
   ↳ com.android.ddmlib.MultiLineReceiver
     ↳ com.android.tradefed.testtype.GTestResultParser


Parses the 'raw output mode' results of native tests using GTest that run from shell, and informs a ITestInvocationListener of the results.

Sample format of output expected:

 [==========] Running 15 tests from 1 test case.
 [----------] Global test environment set-up.
 [----------] 15 tests from MessageTest
 [ RUN      ] MessageTest.DefaultConstructor
 [       OK ] MessageTest.DefaultConstructor (1 ms)
 [ RUN      ] MessageTest.CopyConstructor
 external/gtest/test/gtest-message_test.cc:67: Failure
 Value of: 5
 Expected: 2
 external/gtest/test/gtest-message_test.cc:68: Failure
 Value of: 1 == 1
 Actual: true
 Expected: false
 [  FAILED  ] MessageTest.CopyConstructor (2 ms)
  ...
 [ RUN      ] MessageTest.DoesNotTakeUpMuchStackSpace
 [       OK ] MessageTest.DoesNotTakeUpMuchStackSpace (0 ms)
 [----------] 15 tests from MessageTest (26 ms total)

 [----------] Global test environment tear-down
 [==========] 15 tests from 1 test case ran. (26 ms total)
 [  PASSED  ] 6 tests.
 [  FAILED  ] 9 tests, listed below:
 [  FAILED  ] MessageTest.CopyConstructor
 [  FAILED  ] MessageTest.ConstructsFromCString
 [  FAILED  ] MessageTest.StreamsCString
 [  FAILED  ] MessageTest.StreamsNullCString
 [  FAILED  ] MessageTest.StreamsString
 [  FAILED  ] MessageTest.StreamsStringWithEmbeddedNUL
 [  FAILED  ] MessageTest.StreamsNULChar
 [  FAILED  ] MessageTest.StreamsInt
 [  FAILED  ] MessageTest.StreamsBasicIoManip
 9 FAILED TESTS
 

where the following tags are used to signal certain events:

 [==========]: the first occurrence indicates a new run started, including the number of tests
                  to be expected in this run
 [ RUN      ]: indicates a new test has started to run; a series of zero or more lines may
                  follow a test start, and will be captured in case of a test failure or error
 [       OK ]: the preceding test has completed successfully, optionally including the time it
                  took to run (in ms)
 [  FAILED  ]: the preceding test has failed, optionally including the time it took to run (in ms)
 [==========]: the preceding test run has completed, optionally including the time it took to run
                  (in ms)
 
All other lines are ignored.

Summary

Public constructors

GTestResultParser(String testRunName, listeners)

Creates the GTestResultParser.

GTestResultParser(String testRunName, listeners, boolean allowRustTestName)

Creates the GTestResultParser.

Public methods

void cancel()

Requests cancellation of test run.

void done()

Called by parent when adb session is complete.

getFailedTests()

Returns a list of tests that failed during the current test run.

boolean getPrependFileName()
boolean isCancelled()

Returns true if test run canceled.

boolean isTestRunIncomplete()

Whether the test run was incomplete or not.

void processNewLines(String[] lines)

void setPrependFileName(boolean prepend)

Protected methods

boolean isUnexpectedTestFound()

Exposed for unit testing.

Public constructors

GTestResultParser

public GTestResultParser (String testRunName, 
                 listeners)

Creates the GTestResultParser.

Parameters
testRunName String: the test run name to provide to ITestLifeCycleReceiver.testRunStarted(String, int)

listeners : informed of test results as the tests are executing

GTestResultParser

public GTestResultParser (String testRunName, 
                 listeners, 
                boolean allowRustTestName)

Creates the GTestResultParser.

Parameters
testRunName String: the test run name to provide to ITestLifeCycleReceiver.testRunStarted(String, int)

listeners : informed of test results as the tests are executing

allowRustTestName boolean: allow test names to not follow the '::' separation pattern

Public methods

cancel

public void cancel ()

Requests cancellation of test run.

done

public void done ()

Called by parent when adb session is complete.

getFailedTests

public  getFailedTests ()

Returns a list of tests that failed during the current test run.

Returns

getPrependFileName

public boolean getPrependFileName ()

Returns
boolean

isCancelled

public boolean isCancelled ()

Returns true if test run canceled.

Returns
boolean

isTestRunIncomplete

public boolean isTestRunIncomplete ()

Whether the test run was incomplete or not.

Returns
boolean true, if the test run was incomplete due to parsing issues or crashes.

processNewLines

public void processNewLines (String[] lines)

Parameters
lines String

setPrependFileName

public void setPrependFileName (boolean prepend)

Parameters
prepend boolean

Protected methods

isUnexpectedTestFound

protected boolean isUnexpectedTestFound ()

Exposed for unit testing.

Returns
boolean