am 489b4312: am 4c48d2ff: Merge "Make operation counts monotonically increase." into ics-mr1 am: dbb59f22db

Original change: undetermined

Change-Id: Id181c8361f35fa9118afd513d91e077c3f0c26c4
This commit is contained in:
Jeff Sharkey
2021-05-31 05:10:12 +00:00
committed by Automerger Merge Worker

View File

@@ -294,6 +294,22 @@ public class NetworkStatsTest extends TestCase {
assertValues(after, 1, TEST_IFACE, 101, SET_DEFAULT, 0xF00D, 128L, 8L, 0L, 0L, 0L);
}
public void testClone() throws Exception {
final NetworkStats original = new NetworkStats(TEST_START, 5)
.addValues(TEST_IFACE, 100, SET_DEFAULT, TAG_NONE, 128L, 8L, 0L, 2L, 20L)
.addValues(TEST_IFACE2, 100, SET_DEFAULT, TAG_NONE, 512L, 32L, 0L, 0L, 0L);
// make clone and mutate original
final NetworkStats clone = original.clone();
original.addValues(TEST_IFACE, 101, SET_DEFAULT, TAG_NONE, 128L, 8L, 0L, 0L, 0L);
assertEquals(3, original.size());
assertEquals(2, clone.size());
assertEquals(128L + 512L + 128L, original.getTotalBytes());
assertEquals(128L + 512L, clone.getTotalBytes());
}
private static void assertValues(NetworkStats stats, int index, String iface, int uid, int set,
int tag, long rxBytes, long rxPackets, long txBytes, long txPackets, long operations) {
final NetworkStats.Entry entry = stats.getValues(index, null);