Merge "Add extra logging when the test fails." into oc-mr1-dev
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 e65db31..5eaf31b 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
@@ -387,10 +387,34 @@
// Exponential back-off.
timeoutMs = Math.min(timeoutMs*2, NETWORK_TIMEOUT_MS);
}
+ dumpAllNetworkRules();
fail("Invalid state for expectAvailable=" + expectAvailable + " after " + maxTries
+ " attempts.\nLast error: " + error);
}
+ private void dumpAllNetworkRules() throws Exception {
+ final String networkManagementDump = runShellCommand(mInstrumentation,
+ "dumpsys network_management").trim();
+ final String networkPolicyDump = runShellCommand(mInstrumentation,
+ "dumpsys netpolicy").trim();
+ TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter('\n');
+ splitter.setString(networkManagementDump);
+ String next;
+ Log.d(TAG, ">>> Begin network_management dump");
+ while (splitter.hasNext()) {
+ next = splitter.next();
+ Log.d(TAG, next);
+ }
+ Log.d(TAG, "<<< End network_management dump");
+ splitter.setString(networkPolicyDump);
+ Log.d(TAG, ">>> Begin netpolicy dump");
+ while (splitter.hasNext()) {
+ next = splitter.next();
+ Log.d(TAG, next);
+ }
+ Log.d(TAG, "<<< End netpolicy dump");
+ }
+
/**
* Checks whether the network is available as expected.
*