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

Commit ede64ad5 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

btm_iso: Improve assert logs

Bug: 150670922
Sponsor: @jpawlowski
Test: compile

Change-Id: Id11302c8aa16d89e5309fb0d3bb1d3ef0ccc79ef
parent f1e3ee9e
Loading
Loading
Loading
Loading
+24 −21
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ struct iso_impl {
    cig_create_cmpl_evt evt;

    LOG_ASSERT(cig_callbacks_ != nullptr) << "Invalid CIG callbacks";
    LOG_ASSERT(len >= 3) << "Invalid packet length.";
    LOG_ASSERT(len >= 3) << "Invalid packet length: " << +len;

    STREAM_TO_UINT8(evt.status, stream);
    STREAM_TO_UINT8(evt.cig_id, stream);
@@ -104,7 +104,7 @@ struct iso_impl {

    if (evt.status == HCI_SUCCESS) {
      LOG_ASSERT(len >= (3) + (cis_cnt * sizeof(uint16_t)))
          << "Invalid CIS count.";
          << "Invalid CIS count: " << +cis_cnt;

      /* Remove entries for the reconfigured CIG */
      if (evt_code == kIsoEventCigOnReconfigureCmpl) {
@@ -138,7 +138,8 @@ struct iso_impl {

  void create_cig(uint8_t cig_id,
                  struct iso_manager::cig_create_params cig_params) {
    LOG_ASSERT(!IsCigKnown(cig_id)) << "Invalid cig - already exists.";
    LOG_ASSERT(!IsCigKnown(cig_id))
        << "Invalid cig - already exists: " << +cig_id;

    btsnd_hcic_set_cig_params(
        cig_id, cig_params.sdu_itv_mtos, cig_params.sdu_itv_stom,
@@ -151,7 +152,7 @@ struct iso_impl {

  void reconfigure_cig(uint8_t cig_id,
                       struct iso_manager::cig_create_params cig_params) {
    LOG_ASSERT(IsCigKnown(cig_id)) << "No such cig";
    LOG_ASSERT(IsCigKnown(cig_id)) << "No such cig: " << +cig_id;

    btsnd_hcic_set_cig_params(
        cig_id, cig_params.sdu_itv_mtos, cig_params.sdu_itv_stom,
@@ -166,7 +167,7 @@ struct iso_impl {
    cig_remove_cmpl_evt evt;

    LOG_ASSERT(cig_callbacks_ != nullptr) << "Invalid CIG callbacks";
    LOG_ASSERT(len == 2) << "Invalid packet length.";
    LOG_ASSERT(len == 2) << "Invalid packet length: " << +len;

    STREAM_TO_UINT8(evt.status, stream);
    STREAM_TO_UINT8(evt.cig_id, stream);
@@ -185,7 +186,7 @@ struct iso_impl {
  }

  void remove_cig(uint8_t cig_id) {
    LOG_ASSERT(IsCigKnown(cig_id)) << "No such cig";
    LOG_ASSERT(IsCigKnown(cig_id)) << "No such cig: " << +cig_id;

    btsnd_hcic_remove_cig(cig_id, base::BindOnce(&iso_impl::on_remove_cig,
                                                 base::Unretained(this)));
@@ -196,7 +197,7 @@ struct iso_impl {
      uint16_t len) {
    uint8_t status;

    LOG_ASSERT(len == 2) << "Invalid packet length: " << len;
    LOG_ASSERT(len == 2) << "Invalid packet length: " << +len;

    STREAM_TO_UINT16(status, stream);

@@ -205,7 +206,8 @@ struct iso_impl {

      if (status != HCI_SUCCESS) {
        auto cis = GetCisIfKnown(cis_param.cis_conn_handle);
        LOG_ASSERT(cis != nullptr) << "No such cis";
        LOG_ASSERT(cis != nullptr)
            << "No such cis: " << +cis_param.cis_conn_handle;

        evt.status = status;
        evt.cis_conn_hdl = cis_param.cis_conn_handle;
@@ -219,7 +221,7 @@ struct iso_impl {
  void establish_cis(struct iso_manager::cis_establish_params conn_params) {
    for (auto& el : conn_params.conn_pairs) {
      auto cis = GetCisIfKnown(el.cis_conn_handle);
      LOG_ASSERT(cis) << "No such cis";
      LOG_ASSERT(cis) << "No such cis: " << +el.cis_conn_handle;
      LOG_ASSERT(!(cis->state_flags &
                   (kStateFlagIsConnected | kStateFlagIsConnecting)))
          << "Already connected or connecting";
@@ -233,7 +235,7 @@ struct iso_impl {

  void disconnect_cis(uint16_t cis_handle, uint8_t reason) {
    auto cis = GetCisIfKnown(cis_handle);
    LOG_ASSERT(cis) << "No such cis";
    LOG_ASSERT(cis) << "No such cis: " << +cis_handle;
    LOG_ASSERT(cis->state_flags & kStateFlagIsConnected ||
               cis->state_flags & kStateFlagIsConnecting)
        << "Not connected";
@@ -314,7 +316,7 @@ struct iso_impl {

  void remove_iso_data_path(uint16_t iso_handle, uint8_t data_path_dir) {
    iso_base* iso = GetIsoIfKnown(iso_handle);
    LOG_ASSERT(iso != nullptr) << "No such iso connection";
    LOG_ASSERT(iso != nullptr) << "No such iso connection: " << +iso_handle;
    LOG_ASSERT((iso->state_flags & kStateFlagHasDataPathSet) ==
               kStateFlagHasDataPathSet)
        << "Data path not set";
@@ -449,14 +451,14 @@ struct iso_impl {
  void process_cis_est_pkt(uint8_t len, uint8_t* data) {
    cis_establish_cmpl_evt evt;

    LOG_ASSERT(len == 28) << "Invalid packet length";
    LOG_ASSERT(len == 28) << "Invalid packet length: " << +len;
    LOG_ASSERT(cig_callbacks_ != nullptr) << "Invalid CIG callbacks";

    STREAM_TO_UINT8(evt.status, data);
    STREAM_TO_UINT16(evt.cis_conn_hdl, data);

    auto cis = GetCisIfKnown(evt.cis_conn_hdl);
    LOG_ASSERT(cis != nullptr) << "No such cis";
    LOG_ASSERT(cis != nullptr) << "No such cis: " << +evt.cis_conn_hdl;

    cis->sync_info.first_sync_ts = bluetooth::common::time_get_os_boottime_us();

@@ -558,7 +560,7 @@ struct iso_impl {
  void process_create_big_cmpl_pkt(uint8_t len, uint8_t* data) {
    struct big_create_cmpl_evt evt;

    LOG_ASSERT(len >= 18) << "Invalid packet length";
    LOG_ASSERT(len >= 18) << "Invalid packet length: " << +len;
    LOG_ASSERT(big_callbacks_ != nullptr) << "Invalid BIG callbacks";

    STREAM_TO_UINT8(evt.status, data);
@@ -576,9 +578,9 @@ struct iso_impl {
    uint8_t num_bis;
    STREAM_TO_UINT8(num_bis, data);

    LOG_ASSERT(num_bis != 0) << "Invalid bis count";
    LOG_ASSERT(num_bis != 0) << "Bis count is 0";
    LOG_ASSERT(len == (18 + num_bis * sizeof(uint16_t)))
        << "Invalid packet length";
        << "Invalid packet length: " << len << ". Number of bis: " << +num_bis;

    uint32_t ts = bluetooth::common::time_get_os_boottime_us();
    for (auto i = 0; i < num_bis; ++i) {
@@ -604,7 +606,7 @@ struct iso_impl {
  void process_terminate_big_cmpl_pkt(uint8_t len, uint8_t* data) {
    struct big_terminate_cmpl_evt evt;

    LOG_ASSERT(len == 2) << "Invalid packet length";
    LOG_ASSERT(len == 2) << "Invalid packet length: " << +len;
    LOG_ASSERT(big_callbacks_ != nullptr) << "Invalid BIG callbacks";

    STREAM_TO_UINT8(evt.big_id, data);
@@ -621,12 +623,13 @@ struct iso_impl {
      }
    }

    LOG_ASSERT(is_known_handle) << "No such big";
    LOG_ASSERT(is_known_handle) << "No such big: " << +evt.big_id;
    big_callbacks_->OnBigEvent(kIsoEventBigOnTerminateCmpl, &evt);
  }

  void create_big(uint8_t big_id, struct big_create_params big_params) {
    LOG_ASSERT(!IsBigKnown(big_id)) << "Invalid big - already exists";
    LOG_ASSERT(!IsBigKnown(big_id))
        << "Invalid big - already exists: " << +big_id;

    last_big_create_req_sdu_itv_ = big_params.sdu_itv;
    btsnd_hcic_create_big(
@@ -637,7 +640,7 @@ struct iso_impl {
  }

  void terminate_big(uint8_t big_id, uint8_t reason) {
    LOG_ASSERT(IsBigKnown(big_id)) << "No such big";
    LOG_ASSERT(IsBigKnown(big_id)) << "No such big: " << +big_id;

    btsnd_hcic_term_big(big_id, reason);
  }
+2 −1
Original line number Diff line number Diff line
@@ -1288,7 +1288,8 @@ TEST_F(IsoManagerDeathTest, CreateBigInvalidResponsePacket) {
          });

  ASSERT_EXIT(IsoManager::GetInstance()->CreateBig(0x01, kDefaultBigParams),
              ::testing::KilledBySignal(SIGABRT), "Invalid bis count");
              ::testing::KilledBySignal(SIGABRT),
              "num_bis != 0. Bis count is 0");
}

TEST_F(IsoManagerDeathTest, CreateBigInvalidResponsePacket2) {