From 2a8b4670a3c7c10ac283d00759cc266f2cfa7ff2 Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Tue, 26 Aug 2025 14:44:58 -0700 Subject: [PATCH] Skip testCallbacks when unrestricted interfaces are present The old assumption check ran the test on devices with unrestricted interfaces which were configured in the overlay. Apparently, this is a common configuration on automotive devices. There are likely other tests that are broken which need to be moved to the new assumption check. Test: TH Flag: EXEMPT mainline Change-Id: I504534920ea2c083a05bf217bec17a084a829184 --- .../src/android/net/cts/EthernetManagerTest.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt index 3b7d588f56..f795905b11 100644 --- a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt +++ b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt @@ -324,6 +324,12 @@ class EthernetManagerTest { val cb = events.poll(NO_CALLBACK_TIMEOUT_MS) assertNull(cb, "Expected no callback but got $cb") } + + fun assumeNoCallback() { + val cb = events.poll(0 /* timeout */) + // Note that assumeNull does not exist. + assumeTrue(cb == null) + } } private class TetheredInterfaceListener : TetheredInterfaceCallback { @@ -617,7 +623,7 @@ class EthernetManagerTest { // check is explicitly *not* using an interface state listener. // Since restricted interfaces cannot be used for tethering, // assumeNoInterfaceForTetheringAvailable() is an okay proxy. - assumeNoInterfaceForTetheringAvailable() + assumeNoUnrestrictedInterfacesAvailable() // If an interface exists when the callback is registered, it is reported on registration. val iface = createInterface() @@ -680,6 +686,15 @@ class EthernetManagerTest { } } + private fun assumeNoUnrestrictedInterfacesAvailable() { + val listener = EthernetStateListener() + addInterfaceStateListener(listener) + + // Force interface state listener callbacks to be processed before proceeding. + setEthernetEnabled(ethernetEnabled) + listener.assumeNoCallback() + } + @Test fun testCallbacks_forServerModeInterfaces() { // do not run this test if an interface that can be used for tethering already exists.