aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/tradefed/testtype/SubprocessTfLauncher.java4
-rw-r--r--src/com/android/tradefed/testtype/TfTestLauncher.java3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/com/android/tradefed/testtype/SubprocessTfLauncher.java b/src/com/android/tradefed/testtype/SubprocessTfLauncher.java
index 42cd03baa..2533619f2 100644
--- a/src/com/android/tradefed/testtype/SubprocessTfLauncher.java
+++ b/src/com/android/tradefed/testtype/SubprocessTfLauncher.java
@@ -231,6 +231,7 @@ public abstract class SubprocessTfLauncher
boolean exception = false;
long startTime = 0l;
+ long elapsedTime = -1l;
try {
stdoutFile = FileUtil.createTempFile("stdout_subprocess_", ".log");
stderrFile = FileUtil.createTempFile("stderr_subprocess_", ".log");
@@ -249,8 +250,10 @@ public abstract class SubprocessTfLauncher
startTime = System.currentTimeMillis();
CommandResult result = mRunUtil.runTimedCmd(mMaxTfRunTime, stdout,
stderr, mCmdArgs.toArray(new String[0]));
+ elapsedTime = System.currentTimeMillis() - startTime;
// We possibly allow for a little more time if the thread is still processing events.
if (!eventParser.joinReceiver(EVENT_THREAD_JOIN_TIMEOUT_MS)) {
+ elapsedTime = -1l;
throw new RuntimeException(String.format("Event receiver thread did not complete:"
+ "\n%s", FileUtil.readStringFromFile(stderrFile)));
}
@@ -278,7 +281,6 @@ public abstract class SubprocessTfLauncher
exception = true;
throw new RuntimeException(e);
} finally {
- long elapsedTime = System.currentTimeMillis() - startTime;
StreamUtil.close(stdout);
StreamUtil.close(stderr);
logAndCleanFile(stdoutFile, listener);
diff --git a/src/com/android/tradefed/testtype/TfTestLauncher.java b/src/com/android/tradefed/testtype/TfTestLauncher.java
index f04bd461d..c5cc4eca7 100644
--- a/src/com/android/tradefed/testtype/TfTestLauncher.java
+++ b/src/com/android/tradefed/testtype/TfTestLauncher.java
@@ -309,6 +309,9 @@ public class TfTestLauncher extends SubprocessTfLauncher {
* @param listener the {@link ITestInvocationListener} where to report the metric.
*/
private void reportMetrics(long elapsedTime, ITestInvocationListener listener) {
+ if (elapsedTime == -1l) {
+ return;
+ }
listener.testRunStarted("elapsed-time", 1);
TestIdentifier tid = new TestIdentifier("elapsed-time", "run-elapsed-time");
listener.testStarted(tid);