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

Commit 04718d34 authored by William Escande's avatar William Escande
Browse files

Mock static initialization order 17

cpp static order initialization is not guarantee.
In order to avoid the mess, we need to have a lazy init schema.
Replacing all mock incrementation in mock_main*
```
's|mock_function_count_map\[__func__\]++|inc_func_call_count(__func__)|'
```

Bug: 265217208
Test: atest --host
Change-Id: I9943e0b329de1e8d28b7dd919261a86cf4ce9130
parent 94a811d5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -51,11 +51,11 @@ struct bte_main_hci_send bte_main_hci_send;

// Mocked functions, if any
void bte_main_init(void) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::main_bte::bte_main_init();
}
void bte_main_hci_send(BT_HDR* p_msg, uint16_t event) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::main_bte::bte_main_hci_send(p_msg, event);
}

+8 −8
Original line number Diff line number Diff line
@@ -34,15 +34,15 @@
#endif

bool bluetooth::shim::is_gd_l2cap_enabled() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return false;
}
bool bluetooth::shim::is_gd_security_enabled() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return false;
}
bool bluetooth::shim::is_gd_shim_enabled() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return false;
}
namespace test {
@@ -51,22 +51,22 @@ bool bluetooth_shim_is_gd_stack_started_up = false;
}
}  // namespace test
bool bluetooth::shim::is_gd_stack_started_up() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::bluetooth_shim_is_gd_stack_started_up;
}
bool bluetooth::shim::is_gd_link_policy_enabled() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return false;
}
future_t* GeneralShutDown() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return nullptr;
}
future_t* IdleModuleStartUp() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return nullptr;
}
future_t* ShimModuleStartUp() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return nullptr;
}
+1 −1
Original line number Diff line number Diff line
@@ -32,4 +32,4 @@
#define UNUSED_ATTR
#endif

void bluetooth::shim::ACL_Shutdown() { mock_function_count_map[__func__]++; }
void bluetooth::shim::ACL_Shutdown() { inc_func_call_count(__func__); }
+15 −15
Original line number Diff line number Diff line
@@ -37,66 +37,66 @@

void bluetooth::shim::ACL_CreateClassicConnection(
    const RawAddress& raw_address) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_CancelClassicConnection(
    const RawAddress& raw_address) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
bool bluetooth::shim::ACL_AcceptLeConnectionFrom(
    const tBLE_BD_ADDR& legacy_address_with_type, bool is_direct) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return true;
}
void bluetooth::shim::ACL_IgnoreLeConnectionFrom(
    const tBLE_BD_ADDR& legacy_address_with_type) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_ConfigureLePrivacy(bool is_le_privacy_enabled) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_WriteData(uint16_t handle, BT_HDR* p_buf) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_Disconnect(uint16_t handle, bool is_classic,
                                     tHCI_STATUS reason, std::string comment) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_IgnoreAllLeConnections() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_ReadConnectionAddress(const RawAddress& pseudo_addr,
                                                RawAddress& conn_addr,
                                                tBLE_ADDR_TYPE* p_addr_type) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
std::optional<uint8_t> bluetooth::shim::ACL_GetAdvertisingSetConnectedTo(
    const RawAddress& addr) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return std::nullopt;
}
void bluetooth::shim::ACL_AddToAddressResolution(
    const tBLE_BD_ADDR& legacy_address_with_type, const Octet16& peer_irk,
    const Octet16& local_irk) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}

void bluetooth::shim::ACL_RemoveFromAddressResolution(
    const tBLE_BD_ADDR& legacy_address_with_type) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_ClearAddressResolution() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_LeSetDefaultSubrate(uint16_t subrate_min,
                                              uint16_t subrate_max,
                                              uint16_t max_latency,
                                              uint16_t cont_num,
                                              uint16_t sup_tout) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
void bluetooth::shim::ACL_LeSubrateRequest(
    uint16_t hci_handle, uint16_t subrate_min, uint16_t subrate_max,
    uint16_t max_latency, uint16_t cont_num, uint16_t sup_tout) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
+2 −2
Original line number Diff line number Diff line
@@ -33,9 +33,9 @@

ActivityAttributionInterface*
bluetooth::shim::get_activity_attribution_instance() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return nullptr;
}
void bluetooth::shim::init_activity_attribution() {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
}
Loading