OSDN Git Service

HciMatchers: enforce argument requirement
authorMartin Brabham <optedoblivion@google.com>
Wed, 18 Nov 2020 00:17:03 +0000 (16:17 -0800)
committerMartin Brabham <optedoblivion@google.com>
Fri, 20 Nov 2020 17:32:06 +0000 (09:32 -0800)
If the command complete opcode is not specified then it
will match ANY command complete event which can prove to
be troubles some when getting a series of CommandComplete()
matches.

Bug: 162984360
Tag: #gd-refactor
Test: cert/run --host SecurityTest
Change-Id: Ia42c74c6476fd9d0763afa87ad1f61a243942e27

gd/cert/matchers.py
gd/security/cert/cert_security.py

index a912973..46a690f 100644 (file)
@@ -31,7 +31,7 @@ from bluetooth_packets_python3.l2cap_packets import LeCreditBasedConnectionRespo
 class HciMatchers(object):
 
     @staticmethod
-    def CommandComplete(opcode=None):
+    def CommandComplete(opcode):
         return lambda msg: HciMatchers._is_matching_command_complete(msg.payload, opcode)
 
     @staticmethod
index ef11082..a91c7bb 100644 (file)
@@ -265,7 +265,8 @@ class CertSecurity(PySecurity):
         self._enqueue_hci_command(
             hci_packets.IoCapabilityRequestReplyBuilder(
                 dut_address.decode('utf8'), self._io_caps, oob_data_present, self._auth_reqs), True)
-        assertThat(self._hci_event_stream).emits(HciMatchers.CommandComplete())
+        assertThat(self._hci_event_stream).emits(
+            HciMatchers.CommandComplete(hci_packets.OpCode.IO_CAPABILITY_REQUEST_REPLY))
         logging.info("Cert: Waiting for SIMPLE_PAIRING_COMPLETE")
         ssp_complete_capture = HciCaptures.SimplePairingCompleteCapture()
         assertThat(self._hci_event_stream).emits(ssp_complete_capture)