Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b1dcfc5 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2capTest stability improvement

Manually configure channel.
Remove hacks. Make things more controlled and flexible.

Test: cert/run --host
Bug: 153275282
Change-Id: I01bc20bba116c29e23ee50fbc5bf1c6ea291e386
parent 53724407
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -124,6 +124,18 @@ class L2capCaptures(object):
            packet, CommandCode.CONNECTION_RESPONSE)
        return l2cap_packets.ConnectionResponseView(frame)

    @staticmethod
    def ConfigurationRequest(cid=None):
        return Capture(
            L2capMatchers.ConfigurationRequest(cid),
            L2capCaptures._extract_configuration_request)

    @staticmethod
    def _extract_configuration_request(packet):
        frame = L2capMatchers.control_frame_with_code(
            packet, CommandCode.CONFIGURATION_REQUEST)
        return l2cap_packets.ConfigurationRequestView(frame)

    @staticmethod
    def CreditBasedConnectionRequest(psm):
        return Capture(
+12 −2
Original line number Diff line number Diff line
@@ -122,8 +122,8 @@ class L2capMatchers(object):
        return lambda packet: L2capMatchers._is_matching_configuration_response(packet, result)

    @staticmethod
    def ConfigurationRequest():
        return lambda packet: L2capMatchers._is_control_frame_with_code(packet, CommandCode.CONFIGURATION_REQUEST)
    def ConfigurationRequest(cid=None):
        return lambda packet: L2capMatchers._is_matching_configuration_request_with_cid(packet, cid)

    @staticmethod
    def ConfigurationRequestWithErtm():
@@ -424,6 +424,16 @@ class L2capMatchers(object):
        ) == ConnectionResponseResult.SUCCESS and response.GetDestinationCid(
        ) != 0

    @staticmethod
    def _is_matching_configuration_request_with_cid(packet, cid=None):
        frame = L2capMatchers.control_frame_with_code(
            packet, CommandCode.CONFIGURATION_REQUEST)
        if frame is None:
            return False
        request = l2cap_packets.ConfigurationRequestView(frame)
        dcid = request.GetDestinationCid()
        return cid is None or cid == dcid

    @staticmethod
    def _is_matching_configuration_request_with_ertm(packet):
        frame = L2capMatchers.control_frame_with_code(
+115 −240

File changed.

Preview size limit exceeded, changes collapsed.

+195 −153

File changed.

Preview size limit exceeded, changes collapsed.

+13 −10
Original line number Diff line number Diff line
@@ -100,13 +100,16 @@ class DualL2capTest(GdBaseTestClass):
            psm=psm, scid=our_scid)
        dut_channel = dut_channel_future.get_channel()

        assertThat(self.cert_l2cap.get_control_channel()).emits(
            L2capMatchers.ConfigurationResponse(),
            L2capMatchers.ConfigurationRequest()).inAnyOrder()
        cert_channel.verify_configuration_request_and_respond()
        cert_channel.send_configure_request([])
        cert_channel.verify_configuration_response()

        return (dut_channel, cert_channel)

    def _open_unvalidated_channel(self, signal_id=1, scid=0x0101, psm=0x33):
    def _open_unconfigured_channel_from_cert(self,
                                             signal_id=1,
                                             scid=0x0101,
                                             psm=0x33):

        dut_channel = self.dut_l2cap.register_dynamic_channel(psm)
        cert_channel = self.cert_l2cap.open_channel(signal_id, psm, scid)
@@ -114,13 +117,13 @@ class DualL2capTest(GdBaseTestClass):
        return (dut_channel, cert_channel)

    def _open_channel_from_cert(self, signal_id=1, scid=0x0101, psm=0x33):
        result = self._open_unvalidated_channel(signal_id, scid, psm)
        (dut_channel, cert_channel) = self._open_unconfigured_channel_from_cert(
            signal_id, scid, psm)
        cert_channel.verify_configuration_request_and_respond()
        cert_channel.send_configure_request([])
        cert_channel.verify_configuration_response()

        assertThat(self.cert_l2cap.get_control_channel()).emits(
            L2capMatchers.ConfigurationResponse(),
            L2capMatchers.ConfigurationRequest()).inAnyOrder()

        return result
        return (dut_channel, cert_channel)

    def _open_le_coc_from_cert(self,
                               signal_id=1,