コード例 #1
0
    def test_transmit_i_frames(self):
        """
        L2CAP/ERM/BV-01-C [Transmit I-frames]
        """
        self._setup_link_from_cert()
        self.cert_l2cap.turn_on_ertm()

        (dut_channel, cert_channel) = self._open_channel(scid=0x41,
                                                         psm=0x33,
                                                         use_ertm=True)

        dut_channel.send(b'abc')
        assertThat(cert_channel).emits(
            L2capMatchers.IFrame(tx_seq=0, payload=b"abc"))

        # Assemble a sample packet. TODO: Use RawBuilder
        SAMPLE_PACKET = l2cap_packets.CommandRejectNotUnderstoodBuilder(1)

        # todo: verify packet received?
        cert_channel.send_i_frame(tx_seq=0, req_seq=1, payload=SAMPLE_PACKET)

        dut_channel.send(b'abc')
        assertThat(cert_channel).emits(
            L2capMatchers.IFrame(tx_seq=1, payload=b"abc"))

        cert_channel.send_i_frame(tx_seq=1, req_seq=2, payload=SAMPLE_PACKET)

        dut_channel.send(b'abc')
        assertThat(cert_channel).emits(L2capMatchers.PartialData(b"abc"))

        cert_channel.send_i_frame(tx_seq=2, req_seq=3, payload=SAMPLE_PACKET)
コード例 #2
0
    def test_fixed_channel(self):
        self._setup_link_from_cert()

        self.dut.l2cap.RegisterChannel(
            l2cap_facade_pb2.RegisterChannelRequest(channel=2))
        asserts.skip("FIXME: Not working")
        self.dut.l2cap.SendL2capPacket(
            l2cap_facade_pb2.L2capPacket(channel=2, payload=b"123"))

        assertThat(self.cert_channel).emits(L2capMatchers.PartialData(b'123'))
コード例 #3
0
    def test_respond_to_echo_request(self):
        """
        L2CAP/COS/ECH/BV-01-C [Respond to Echo Request]
        Verify that the IUT responds to an echo request.
        """
        self._setup_link_from_cert()
        asserts.skip("is echo without a channel supported?")

        echo_request = l2cap_packets.EchoRequestBuilder(
            100, l2cap_packets.DisconnectionRequestBuilder(1, 2, 3))
        echo_request_l2cap = l2cap_packets.BasicFrameBuilder(1, echo_request)
        self.cert_send_b_frame(echo_request_l2cap)

        assertThat(self.cert_channel).emits(
            L2capMatchers.PartialData(b"\x06\x01\x04\x00\x02\x00\x03\x00"))
コード例 #4
0
    def test_implicitly_request_use_FCS(self):
        """
        L2CAP/FOC/BV-03-C [Lower Tester Implicitly Requests FCS should be Used]
        TODO: Update this test case. What's the difference between this one and test_explicitly_request_use_FCS?
        """
        self._setup_link_from_cert()
        self.cert_l2cap.turn_on_ertm()
        self.cert_l2cap.turn_on_fcs()

        (dut_channel, cert_channel) = self._open_channel(scid=0x41,
                                                         psm=0x33,
                                                         use_ertm=True)

        dut_channel.send(b'abc')
        assertThat(cert_channel).emits(
            L2capMatchers.PartialData(
                b"abc\x4f\xa3"))  # TODO: Use packet parser
コード例 #5
0
    def test_explicitly_request_use_FCS(self):
        """
        L2CAP/FOC/BV-02-C [Lower Tester Explicitly Requests FCS should be Used]
        Verify the IUT will include the FCS in I/S-frames if the Lower Tester explicitly requests that FCS
        should be used.
        """
        self._setup_link_from_cert()
        self.cert_l2cap.turn_on_ertm()
        self.cert_l2cap.turn_on_fcs()

        (dut_channel, cert_channel) = self._open_channel(scid=0x41,
                                                         psm=0x33,
                                                         use_ertm=True)

        dut_channel.send(b'abc')
        assertThat(cert_channel).emits(
            L2capMatchers.PartialData(
                b"abc\x4f\xa3"))  # TODO: Use packet parser