am b2ff97c6: am 183662b8: am 3c88311f: Merge "resolve merge conflicts of a97c792 to kitkat-cts-dev" into kitkat-cts-dev automerge: 7e84d75 automerge: 9feaaaf
* commit 'b2ff97c6589dd3d3c5e3da5f7c7a69b7a42fb317': Fix CTS android.net package testTrafficStatsForLocalhost seldom fail issue
This commit is contained in:
@@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class TrafficStatsTest extends AndroidTestCase {
|
public class TrafficStatsTest extends AndroidTestCase {
|
||||||
private static final String LOG_TAG = "TrafficStatsTest";
|
private static final String LOG_TAG = "TrafficStatsTest";
|
||||||
|
|
||||||
public void testValidMobileStats() {
|
public void testValidMobileStats() {
|
||||||
// We can't assume a mobile network is even present in this test, so
|
// We can't assume a mobile network is even present in this test, so
|
||||||
// we simply assert that a valid value is returned.
|
// we simply assert that a valid value is returned.
|
||||||
@@ -218,6 +217,17 @@ public class TrafficStatsTest extends AndroidTestCase {
|
|||||||
assertTrue("too many non-localhost packets on the sam UID", deltaTxOtherPackets + deltaTxOtherPackets < 20);
|
assertTrue("too many non-localhost packets on the sam UID", deltaTxOtherPackets + deltaTxOtherPackets < 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some other tests don't cleanup connections correctly.
|
||||||
|
// They have the same UID, so we discount their lingering traffic
|
||||||
|
// which happens only on non-localhost, such as TCP FIN retranmission packets
|
||||||
|
long deltaTxOtherPackets = (totalTxPacketsAfter - totalTxPacketsBefore) - uidTxDeltaPackets;
|
||||||
|
long deltaRxOtherPackets = (totalRxPacketsAfter - totalRxPacketsBefore) - uidRxDeltaPackets;
|
||||||
|
if (deltaTxOtherPackets > 0 || deltaRxOtherPackets > 0) {
|
||||||
|
Log.i(LOG_TAG, "lingering traffic data: " + deltaTxOtherPackets + "/" + deltaRxOtherPackets);
|
||||||
|
// Make sure that not too many non-localhost packets are accounted for
|
||||||
|
assertTrue("too many non-localhost packets on the sam UID", deltaTxOtherPackets + deltaTxOtherPackets < 20);
|
||||||
|
}
|
||||||
|
|
||||||
assertTrue("uidtxp: " + uidTxPacketsBefore + " -> " + uidTxPacketsAfter + " delta=" + uidTxDeltaPackets +
|
assertTrue("uidtxp: " + uidTxPacketsBefore + " -> " + uidTxPacketsAfter + " delta=" + uidTxDeltaPackets +
|
||||||
" Wanted: " + uidTxDeltaPackets + ">=" + packetCount + "+" + minExpectedExtraPackets + " && " +
|
" Wanted: " + uidTxDeltaPackets + ">=" + packetCount + "+" + minExpectedExtraPackets + " && " +
|
||||||
uidTxDeltaPackets + "<=" + packetCount + "+" + packetCount + "+" + maxExpectedExtraPackets + "+" + deltaTxOtherPackets,
|
uidTxDeltaPackets + "<=" + packetCount + "+" + packetCount + "+" + maxExpectedExtraPackets + "+" + deltaTxOtherPackets,
|
||||||
|
|||||||
Reference in New Issue
Block a user