getConnectionOwnerUid: add test for b/141603906

Test: on Marlin and Blueline run
    cts-tradefed run cts -m CtsHostsideNetworkTests \
    -t com.android.cts.net.HostsideVpnTests#testB141603906
Bug: 141603906
Change-Id: I759bc2295b2060e4575d61718c551d201a6455be
This commit is contained in:
Jeff Vander Stoep
2019-10-01 15:49:42 +02:00
parent 409c0dd705
commit c9068f1b87
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");
}
}