Commit 39de7a64 by andrewlewis Committed by Tofunmi Adigun-Hameed

Log additional information on test runner timeout

PiperOrigin-RevId: 538437142
(cherry picked from commit 136f323f97bc048d9cc9a6b703b72073aa6132de)
parent 2ca5cefd
......@@ -29,6 +29,7 @@ import androidx.annotation.Nullable;
import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.effect.DebugTraceUtil;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.SystemClock;
import com.google.android.exoplayer2.util.Util;
......@@ -38,6 +39,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
......@@ -351,6 +353,7 @@ public class TransformerAndroidTestRunner {
// Block here until timeout reached or latch is counted down.
if (!countDownLatch.await(timeoutSeconds, SECONDS)) {
logTimeoutDiagnostics();
throw new TimeoutException("Transformer timed out after " + timeoutSeconds + " seconds.");
}
@Nullable Exception unexpectedException = unexpectedExceptionReference.get();
......@@ -450,4 +453,18 @@ public class TransformerAndroidTestRunner {
}
return false;
}
private static void logTimeoutDiagnostics() {
Log.e(TAG, "Effect debug traces at timeout: " + DebugTraceUtil.generateTrace());
Log.e(TAG, "Thread state at timeout:");
Set<Map.Entry<Thread, StackTraceElement[]>> entries = Thread.getAllStackTraces().entrySet();
for (Map.Entry<Thread, StackTraceElement[]> threadAndStackTraceElements : entries) {
Thread thread = threadAndStackTraceElements.getKey();
StackTraceElement[] stackTraceElements = threadAndStackTraceElements.getValue();
Log.e(TAG, "> " + thread + ' ' + thread.getState());
for (StackTraceElement stackTraceElement : stackTraceElements) {
Log.e(TAG, "> " + stackTraceElement);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment