Add CTS to verify RIO min/max prefix length
Add two new test cases to ConnectivityManagerTest:
testAcceptRaRtInfoMinPlen()
testAcceptRaRtInfoMaxPlen()
Bug: 33333670
Test: ConnectivityManagerTest CTS test passes with WIFI on/off
Change-Id: I3c0a6823b6fa75f55f9bb99b59557abeb5b9ac62
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index 22dfd1b..2b10ac2 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -45,12 +45,15 @@
import com.android.internal.telephony.PhoneConstants;
+import java.io.File;
+import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.InetSocketAddress;
import java.util.HashMap;
+import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -74,6 +77,13 @@
"Host: " + TEST_HOST + "\r\n" +
"Connection: keep-alive\r\n\r\n";
+ // Base path for IPv6 sysctls
+ private static final String IPV6_SYSCTL_DIR = "/proc/sys/net/ipv6/conf";
+
+ // Expected values for MIN|MAX_PLEN.
+ private static final int IPV6_WIFI_ACCEPT_RA_RT_INFO_MIN_PLEN = 48;
+ private static final int IPV6_WIFI_ACCEPT_RA_RT_INFO_MAX_PLEN = 64;
+
// Action sent to ConnectivityActionReceiver when a network callback is sent via PendingIntent.
private static final String NETWORK_CALLBACK_ACTION =
"ConnectivityManagerTest.NetworkCallbackAction";
@@ -765,4 +775,23 @@
fail("No exception thrown when restricted network requested.");
} catch (SecurityException expected) {}
}
+
+ private Scanner makeWifiSysctlScanner(String key) throws FileNotFoundException {
+ Network network = ensureWifiConnected();
+ String iface = mCm.getLinkProperties(network).getInterfaceName();
+ String path = IPV6_SYSCTL_DIR + "/" + iface + "/" + key;
+ return new Scanner(new File(path));
+ }
+
+ /** Verify that accept_ra_rt_info_min_plen exists and is set to the expected value */
+ public void testAcceptRaRtInfoMinPlen() throws Exception {
+ Scanner s = makeWifiSysctlScanner("accept_ra_rt_info_min_plen");
+ assertEquals(IPV6_WIFI_ACCEPT_RA_RT_INFO_MIN_PLEN, s.nextInt());
+ }
+
+ /** Verify that accept_ra_rt_info_max_plen exists and is set to the expected value */
+ public void testAcceptRaRtInfoMaxPlen() throws Exception {
+ Scanner s = makeWifiSysctlScanner("accept_ra_rt_info_max_plen");
+ assertEquals(IPV6_WIFI_ACCEPT_RA_RT_INFO_MAX_PLEN, s.nextInt());
+ }
}