Search in sources :

Example 21 with IpConnectivityEvent

use of com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityEvent in project android_frameworks_base by crdroidandroid.

the class NetdEventListenerServiceTest method testConnectLogging.

@SmallTest
public void testConnectLogging() throws Exception {
    final int OK = 0;
    Thread[] logActions = { // ignored
    connectEventAction(OsConstants.EALREADY, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EALREADY, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.EINPROGRESS, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EINPROGRESS, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.EINPROGRESS, 0, EXAMPLE_IPV6), // valid latencies
    connectEventAction(OK, 110, EXAMPLE_IPV4), connectEventAction(OK, 23, EXAMPLE_IPV4), connectEventAction(OK, 45, EXAMPLE_IPV4), connectEventAction(OK, 56, EXAMPLE_IPV4), connectEventAction(OK, 523, EXAMPLE_IPV6), connectEventAction(OK, 214, EXAMPLE_IPV6), connectEventAction(OK, 67, EXAMPLE_IPV6), // errors
    connectEventAction(OsConstants.EPERM, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EPERM, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EAGAIN, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EACCES, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EACCES, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.EACCES, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.EADDRINUSE, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.ETIMEDOUT, 0, EXAMPLE_IPV4), connectEventAction(OsConstants.ETIMEDOUT, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.ETIMEDOUT, 0, EXAMPLE_IPV6), connectEventAction(OsConstants.ECONNREFUSED, 0, EXAMPLE_IPV4) };
    for (Thread t : logActions) {
        t.start();
    }
    for (Thread t : logActions) {
        t.join();
    }
    List<IpConnectivityEvent> events = new ArrayList<>();
    mNetdEventListenerService.flushStatistics(events);
    IpConnectivityEvent got = events.get(0);
    String want = joinLines("time_ms: 0", "transport: 0", "connect_statistics <", "  connect_count: 12", "  errnos_counters <", "    key: 1", "    value: 2", "  >", "  errnos_counters <", "    key: 11", "    value: 1", "  >", "  errnos_counters <", "    key: 13", "    value: 3", "  >", "  errnos_counters <", "    key: 98", "    value: 1", "  >", "  errnos_counters <", "    key: 110", "    value: 3", "  >", "  errnos_counters <", "    key: 111", "    value: 1", "  >", "  ipv6_addr_count: 6", "  latencies_ms: 23", "  latencies_ms: 45", "  latencies_ms: 56", "  latencies_ms: 67", "  latencies_ms: 110", "  latencies_ms: 214", "  latencies_ms: 523");
    verifyConnectEvent(want, got);
}
Also used : IpConnectivityEvent(com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityEvent) ArrayList(java.util.ArrayList) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

IpConnectivityEvent (com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityEvent)21 ArrayList (java.util.ArrayList)8 ConnectivityMetricsEvent (android.net.ConnectivityMetricsEvent)5 IpConnectivityLog (com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityLog)4 SmallTest (android.test.suitebuilder.annotation.SmallTest)3