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

Commit ab3f84bb authored by William Escande's avatar William Escande
Browse files

Mock static initialization order 02

cpp static order initialization is not guarantee.
In order to avoid the mess, we need to have a lazy init schema.
Remove extra declaration of map to the common mock declaration

Bug: 265217208
Test: atest --host
Change-Id: Ic95c034968fa3699f169ce92d727df1012e01789
parent ded3d038
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ cc_test {
        ":OsiCompatSources",
        ":TestCommonLogMsg",
        ":TestCommonMainHandler",
        ":TestCommonMockFunctions",
        ":TestMockBtif",
        ":TestMockDevice",
        ":TestMockMainShim",
@@ -362,6 +363,7 @@ cc_test {
        "packages/modules/Bluetooth/system/osi/include",
    ],
    srcs : [
        ":TestCommonMockFunctions",
        ":TestMockBtif",
        ":TestMockMainShimLeScanning",
        "csis/csis_client.cc",
@@ -412,6 +414,7 @@ cc_test {
        "packages/modules/Bluetooth/system/bta/include",
    ],
    srcs : [
        ":TestCommonMockFunctions",
        ":TestMockBtif",
        "groups/groups_test.cc",
        "groups/groups.cc",
@@ -457,6 +460,7 @@ cc_test {
        "packages/modules/Bluetooth/system/stack/include",
    ],
    srcs : [
        ":TestCommonMockFunctions",
        ":TestMockOsi",
        "gatt/database.cc",
        "gatt/database_builder.cc",
@@ -590,8 +594,9 @@ cc_test {
        "packages/modules/Bluetooth/system/stack/include",
    ],
    srcs : [
        ":TestStubOsi",
        ":TestCommonMockFunctions",
        ":TestMockBtaLeAudioHalVerifier",
        ":TestStubOsi",
        "test/common/bta_gatt_api_mock.cc",
        "test/common/bta_gatt_queue_mock.cc",
        "test/common/btm_api_mock.cc",
@@ -664,8 +669,9 @@ cc_test {
        "packages/modules/Bluetooth/system/stack/include",
    ],
    srcs : [
        ":TestStubOsi",
        ":TestCommonMockFunctions",
        ":TestMockBtaLeAudioHalVerifier",
        ":TestStubOsi",
        "gatt/database.cc",
        "gatt/database_builder.cc",
        "le_audio/client.cc",
@@ -766,6 +772,7 @@ cc_test {
        "le_audio/le_audio_types.cc",
        "le_audio/mock_iso_manager.cc",
        "le_audio/mock_codec_manager.cc",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
    ],
    shared_libs: [
@@ -822,6 +829,7 @@ cc_test {
        "le_audio/mock_iso_manager.cc",
        "test/common/mock_controller.cc",
        "le_audio/mock_codec_manager.cc",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
    ],
    shared_libs: [
+1 −2
Original line number Diff line number Diff line
@@ -29,8 +29,7 @@
#include "csis_types.h"
#include "gatt/database_builder.h"
#include "hardware/bt_gatt_types.h"

std::map<std::string, int> mock_function_count_map;
#include "test/common/mock_functions.h"

namespace bluetooth {
namespace csis {
+1 −2
Original line number Diff line number Diff line
@@ -20,11 +20,10 @@
#include <gtest/gtest.h>

#include "bta_groups.h"
#include "test/common/mock_functions.h"
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"

std::map<std::string, int> mock_function_count_map;

namespace bluetooth {
namespace groups {

+1 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "bta/test/common/mock_controller.h"
#include "device/include/controller.h"
#include "stack/include/btm_iso_api.h"
#include "test/common/mock_functions.h"

using namespace std::chrono_literals;

@@ -54,8 +55,6 @@ using le_audio::LeAudioSourceAudioHalClient;
using le_audio::broadcaster::BigConfig;
using le_audio::broadcaster::BroadcastCodecWrapper;

std::map<std::string, int> mock_function_count_map;

// Disables most likely false-positives from base::SplitString()
extern "C" const char* __asan_default_options() {
  return "detect_container_overflow=0";
+1 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "mock_iso_manager.h"
#include "stack/include/ble_advertiser.h"
#include "state_machine.h"
#include "test/common/mock_functions.h"

using namespace bluetooth::hci::iso_manager;

@@ -37,8 +38,6 @@ using testing::Mock;
using testing::SaveArg;
using testing::Test;

std::map<std::string, int> mock_function_count_map;

// Disables most likely false-positives from base::SplitString()
extern "C" const char* __asan_default_options() {
  return "detect_container_overflow=0";
Loading