ethernet: add test for updateConfiguration on untracked interface
The automotive team has confirmed that updating IpConfiguration /
NetworkCapabilities should succeed independent of the interface state
(absent, client mode, server mode). This ensures updateConfiguration
works when the interface is absent, and the configuration is applied to
the interface once it gets added.
Test: atest EthernetManagerTest --iterations 10
Bug: 236312641
Change-Id: I6d295bce4575daca2061f46313732a9e4600a2ee
diff --git a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt
index d3f1b13..ff1766e 100644
--- a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt
+++ b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt
@@ -962,4 +962,29 @@
// With the test process UID allowed, binding to a restricted network should be successful.
Socket().use { socket -> updatedNetwork.bindSocket(socket) }
}
+
+ // TODO: consider only having this test in MTS as it makes use of the fact that
+ // setEthernetEnabled(false) untracks all interfaces. This behavior is an implementation detail
+ // and may change in the future.
+ @Test
+ fun testUpdateConfiguration_onUntrackedInterface() {
+ assumeFalse(isAdbOverEthernet())
+ val iface = createInterface()
+ setEthernetEnabled(false)
+
+ // Updating the IpConfiguration and NetworkCapabilities on absent interfaces is a supported
+ // use case.
+ val testCapability = NET_CAPABILITY_TEMPORARILY_NOT_METERED
+ val nc = NetworkCapabilities
+ .Builder(ETH_REQUEST.networkCapabilities)
+ .addCapability(testCapability)
+ .build()
+ updateConfiguration(iface, STATIC_IP_CONFIGURATION, nc).expectResult(iface.name)
+
+ setEthernetEnabled(true)
+ val cb = requestNetwork(ETH_REQUEST)
+ cb.expectAvailable()
+ cb.eventuallyExpectCapabilitiesWith(testCapability)
+ cb.eventuallyExpectLpForStaticConfig(STATIC_IP_CONFIGURATION.staticIpConfiguration)
+ }
}