summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLucas Lin <lucaslin@google.com>2021-03-12 03:30:32 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-03-12 03:30:32 +0000
commitae7491e2f9c8be7d2fc1771c94efa82440522aa7 (patch)
tree3cd88409580c83ae755d0fff3e1df5f8051957f3 /tests
parent2dafdfb0f8715d290ece550b85e4a5f09f2a22a4 (diff)
parent7d02c648467dfcf35e39be31478cade5a4b86f57 (diff)
Merge changes Ib80f814f,Ic605e489
* changes: Use new API - getIpSecNetIdRange() in IpSecService Add a new API to get the network ID range of IPSec tunnel interface
Diffstat (limited to 'tests')
-rw-r--r--tests/net/java/com/android/server/IpSecServiceTest.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/net/java/com/android/server/IpSecServiceTest.java b/tests/net/java/com/android/server/IpSecServiceTest.java
index f97eabf6366d..6232423b4f9e 100644
--- a/tests/net/java/com/android/server/IpSecServiceTest.java
+++ b/tests/net/java/com/android/server/IpSecServiceTest.java
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.net.ConnectivityManager;
import android.net.INetd;
import android.net.IpSecAlgorithm;
import android.net.IpSecConfig;
@@ -47,6 +48,7 @@ import android.os.Process;
import android.system.ErrnoException;
import android.system.Os;
import android.system.StructStat;
+import android.util.Range;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -647,9 +649,9 @@ public class IpSecServiceTest {
@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());
+ final Range<Integer> netIdRange = ConnectivityManager.getIpSecNetIdRange();
+ for (int netId = netIdRange.getLower(); netId <= netIdRange.getUpper(); netId++) {
+ assertEquals(netId, mIpSecService.reserveNetId());
}
// Check that resource exhaustion triggers an exception
@@ -661,7 +663,7 @@ public class IpSecServiceTest {
// Now release one and try again
int releasedNetId =
- mIpSecService.TUN_INTF_NETID_START + mIpSecService.TUN_INTF_NETID_RANGE / 2;
+ netIdRange.getLower() + (netIdRange.getUpper() - netIdRange.getLower()) / 2;
mIpSecService.releaseNetId(releasedNetId);
assertEquals(releasedNetId, mIpSecService.reserveNetId());
}