From 5f09f8da8c0066846efbdb5719b1829d18c8cc41 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Wed, 23 Feb 2022 04:23:46 +0000 Subject: [PATCH] Add some debugs to diagnose test failure. Bug: 218308105 Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests Change-Id: I096258d8c55cf56478015a655b5f3be19f29ace1 Merged-In: I096258d8c55cf56478015a655b5f3be19f29ace1 --- ...AbstractRestrictBackgroundNetworkTestCase.java | 15 +++++++++------ .../cts/net/hostside/DumpOnFailureRule.java | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java index 1b52ec4896..a7f9157c3b 100644 --- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java +++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java @@ -329,7 +329,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase { + "; sleeping 1s before trying again"); SystemClock.sleep(SECOND_IN_MS); } - fail("App2 is not on background state after " + maxTries + " attempts: " + state ); + fail("App2 (" + mUid + ") is not on background state after " + + maxTries + " attempts: " + state); } protected final void assertForegroundState() throws Exception { @@ -347,7 +348,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase { turnScreenOn(); SystemClock.sleep(SECOND_IN_MS); } - fail("App2 is not on foreground state after " + maxTries + " attempts: " + state ); + fail("App2 (" + mUid + ") is not on foreground state after " + + maxTries + " attempts: " + state); } protected final void assertForegroundServiceState() throws Exception { @@ -364,7 +366,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase { + "; sleeping 1s before trying again"); SystemClock.sleep(SECOND_IN_MS); } - fail("App2 is not on foreground service state after " + maxTries + " attempts: " + state ); + fail("App2 (" + mUid + ") is not on foreground service state after " + + maxTries + " attempts: " + state); } /** @@ -406,8 +409,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase { // Exponential back-off. timeoutMs = Math.min(timeoutMs*2, NETWORK_TIMEOUT_MS); } - fail("Invalid state for expectAvailable=" + expectAvailable + " after " + maxTries - + " attempts.\nLast error: " + error); + fail("Invalid state for " + mUid + "; expectAvailable=" + expectAvailable + " after " + + maxTries + " attempts.\nLast error: " + error); } /** @@ -763,7 +766,7 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase { Log.v(TAG, "app2 receiver is not ready yet; sleeping 1s before polling again"); SystemClock.sleep(SECOND_IN_MS); } - fail("app2 receiver is not ready"); + fail("app2 receiver is not ready in " + mUid); } protected void registerNetworkCallback(final NetworkRequest request, INetworkCallback cb) diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/DumpOnFailureRule.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/DumpOnFailureRule.java index cb0341c0cb..0526a75344 100644 --- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/DumpOnFailureRule.java +++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/DumpOnFailureRule.java @@ -62,6 +62,7 @@ public class DumpOnFailureRule extends OnFailureRule { "dumpsys network_management", "dumpsys usagestats " + TEST_PKG + " " + TEST_APP2_PKG, "dumpsys usagestats appstandby", + "dumpsys netd trafficcontroller", }) { dumpCommandOutput(out, cmd); }