am 17607b8a: am 4106602e: am 7e84d75c: Merge "resolve merge conflicts of a97c792 to kitkat-cts-dev" into kitkat-cts-dev
* commit '17607b8a36287108099db71b9a15f20d64434203': 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.
|
||||||
@@ -208,26 +207,37 @@ public class TrafficStatsTest extends AndroidTestCase {
|
|||||||
final int minExpectedExtraPackets = 5;
|
final int minExpectedExtraPackets = 5;
|
||||||
|
|
||||||
|
|
||||||
|
// 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,
|
uidTxDeltaPackets + "<=" + packetCount + "+" + packetCount + "+" + maxExpectedExtraPackets + "+" + deltaTxOtherPackets,
|
||||||
uidTxDeltaPackets >= packetCount + minExpectedExtraPackets &&
|
uidTxDeltaPackets >= packetCount + minExpectedExtraPackets &&
|
||||||
uidTxDeltaPackets <= packetCount + packetCount + maxExpectedExtraPackets);
|
uidTxDeltaPackets <= packetCount + packetCount + maxExpectedExtraPackets + deltaTxOtherPackets);
|
||||||
assertTrue("uidrxp: " + uidRxPacketsBefore + " -> " + uidRxPacketsAfter + " delta=" + uidRxDeltaPackets +
|
assertTrue("uidrxp: " + uidRxPacketsBefore + " -> " + uidRxPacketsAfter + " delta=" + uidRxDeltaPackets +
|
||||||
" Wanted: " + uidRxDeltaPackets + ">=" + packetCount + "+" + minExpectedExtraPackets + " && " +
|
" Wanted: " + uidRxDeltaPackets + ">=" + packetCount + "+" + minExpectedExtraPackets + " && " +
|
||||||
uidRxDeltaPackets + "<=" + packetCount + "+" + packetCount + "+" + maxExpectedExtraPackets,
|
uidRxDeltaPackets + "<=" + packetCount + "+" + packetCount + "+" + maxExpectedExtraPackets,
|
||||||
uidRxDeltaPackets >= packetCount + minExpectedExtraPackets &&
|
uidRxDeltaPackets >= packetCount + minExpectedExtraPackets &&
|
||||||
uidRxDeltaPackets <= packetCount + packetCount + maxExpectedExtraPackets);
|
uidRxDeltaPackets <= packetCount + packetCount + maxExpectedExtraPackets + deltaRxOtherPackets);
|
||||||
assertTrue("uidtxb: " + uidTxBytesBefore + " -> " + uidTxBytesAfter + " delta=" + uidTxDeltaBytes +
|
assertTrue("uidtxb: " + uidTxBytesBefore + " -> " + uidTxBytesAfter + " delta=" + uidTxDeltaBytes +
|
||||||
" Wanted: " + uidTxDeltaBytes + ">=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(minExpectedExtraPackets, 0) + " && " +
|
" Wanted: " + uidTxDeltaBytes + ">=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(minExpectedExtraPackets, 0) + " && " +
|
||||||
uidTxDeltaBytes + "<=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets, 0),
|
uidTxDeltaBytes + "<=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets, 0),
|
||||||
uidTxDeltaBytes >= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(minExpectedExtraPackets, 0) &&
|
uidTxDeltaBytes >= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(minExpectedExtraPackets, 0) &&
|
||||||
uidTxDeltaBytes <= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets, 0));
|
uidTxDeltaBytes <= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets + deltaTxOtherPackets, 0));
|
||||||
assertTrue("uidrxb: " + uidRxBytesBefore + " -> " + uidRxBytesAfter + " delta=" + uidRxDeltaBytes +
|
assertTrue("uidrxb: " + uidRxBytesBefore + " -> " + uidRxBytesAfter + " delta=" + uidRxDeltaBytes +
|
||||||
" Wanted: " + uidRxDeltaBytes + ">=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(minExpectedExtraPackets, 0) + " && " +
|
" Wanted: " + uidRxDeltaBytes + ">=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(minExpectedExtraPackets, 0) + " && " +
|
||||||
uidRxDeltaBytes + "<=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets, 0),
|
uidRxDeltaBytes + "<=" + tcpPacketToIpBytes(packetCount, byteCount) + "+" + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets, 0),
|
||||||
uidRxDeltaBytes >= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(minExpectedExtraPackets, 0) &&
|
uidRxDeltaBytes >= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(minExpectedExtraPackets, 0) &&
|
||||||
uidRxDeltaBytes <= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets, 0));
|
uidRxDeltaBytes <= tcpPacketToIpBytes(packetCount, byteCount) + tcpPacketToIpBytes(packetCount + maxExpectedExtraPackets + deltaRxOtherPackets, 0));
|
||||||
|
|
||||||
// Localhost traffic *does* count against total stats.
|
// Localhost traffic *does* count against total stats.
|
||||||
// Fudge by 132 packets of 1500 bytes not related to the test.
|
// Fudge by 132 packets of 1500 bytes not related to the test.
|
||||||
|
|||||||
Reference in New Issue
Block a user