LogSaverResultForwarder

public class LogSaverResultForwarder
extends ResultForwarder implements ILogSaverListener

java.lang.Object
   ↳ com.android.tradefed.result.ResultForwarder
     ↳ com.android.tradefed.result.LogSaverResultForwarder


A ResultForwarder for saving logs with the global file saver.

Summary

Public constructors

LogSaverResultForwarder(ILogSaver logSaver, listeners, IConfiguration config)

Public methods

void invocationEnded(long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

void invocationStarted(IInvocationContext context)

Reports the start of the test invocation.

void logAssociation(String dataName, LogFile logFile)

In some cases, log must be strongly associated with a test cases, but the opportunity to do so on the direct testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) callback is not possible.

static void logFile( listeners, ILogSaver saver, InputStreamSource source, String name, LogDataType type)

Log a final file before completion

static void reportEndHostLog( listeners, ILogSaver saver, String name)

Reports host_log from session in progress.

void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

Also, save the log file with the global ILogSaver and call ILogSaverListener.testLogSaved(String, LogDataType, InputStreamSource, LogFile) for those listeners implementing the ILogSaverListener interface.

void testLogForward(String dataName, LogDataType dataType, InputStreamSource dataStream)

Only forward the testLog instead of saving the log first.

void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

Called when the test log is saved.

If LogSaverResultForwarder is wrap in another one, ensure we forward the testLogSaved callback to the listeners under it.

Public constructors

LogSaverResultForwarder

public LogSaverResultForwarder (ILogSaver logSaver, 
                 listeners, 
                IConfiguration config)

Parameters
logSaver ILogSaver

listeners

config IConfiguration

Public methods

invocationEnded

public void invocationEnded (long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
elapsedTime long: the elapsed time of the invocation in ms

invocationStarted

public void invocationStarted (IInvocationContext context)

Reports the start of the test invocation.

Will be automatically called by the TradeFederation framework. Reporters need to override this method to support multiple devices reporting.

Parameters
context IInvocationContext: information about the invocation

logAssociation

public void logAssociation (String dataName, 
                LogFile logFile)

In some cases, log must be strongly associated with a test cases, but the opportunity to do so on the direct testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) callback is not possible. Thus, this callback allows to provide a strong association explicitly.

Parameters
dataName String: The name of the data

logFile LogFile: the LogFile that was logged before and should be associated with the test case.

logFile

public static void logFile ( listeners, 
                ILogSaver saver, 
                InputStreamSource source, 
                String name, 
                LogDataType type)

Log a final file before completion

Parameters
listeners

saver ILogSaver

source InputStreamSource

name String

type LogDataType

reportEndHostLog

public static void reportEndHostLog ( listeners, 
                ILogSaver saver, 
                String name)

Reports host_log from session in progress.

Parameters
listeners

saver ILogSaver

name String

testLog

public void testLog (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

Must be called before ERROR(/ITestInvocationListener#invocationFailed(Throwable)) or ERROR(/ITestInvocationListener#invocationEnded(long))

The TradeFederation framework will automatically call this method, providing the host log and if applicable, the device logcat.

Also, save the log file with the global ILogSaver and call ILogSaverListener.testLogSaved(String, LogDataType, InputStreamSource, LogFile) for those listeners implementing the ILogSaverListener interface.

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat". Note dataName may not be unique per invocation. ie implementers must be able to handle multiple calls with same dataName

dataType LogDataType: the LogDataType of the data

dataStream InputStreamSource: the InputStreamSource of the data. Implementers should call createInputStream to start reading the data, and ensure to close the resulting InputStream when complete. Callers should ensure the source of the data remains present and accessible until the testLog method completes.

testLogForward

public void testLogForward (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

Only forward the testLog instead of saving the log first.

Parameters
dataName String

dataType LogDataType

dataStream InputStreamSource

testLogSaved

public void testLogSaved (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream, 
                LogFile logFile)

Called when the test log is saved.

Should be used in place of ITestInvocationListener.testLog(String, LogDataType, InputStreamSource).

If LogSaverResultForwarder is wrap in another one, ensure we forward the testLogSaved callback to the listeners under it.

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat". Note dataName may not be unique per invocation. ie implementers must be able to handle multiple calls with same dataName

dataType LogDataType: the LogDataType of the data

dataStream InputStreamSource: the InputStreamSource of the data. Implementers should call createInputStream to start reading the data, and ensure to close the resulting InputStream when complete.

logFile LogFile: the LogFile containing the meta data of the saved file.