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

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

L2capTest: Add MTU size test

Test: cert/run --host
Change-Id: I21e98423a970629f19f6952f39cd93342a642b1c
parent b339a64b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ class CertL2cap(Closable):
        self.ertm_option = None
        self.fcs_option = None
        self.fcs_enabled = False
        self.mtu_option = None

        self.config_response_result = l2cap_packets.ConfigurationResponseResult.SUCCESS
        self.config_response_options = []
@@ -228,6 +229,10 @@ class CertL2cap(Closable):
    def disable_fcs(self):
        self.support_fcs = False

    def set_mtu(self, mtu=672):
        self.mtu_option = l2cap_packets.MtuConfigurationOption()
        self.mtu_option.mtu = mtu

    def turn_on_ertm(self, tx_window_size=10, max_transmit=20, mps=1010):
        self.ertm_option = l2cap_packets.RetransmissionAndFlowControlConfigurationOption(
        )
@@ -307,6 +312,8 @@ class CertL2cap(Closable):
            options.append(self.ertm_option)
        if self.fcs_option is not None:
            options.append(self.fcs_option)
        if self.mtu_option is not None:
            options.append(self.mtu_option)

        config_request = l2cap_packets.ConfigurationRequestBuilder(
            sid + 1, dcid, l2cap_packets.Continuation.END, options)
+24 −0
Original line number Diff line number Diff line
@@ -221,6 +221,16 @@ class L2capTest(GdBaseTestClass):
        assertThat(self.cert_l2cap.get_control_channel()).emitsNone(
            L2capMatchers.ConfigurationResponse())

    @metadata(
        pts_test_id="L2CAP/COS/CED/BV-11-C", pts_test_name="Configure MTU size")
    def test_configure_mtu_size(self):
        """
        Verify that the IUT is able to configure the supported MTU size
        """
        self._setup_link_from_cert()
        self.cert_l2cap.set_mtu(672)
        self._open_channel(scid=0x41, psm=0x33)

    @metadata(
        pts_test_id="L2CAP/COS/CFD/BV-01-C", pts_test_name="Continuation Flag")
    def test_continuation_flag(self):
@@ -288,6 +298,20 @@ class L2capTest(GdBaseTestClass):
            L2capMatchers.ConfigurationResponse(),
            L2capMatchers.ConfigurationRequest()).inAnyOrder()

    @metadata(
        pts_test_id="L2CAP/COS/CFD/BV-09-C",
        pts_test_name="Mandatory 48 Byte MTU")
    def test_mandatory_48_byte_mtu(self):
        """
        Verify that the IUT can support mandatory 48 byte MTU
        """
        self._setup_link_from_cert()
        self.cert_l2cap.set_mtu(48)
        (dut_channel, cert_channel) = self._open_channel(scid=0x41, psm=0x33)

        dut_channel.send(b"a" * 44)
        assertThat(cert_channel).emits(L2capMatchers.Data(b"a" * 44))

    @metadata(
        pts_test_id="L2CAP/COS/CFD/BV-12-C",
        pts_test_name="Unknown Option Response")