summaryrefslogtreecommitdiff
path: root/tools/rootcanal
diff options
context:
space:
mode:
author Henri Chataing <henrichataing@google.com> 2024-03-15 09:15:13 -0700
committer Henri Chataing <henrichataing@google.com> 2024-03-15 09:15:13 -0700
commitbf720f9668d88b876a192bdc98e4256acfe8d066 (patch)
treee86668b12a149465f5fdd7f2b26bdf0d47f8aca6 /tools/rootcanal
parentc8958243639902b1ce47f6ae891e8bdfa4d96a1c (diff)
RootCanal: Remove potential source of flakiness in LL tests
Timings can cause LL.DDI.ADV.BV_11_C to fail because of reordering of LL pdus Bug: 323271676 Test: atest rootcanal_ll_test Flag: EXEMPT, tool change Change-Id: I0f71bed0e1018231c813e8d6d9c1f46afc13a397
Diffstat (limited to 'tools/rootcanal')
-rw-r--r--tools/rootcanal/py/controller.py48
-rw-r--r--tools/rootcanal/test/LL/DDI/ADV/BV_11_C.py3
2 files changed, 31 insertions, 20 deletions
diff --git a/tools/rootcanal/py/controller.py b/tools/rootcanal/py/controller.py
index b4bbecaac0..be3488cbcb 100644
--- a/tools/rootcanal/py/controller.py
+++ b/tools/rootcanal/py/controller.py
@@ -305,30 +305,40 @@ class ControllerTest(unittest.IsolatedAsyncioTestCase):
async def expect_ll(self,
expected_pdus: typing.Union[list, typing.Union[ll.LinkLayerPacket, type]],
+ ignored_pdus: typing.Union[list, type] = [],
timeout: int = 3) -> ll.LinkLayerPacket:
+ if not isinstance(ignored_pdus, list):
+ ignored_pdus = [ignored_pdus]
+
if not isinstance(expected_pdus, list):
expected_pdus = [expected_pdus]
- packet = await asyncio.wait_for(self.controller.receive_ll(), timeout=timeout)
- pdu = ll.LinkLayerPacket.parse_all(packet)
+ async with asyncio.timeout(timeout):
+ while True:
+ packet = await asyncio.wait_for(self.controller.receive_ll())
+ pdu = ll.LinkLayerPacket.parse_all(packet)
+
+ for ignored_pdu in ignored_pdus:
+ if isinstance(pdu, ignored_pdu):
+ continue
- for expected_pdu in expected_pdus:
- if isinstance(expected_pdu, type) and isinstance(pdu, expected_pdu):
- return pdu
- if isinstance(expected_pdu, ll.LinkLayerPacket) and pdu == expected_pdu:
- return pdu
-
- print("received unexpected pdu:")
- pdu.show()
- print("expected pdus:")
- for expected_pdu in expected_pdus:
- if isinstance(expected_pdu, type):
- print(f"- {expected_pdu.__name__}")
- if isinstance(expected_pdu, ll.LinkLayerPacket):
- print(f"- {expected_pdu.__class__.__name__}")
- expected_pdu.show()
-
- self.assertTrue(False)
+ for expected_pdu in expected_pdus:
+ if isinstance(expected_pdu, type) and isinstance(pdu, expected_pdu):
+ return pdu
+ if isinstance(expected_pdu, ll.LinkLayerPacket) and pdu == expected_pdu:
+ return pdu
+
+ print("received unexpected pdu:")
+ pdu.show()
+ print("expected pdus:")
+ for expected_pdu in expected_pdus:
+ if isinstance(expected_pdu, type):
+ print(f"- {expected_pdu.__name__}")
+ if isinstance(expected_pdu, ll.LinkLayerPacket):
+ print(f"- {expected_pdu.__class__.__name__}")
+ expected_pdu.show()
+
+ self.assertTrue(False)
async def expect_llcp(self,
source_address: hci.Address,
diff --git a/tools/rootcanal/test/LL/DDI/ADV/BV_11_C.py b/tools/rootcanal/test/LL/DDI/ADV/BV_11_C.py
index 51c24bdcc9..0a01918f7d 100644
--- a/tools/rootcanal/test/LL/DDI/ADV/BV_11_C.py
+++ b/tools/rootcanal/test/LL/DDI/ADV/BV_11_C.py
@@ -123,7 +123,8 @@ class Test(ControllerTest):
advertising_address_type=ll.AddressType.PUBLIC,
conn_interval=self.LL_initiator_connInterval,
conn_peripheral_latency=self.LL_initiator_connPeripheralLatency,
- conn_supervision_timeout=self.LL_initiator_connSupervisionTimeout))
+ conn_supervision_timeout=self.LL_initiator_connSupervisionTimeout),
+ ignored_pdus=[ll.LeLegacyAdvertisingPdu])
# 11. Upper Tester receives an HCI_LE_Connection_Complete event from the IUT including the
# parameters sent to the IUT in step 8.