diff options
| author | 2018-01-24 09:02:56 +0000 | |
|---|---|---|
| committer | 2018-01-24 09:02:56 +0000 | |
| commit | eacecc37e8fd3b2157ef2a591cd211dead57bb89 (patch) | |
| tree | 6481a78389698399e54e4cf18cc317ac92eb67a1 /tests | |
| parent | 22734c40b47d50473a16d73311b325ebc0940d81 (diff) | |
| parent | e1aa92f1c1b6488efcbf8112aedb71e4b1aa6a2a (diff) | |
Merge "Add TunnelInterface API and KernelResourceRecords" am: f811dff3bc
am: e1aa92f1c1
Change-Id: If27d78708ce225a900ad78a82d9f323770223808
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/net/java/com/android/server/IpSecServiceTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/net/java/com/android/server/IpSecServiceTest.java b/tests/net/java/com/android/server/IpSecServiceTest.java index a375b600ca60..2c94a601fbf6 100644 --- a/tests/net/java/com/android/server/IpSecServiceTest.java +++ b/tests/net/java/com/android/server/IpSecServiceTest.java @@ -635,4 +635,25 @@ public class IpSecServiceTest { verify(mMockNetd).ipSecSetEncapSocketOwner(argThat(fdMatcher), eq(Os.getuid())); mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId); } + + @Test + public void testReserveNetId() { + int start = mIpSecService.TUN_INTF_NETID_START; + for (int i = 0; i < mIpSecService.TUN_INTF_NETID_RANGE; i++) { + assertEquals(start + i, mIpSecService.reserveNetId()); + } + + // Check that resource exhaustion triggers an exception + try { + mIpSecService.reserveNetId(); + fail("Did not throw error for all netIds reserved"); + } catch (IllegalStateException expected) { + } + + // Now release one and try again + int releasedNetId = + mIpSecService.TUN_INTF_NETID_START + mIpSecService.TUN_INTF_NETID_RANGE / 2; + mIpSecService.releaseNetId(releasedNetId); + assertEquals(releasedNetId, mIpSecService.reserveNetId()); + } } |