Merge "Add some debugs to diagnose test failure."

This commit is contained in:
Sudheer Shanka
2022-03-01 01:05:01 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 6 deletions

View File

@@ -329,7 +329,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
+ "; sleeping 1s before trying again"); + "; sleeping 1s before trying again");
SystemClock.sleep(SECOND_IN_MS); 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 { protected final void assertForegroundState() throws Exception {
@@ -347,7 +348,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
turnScreenOn(); turnScreenOn();
SystemClock.sleep(SECOND_IN_MS); 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 { protected final void assertForegroundServiceState() throws Exception {
@@ -364,7 +366,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase {
+ "; sleeping 1s before trying again"); + "; sleeping 1s before trying again");
SystemClock.sleep(SECOND_IN_MS); 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. // Exponential back-off.
timeoutMs = Math.min(timeoutMs*2, NETWORK_TIMEOUT_MS); timeoutMs = Math.min(timeoutMs*2, NETWORK_TIMEOUT_MS);
} }
fail("Invalid state for expectAvailable=" + expectAvailable + " after " + maxTries fail("Invalid state for " + mUid + "; expectAvailable=" + expectAvailable + " after "
+ " attempts.\nLast error: " + error); + 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"); Log.v(TAG, "app2 receiver is not ready yet; sleeping 1s before polling again");
SystemClock.sleep(SECOND_IN_MS); 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) protected void registerNetworkCallback(final NetworkRequest request, INetworkCallback cb)

View File

@@ -62,6 +62,7 @@ public class DumpOnFailureRule extends OnFailureRule {
"dumpsys network_management", "dumpsys network_management",
"dumpsys usagestats " + TEST_PKG + " " + TEST_APP2_PKG, "dumpsys usagestats " + TEST_PKG + " " + TEST_APP2_PKG,
"dumpsys usagestats appstandby", "dumpsys usagestats appstandby",
"dumpsys netd trafficcontroller",
}) { }) {
dumpCommandOutput(out, cmd); dumpCommandOutput(out, cmd);
} }