Merge "getConnectionOwnerUid: add test for b/141603906" am: e8a8d9a26f am: ab361a6fbd

am: 90190f2e14

Change-Id: If1d5335854f076ec3f5b64678c83c879f3429bce
This commit is contained in:
Jeffrey Vander Stoep
2019-10-08 03:39:20 -07:00
committed by android-build-merger
2 changed files with 30 additions and 0 deletions

View File

@@ -897,6 +897,32 @@ public class VpnTest extends InstrumentationTestCase {
assertTrue(mCM.isActiveNetworkMetered());
}
public void testB141603906() throws Exception {
final InetSocketAddress src = new InetSocketAddress(0);
final InetSocketAddress dst = new InetSocketAddress(0);
final int NUM_THREADS = 8;
final int NUM_SOCKETS = 5000;
final Thread[] threads = new Thread[NUM_THREADS];
startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"},
new String[] {"0.0.0.0/0", "::/0"},
"", "", null, null /* underlyingNetworks */, false /* isAlwaysMetered */);
for (int i = 0; i < NUM_THREADS; i++) {
threads[i] = new Thread(() -> {
for (int j = 0; j < NUM_SOCKETS; j++) {
mCM.getConnectionOwnerUid(IPPROTO_TCP, src, dst);
}
});
}
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
stopVpn();
}
private boolean isNetworkMetered(Network network) {
NetworkCapabilities nc = mCM.getNetworkCapabilities(network);
return !nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);

View File

@@ -91,4 +91,8 @@ public class HostsideVpnTests extends HostsideNetworkTestCase {
TEST_PKG + ".VpnTest",
"testAlwaysMeteredVpnWithNonNullUnderlyingNetwork");
}
public void testB141603906() throws Exception {
runDeviceTests(TEST_PKG, TEST_PKG + ".VpnTest", "testB141603906");
}
}