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 Change-Id: Iefccc9318a9ea2f929d34a52b7b275bf7a23f443
This commit is contained in:
parent
f360e458fc
commit
ef61c582f5
1 changed files with 6 additions and 0 deletions
|
|
@ -310,6 +310,12 @@ class EthernetManagerTest {
|
|||
fun setUp() {
|
||||
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