ethernet: wait for the interface listener to be registered
If an interface is created before the interface state listener is
registered with the ethernet service, callbacks can get missed.
Specifically, createInterface() expects a down before an up callback. If
the listener registration executes after the event, the listener only
receives the final state event (up in this case).
This was a common source of flakiness in the EthernetManagerTests.
Test: EthernetManagerTest
Bug: 243120665
Merged-In: Iefccc9318a9ea2f929d34a52b7b275bf7a23f443
Change-Id: Iefccc9318a9ea2f929d34a52b7b275bf7a23f443
(cherry picked from commit ef61c582f5)
This commit is contained in:
parent
88f253679b
commit
83b95f6bab
1 changed files with 6 additions and 0 deletions
|
|
@ -253,6 +253,12 @@ class EthernetManagerTest {
|
|||
assumeTrue(isEthernetSupported())
|
||||
setIncludeTestInterfaces(true)
|
||||
addInterfaceStateListener(ifaceListener)
|
||||
// Handler.post() events may get processed after native fd events, so it is possible that
|
||||
// RTM_NEWLINK (from a subsequent createInterface() call) arrives before the interface state
|
||||
// listener is registered. This affects the callbacks and breaks the tests.
|
||||
// setEthernetEnabled() will always wait on a callback, so it is used as a barrier to ensure
|
||||
// proper listener registration before proceeding.
|
||||
setEthernetEnabled(true)
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
|||
Loading…
Reference in a new issue