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

Commit 3666924f authored by William Escande's avatar William Escande
Browse files

Mock static initialization order 13

cpp static order initialization is not guarantee.
In order to avoid the mess, we need to have a lazy init schema.
Replacing all mock map in system/device
Add a way to get the number of entry in the mock map

Bug: 265217208
Test: atest --host
Change-Id: I512e3f85ed17d77541358ebcce2ff9f92579d1ec
parent 76bad3aa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ cc_test {
        "packages/modules/Bluetooth/system/device/src",
    ],
    srcs: [
        ":TestCommonMockFunctions",
        ":TestMockOsi",
        "test/device_iot_config_test.cc",
    ],
+490 −491

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ void inc_func_call_count(const char* fn) { _get_func_call_count_map()[fn]++; }

void reset_mock_function_count_map() { _get_func_call_count_map().clear(); }

int get_func_call_size() { return _get_func_call_count_map().size(); }

void dump_mock_function_count_map() {
  LOG_INFO("Mock function count map size:%zu",
           _get_func_call_count_map().size());
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
// Usage is deprecated, use get_func_call_count / inc_func_call_count instead
extern std::map<std::string, int> mock_function_count_map;

int get_func_call_size();

int get_func_call_count(const char* fn);
void inc_func_call_count(const char* fn);