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

Commit c917c134 authored by Hansong Zhang's avatar Hansong Zhang Committed by Automerger Merge Worker
Browse files

L2capTest: Fix ERTM Configuration test am: 7495e0eb

Change-Id: Ia3f3b4b292f6522f0a2d345b0cf5f868a61173b4
parents d4f5f808 7495e0eb
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ from bluetooth_packets_python3 import hci_packets
from bluetooth_packets_python3.hci_packets import EventCode
from bluetooth_packets_python3 import l2cap_packets
from bluetooth_packets_python3.l2cap_packets import CommandCode, LeCommandCode
from bluetooth_packets_python3.l2cap_packets import ConfigurationResponseResult
from bluetooth_packets_python3.l2cap_packets import ConnectionResponseResult
from bluetooth_packets_python3.l2cap_packets import InformationRequestInfoType
from bluetooth_packets_python3.l2cap_packets import LeCreditBasedConnectionResponseResult
@@ -117,13 +118,17 @@ class L2capMatchers(object):
        return lambda packet: L2capMatchers._is_matching_connection_response(packet, scid)

    @staticmethod
    def ConfigurationResponse():
        return lambda packet: L2capMatchers._is_control_frame_with_code(packet, CommandCode.CONFIGURATION_RESPONSE)
    def ConfigurationResponse(result=ConfigurationResponseResult.SUCCESS):
        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)

    @staticmethod
    def ConfigurationRequestWithErtm():
        return lambda packet: L2capMatchers._is_matching_configuration_request_with_ertm(packet)

    @staticmethod
    def DisconnectionRequest(scid, dcid):
        return lambda packet: L2capMatchers._is_matching_disconnection_request(packet, scid, dcid)
@@ -415,6 +420,27 @@ class L2capMatchers(object):
        ) == ConnectionResponseResult.SUCCESS and response.GetDestinationCid(
        ) != 0

    @staticmethod
    def _is_matching_configuration_request_with_ertm(packet):
        frame = L2capMatchers.control_frame_with_code(
            packet, CommandCode.CONFIGURATION_REQUEST)
        if frame is None:
            return False
        request = l2cap_packets.ConfigurationRequestView(frame)
        config_bytes = request.GetBytes()
        # TODO(b/153189503): Use packet struct parser.
        return b"\x04\x09\x03" in config_bytes

    @staticmethod
    def _is_matching_configuration_response(
            packet, result=ConfigurationResponseResult.SUCCESS):
        frame = L2capMatchers.control_frame_with_code(
            packet, CommandCode.CONFIGURATION_RESPONSE)
        if frame is None:
            return False
        response = l2cap_packets.ConfigurationResponseView(frame)
        return response.GetResult() == result

    @staticmethod
    def _is_matching_disconnection_request(packet, scid, dcid):
        frame = L2capMatchers.control_frame_with_code(
+9 −23
Original line number Diff line number Diff line
@@ -62,9 +62,6 @@ class L2capTest(GdBaseTestClass):
        self.dut_l2cap.close()
        super().teardown_test()

    def cert_send_b_frame(self, b_frame):
        self.cert_l2cap.send_acl(b_frame)

    def _setup_link_from_cert(self):
        self.dut.neighbor.EnablePageScan(
            neighbor_facade.EnableMsg(enabled=True))
@@ -571,7 +568,7 @@ class L2capTest(GdBaseTestClass):
    @metadata(
        pts_test_id="L2CAP/OFS/BV-06-C",
        pts_test_name="Receiving I-Frames with FCS for ERTM")
    def test_aareceiving_i_frames_with_fcs_for_ertm(self):
    def test_receiving_i_frames_with_fcs_for_ertm(self):
        """
        Verify the IUT can handle I-frames that do contain the FCS.
        """
@@ -1180,11 +1177,8 @@ class L2capTest(GdBaseTestClass):
        self._open_unvalidated_channel(
            scid=0x41, psm=0x33, mode=RetransmissionFlowControlMode.ERTM)

        # TODO: Fix this test. It doesn't work so far with PDL struct

        assertThat(self.cert_l2cap.get_control_channel()).emits(
            L2capMatchers.ConfigurationRequest())
        asserts.skip("Struct not working")
            L2capMatchers.ConfigurationRequestWithErtm())

    @metadata(
        pts_test_id="L2CAP/CMC/BV-02-C",
@@ -1195,22 +1189,14 @@ class L2capTest(GdBaseTestClass):
        Verify the IUT can accept a Configuration Request from the Lower Tester
        containing an F&EC option that specifies Enhanced Retransmission Mode
        """
        asserts.skip("ConfigurationResponseView Not working")
        asserts.skip(
            "This doesn't work. Currently if DUT sends connection request before information response is received, DUT assumes remote doesn't support ERTM, and drops request"
        )
        self._setup_link_from_cert()
        psm = 1
        scid = 0x0101
        self.retransmission_mode = RetransmissionFlowControlMode.ERTM
        self.dut.l2cap.SetDynamicChannel(
            l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                psm=psm, retransmission_mode=self.retransmission_mode))

        open_channel = l2cap_packets.ConnectionRequestBuilder(1, psm, scid)
        open_channel_l2cap = l2cap_packets.BasicFrameBuilder(1, open_channel)
        self.cert_send_b_frame(open_channel_l2cap)

        # TODO: Verify that the type should be ERTM
        assertThat(self.cert_l2cap.get_control_channel()).emits(
            L2capMatchers.ConfigurationResponse())
        self.cert_l2cap.turn_on_ertm()

        self._open_channel_from_dut(
            psm=0x33, mode=RetransmissionFlowControlMode.ERTM)

    @metadata(
        pts_test_id="L2CAP/CMC/BV-12-C",