diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-05-04 12:53:02 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-04 12:53:02 -0700 |
commit | c065a8af1561544f1557e3f5036e45a4be4a6d7e (patch) | |
tree | d9e06e92e784a6b8250f6c027bfd26b65ca670a3 /core/tests | |
parent | 15a5a87e374c26c2502c8b38ca00f80a34f3675f (diff) | |
parent | e8914c36276710de50b347c1e6aecfa45d6a56cd (diff) | |
download | frameworks_base-c065a8af1561544f1557e3f5036e45a4be4a6d7e.zip frameworks_base-c065a8af1561544f1557e3f5036e45a4be4a6d7e.tar.gz frameworks_base-c065a8af1561544f1557e3f5036e45a4be4a6d7e.tar.bz2 |
Merge "Begin collecting xtables iface counters." into jb-dev
Diffstat (limited to 'core/tests')
3 files changed, 16 insertions, 61 deletions
diff --git a/core/tests/coretests/res/raw/net_dev_typical b/core/tests/coretests/res/raw/net_dev_typical deleted file mode 100644 index 290bf03..0000000 --- a/core/tests/coretests/res/raw/net_dev_typical +++ /dev/null @@ -1,8 +0,0 @@ -Inter-| Receive | Transmit - face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed - lo: 8308 116 0 0 0 0 0 0 8308 116 0 0 0 0 0 0 -rmnet0: 1507570 2205 0 0 0 0 0 0 489339 2237 0 0 0 0 0 0 - ifb0: 52454 151 0 151 0 0 0 0 0 0 0 0 0 0 0 0 - ifb1: 52454 151 0 151 0 0 0 0 0 0 0 0 0 0 0 0 - sit0: 0 0 0 0 0 0 0 0 0 0 148 0 0 0 0 0 -ip6tnl0: 0 0 0 0 0 0 0 0 0 0 151 151 0 0 0 0 diff --git a/core/tests/coretests/res/raw/xt_qtaguid_iface_fmt_typical b/core/tests/coretests/res/raw/xt_qtaguid_iface_fmt_typical new file mode 100644 index 0000000..656d5bb --- /dev/null +++ b/core/tests/coretests/res/raw/xt_qtaguid_iface_fmt_typical @@ -0,0 +1,4 @@ +ifname total_skb_rx_bytes total_skb_rx_packets total_skb_tx_bytes total_skb_tx_packets +rmnet2 4968 35 3081 39 +rmnet1 11153922 8051 190226 2468 +rmnet0 6824 16 5692 10 diff --git a/core/tests/coretests/src/com/android/internal/net/NetworkStatsFactoryTest.java b/core/tests/coretests/src/com/android/internal/net/NetworkStatsFactoryTest.java index b994483..d3dd01a 100644 --- a/core/tests/coretests/src/com/android/internal/net/NetworkStatsFactoryTest.java +++ b/core/tests/coretests/src/com/android/internal/net/NetworkStatsFactoryTest.java @@ -81,58 +81,6 @@ public class NetworkStatsFactoryTest extends AndroidTestCase { assertStatsEntry(stats, "rmnet2", 10001, SET_DEFAULT, 0x0, 1125899906842624L, 984L); } - public void testNetworkStatsSummary() throws Exception { - stageFile(R.raw.net_dev_typical, new File(mTestProc, "net/dev")); - - final NetworkStats stats = mFactory.readNetworkStatsSummary(); - assertEquals(6, stats.size()); - assertStatsEntry(stats, "lo", UID_ALL, SET_ALL, TAG_NONE, 8308L, 8308L); - assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 1507570L, 489339L); - assertStatsEntry(stats, "ifb0", UID_ALL, SET_ALL, TAG_NONE, 52454L, 0L); - assertStatsEntry(stats, "ifb1", UID_ALL, SET_ALL, TAG_NONE, 52454L, 0L); - assertStatsEntry(stats, "sit0", UID_ALL, SET_ALL, TAG_NONE, 0L, 0L); - assertStatsEntry(stats, "ip6tnl0", UID_ALL, SET_ALL, TAG_NONE, 0L, 0L); - } - - public void testNetworkStatsSummaryDown() throws Exception { - stageFile(R.raw.net_dev_typical, new File(mTestProc, "net/dev")); - stageLong(1L, new File(mTestProc, "net/xt_qtaguid/iface_stat/wlan0/active")); - stageLong(1024L, new File(mTestProc, "net/xt_qtaguid/iface_stat/wlan0/rx_bytes")); - stageLong(128L, new File(mTestProc, "net/xt_qtaguid/iface_stat/wlan0/rx_packets")); - stageLong(2048L, new File(mTestProc, "net/xt_qtaguid/iface_stat/wlan0/tx_bytes")); - stageLong(256L, new File(mTestProc, "net/xt_qtaguid/iface_stat/wlan0/tx_packets")); - - final NetworkStats stats = mFactory.readNetworkStatsSummary(); - assertEquals(7, stats.size()); - assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 1507570L, 489339L); - assertStatsEntry(stats, "wlan0", UID_ALL, SET_ALL, TAG_NONE, 1024L, 2048L); - } - - public void testNetworkStatsCombined() throws Exception { - stageFile(R.raw.net_dev_typical, new File(mTestProc, "net/dev")); - stageLong(1L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/active")); - stageLong(10L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/rx_bytes")); - stageLong(20L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/rx_packets")); - stageLong(30L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/tx_bytes")); - stageLong(40L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/tx_packets")); - - final NetworkStats stats = mFactory.readNetworkStatsSummary(); - assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 1507570L + 10L, - 2205L + 20L, 489339L + 30L, 2237L + 40L); - } - - public void testNetworkStatsCombinedInactive() throws Exception { - stageFile(R.raw.net_dev_typical, new File(mTestProc, "net/dev")); - stageLong(0L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/active")); - stageLong(10L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/rx_bytes")); - stageLong(20L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/rx_packets")); - stageLong(30L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/tx_bytes")); - stageLong(40L, new File(mTestProc, "net/xt_qtaguid/iface_stat/rmnet0/tx_packets")); - - final NetworkStats stats = mFactory.readNetworkStatsSummary(); - assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 10L, 20L, 30L, 40L); - } - public void testKernelTags() throws Exception { assertEquals(0, kernelToTag("0x0000000000000000")); assertEquals(0x32, kernelToTag("0x0000003200000000")); @@ -159,13 +107,24 @@ public class NetworkStatsFactoryTest extends AndroidTestCase { public void testNetworkStatsSingle() throws Exception { stageFile(R.raw.xt_qtaguid_iface_typical, new File(mTestProc, "net/xt_qtaguid/iface_stat_all")); - final NetworkStats stats = mFactory.readNetworkStatsSummary(); + final NetworkStats stats = mFactory.readNetworkStatsSummaryDev(); assertEquals(6, stats.size()); assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 2112L, 24L, 700L, 10L); assertStatsEntry(stats, "test1", UID_ALL, SET_ALL, TAG_NONE, 6L, 8L, 10L, 12L); assertStatsEntry(stats, "test2", UID_ALL, SET_ALL, TAG_NONE, 1L, 2L, 3L, 4L); } + public void testNetworkStatsXt() throws Exception { + stageFile(R.raw.xt_qtaguid_iface_fmt_typical, + new File(mTestProc, "net/xt_qtaguid/iface_stat_fmt")); + + final NetworkStats stats = mFactory.readNetworkStatsSummaryXt(); + assertEquals(3, stats.size()); + assertStatsEntry(stats, "rmnet0", UID_ALL, SET_ALL, TAG_NONE, 6824L, 16L, 5692L, 10L); + assertStatsEntry(stats, "rmnet1", UID_ALL, SET_ALL, TAG_NONE, 11153922L, 8051L, 190226L, 2468L); + assertStatsEntry(stats, "rmnet2", UID_ALL, SET_ALL, TAG_NONE, 4968L, 35L, 3081L, 39L); + } + /** * Copy a {@link Resources#openRawResource(int)} into {@link File} for * testing purposes. |