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

Commit 847e82cb authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "gd: pts test L2CAP/COS/CFD/BV-12-C"

parents 9c28536b 2a81ac82
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -183,6 +183,33 @@ class L2capTest(GdFacadeOnlyBaseTestClass):
        self.cert_acl.send(config_request_l2cap.Serialize())
        return True

    def _on_connection_response_configuration_request_with_unknown_options_and_hint(
            self, l2cap_control_view):
        connection_response_view = l2cap_packets.ConnectionResponseView(
            l2cap_control_view)
        sid = connection_response_view.GetIdentifier()
        scid = connection_response_view.GetSourceCid()
        dcid = connection_response_view.GetDestinationCid()
        self.scid_to_dcid[scid] = dcid

        mtu_opt = l2cap_packets.MtuConfigurationOption()
        mtu_opt.mtu = 0x1234
        mtu_opt.is_hint = l2cap_packets.ConfigurationOptionIsHint.OPTION_IS_A_HINT

        options = [mtu_opt]
        config_request = l2cap_packets.ConfigurationRequestBuilder(
            sid + 1, dcid, l2cap_packets.Continuation.END, options)
        config_request_l2cap = l2cap_packets.BasicFrameBuilder(
            1, config_request)

        byte_array = bytearray(config_request_l2cap.Serialize())
        ## Modify configuration option type to be a unknown
        byte_array[12] |= 0x7f
        self.cert.hci_acl_manager.SendAclData(
            acl_manager_facade.AclData(
                handle=self.cert_acl_handle, payload=bytes(byte_array)))
        return True

    def _on_configuration_request_default(self, l2cap_control_view):
        configuration_request = l2cap_packets.ConfigurationRequestView(
            l2cap_control_view)
@@ -455,6 +482,17 @@ class L2capTest(GdFacadeOnlyBaseTestClass):
        assertThat(self.cert_acl).emits(
            L2capMatchers.ConfigurationRequest(), at_least_times=2)

    def test_config_unknown_options_with_hint(self):
        """
        L2CAP/COS/CFD/BV-12-C
        """
        self._setup_link_from_cert()
        self.on_connection_response = self._on_connection_response_configuration_request_with_unknown_options_and_hint

        self._open_channel(signal_id=1, scid=0x41, psm=0x33)

        assertThat(self.cert_acl).emits(L2capMatchers.ConfigurationResponse())

    def test_respond_to_echo_request(self):
        """
        L2CAP/COS/ECH/BV-01-C [Respond to Echo Request]
+9 −6
Original line number Diff line number Diff line
@@ -316,6 +316,7 @@ void ClassicSignallingManager::OnConfigurationRequest(SignalId signal_id, Cid ci
        break;
      }
      default:
        if (option->is_hint_ != ConfigurationOptionIsHint::OPTION_IS_A_HINT) {
          LOG_WARN("Received some unsupported configuration option: %d", static_cast<int>(option->type_));
          auto response =
              ConfigurationResponseBuilder::Create(signal_id.Value(), channel->GetRemoteCid(), is_continuation,
@@ -323,6 +324,8 @@ void ClassicSignallingManager::OnConfigurationRequest(SignalId signal_id, Cid ci
          enqueue_buffer_->Enqueue(std::move(response), handler_);
          return;
        }
        break;
    }
  }

  if (configuration_state.state_ == ChannelConfigurationState::State::WAIT_CONFIG_REQ) {