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

Commit 51d2e635 authored by William Escande's avatar William Escande
Browse files

Mock static initialization order 15

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_osi*
```
's|mock_function_count_map\[__func__\]++|inc_func_call_count(__func__)|'
```

Bug: 265217208
Test: atest --host
Change-Id: I8134688ae85fb2b6273ab5f2e18185557fc168cb
parent f17bbf39
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -53,45 +53,45 @@ struct alarm_set_on_mloop alarm_set_on_mloop;

// Mocked functions, if any
void alarm_cancel(alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_alarm::alarm_cancel(alarm);
}
void alarm_cleanup(void) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_alarm::alarm_cleanup();
}
void alarm_debug_dump(int fd) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_alarm::alarm_debug_dump(fd);
}
void alarm_free(alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_alarm::alarm_free(alarm);
}
uint64_t alarm_get_remaining_ms(const alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_alarm::alarm_get_remaining_ms(alarm);
}
bool alarm_is_scheduled(const alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_alarm::alarm_is_scheduled(alarm);
}
alarm_t* alarm_new(const char* name) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_alarm::alarm_new(name);
}
alarm_t* alarm_new_periodic(const char* name) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_alarm::alarm_new_periodic(name);
}
void alarm_set(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
               void* data) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_alarm::alarm_set(alarm, interval_ms, cb, data);
}
void alarm_set_on_mloop(alarm_t* alarm, uint64_t interval_ms,
                        alarm_callback_t cb, void* data) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_alarm::alarm_set_on_mloop(alarm, interval_ms, cb, data);
}
// Mocked functions complete
+8 −8
Original line number Diff line number Diff line
@@ -53,40 +53,40 @@ struct osi_allocator_debug_dump osi_allocator_debug_dump;

// Mocked functions, if any
size_t allocation_tracker_expect_no_allocations(void) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocation_tracker::
      allocation_tracker_expect_no_allocations();
}
void allocation_tracker_init(void) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_allocation_tracker::allocation_tracker_init();
}
void* allocation_tracker_notify_alloc(uint8_t allocator_id, void* ptr,
                                      size_t requested_size) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocation_tracker::allocation_tracker_notify_alloc(
      allocator_id, ptr, requested_size);
}
void* allocation_tracker_notify_free(uint8_t allocator_id, void* ptr) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocation_tracker::allocation_tracker_notify_free(
      allocator_id, ptr);
}
void allocation_tracker_reset(void) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_allocation_tracker::allocation_tracker_reset();
}
size_t allocation_tracker_resize_for_canary(size_t size) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocation_tracker::
      allocation_tracker_resize_for_canary(size);
}
void allocation_tracker_uninit(void) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_allocation_tracker::allocation_tracker_uninit();
}
void osi_allocator_debug_dump(int fd) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_allocation_tracker::osi_allocator_debug_dump(fd);
}
// Mocked functions complete
+6 −6
Original line number Diff line number Diff line
@@ -49,27 +49,27 @@ struct osi_strndup osi_strndup;

// Mocked functions, if any
void* osi_calloc(size_t size) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocator::osi_calloc(size);
}
void osi_free(void* ptr) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_allocator::osi_free(ptr);
}
void osi_free_and_reset(void** p_ptr) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_allocator::osi_free_and_reset(p_ptr);
}
void* osi_malloc(size_t size) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocator::osi_malloc(size);
}
char* osi_strdup(const char* str) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocator::osi_strdup(str);
}
char* osi_strndup(const char* str, size_t len) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_allocator::osi_strndup(str, len);
}
// Mocked functions complete
+23 −23
Original line number Diff line number Diff line
@@ -66,22 +66,22 @@ struct section_t_Set section_t_Set;

// Mocked functions, if any
std::string checksum_read(const char* filename) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::checksum_read(filename);
}
bool checksum_save(const std::string& checksum, const std::string& filename) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::checksum_save(checksum, filename);
}
bool config_get_bool(const config_t& config, const std::string& section,
                     const std::string& key, bool def_value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_get_bool(config, section, key,
                                                 def_value);
}
int config_get_int(const config_t& config, const std::string& section,
                   const std::string& key, int def_value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_get_int(config, section, key,
                                                def_value);
}
@@ -89,88 +89,88 @@ const std::string* config_get_string(const config_t& config,
                                     const std::string& section,
                                     const std::string& key,
                                     const std::string* def_value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_get_string(config, section, key,
                                                   def_value);
}
uint64_t config_get_uint64(const config_t& config, const std::string& section,
                           const std::string& key, uint64_t def_value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_get_uint64(config, section, key,
                                                   def_value);
}
bool config_has_key(const config_t& config, const std::string& section,
                    const std::string& key) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_has_key(config, section, key);
}
bool config_has_section(const config_t& config, const std::string& section) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_has_section(config, section);
}
std::unique_ptr<config_t> config_new(const char* filename) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_new(filename);
}
std::unique_ptr<config_t> config_new_clone(const config_t& src) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_new_clone(src);
}
std::unique_ptr<config_t> config_new_empty(void) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_new_empty();
}
bool config_remove_key(config_t* config, const std::string& section,
                       const std::string& key) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_remove_key(config, section, key);
}
bool config_remove_section(config_t* config, const std::string& section) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_remove_section(config, section);
}
bool config_save(const config_t& config, const std::string& filename) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_save(config, filename);
}
void config_set_bool(config_t* config, const std::string& section,
                     const std::string& key, bool value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_config::config_set_bool(config, section, key, value);
}
void config_set_int(config_t* config, const std::string& section,
                    const std::string& key, int value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_config::config_set_int(config, section, key, value);
}
void config_set_string(config_t* config, const std::string& section,
                       const std::string& key, const std::string& value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_config::config_set_string(config, section, key, value);
}
void config_set_uint64(config_t* config, const std::string& section,
                       const std::string& key, uint64_t value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_config::config_set_uint64(config, section, key, value);
}
std::list<section_t>::iterator config_t::Find(const std::string& section) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_t_Find(section);
}
bool config_t::Has(const std::string& key) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::config_t_Has(key);
}
std::list<entry_t>::iterator section_t::Find(const std::string& key) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::section_t_Find(key);
}
bool section_t::Has(const std::string& key) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_config::section_t_Has(key);
}
void section_t::Set(std::string key, std::string value) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_config::section_t_Set(key, value);
}
// Mocked functions complete
+18 −18
Original line number Diff line number Diff line
@@ -61,78 +61,78 @@ struct fixed_queue_unregister_dequeue fixed_queue_unregister_dequeue;

// Mocked functions, if any
size_t fixed_queue_capacity(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_capacity(queue);
}
void* fixed_queue_dequeue(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_dequeue(queue);
}
void fixed_queue_enqueue(fixed_queue_t* queue, void* data) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_fixed_queue::fixed_queue_enqueue(queue, data);
}
void fixed_queue_flush(fixed_queue_t* queue, fixed_queue_free_cb free_cb) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_fixed_queue::fixed_queue_flush(queue, free_cb);
}
void fixed_queue_free(fixed_queue_t* queue, fixed_queue_free_cb free_cb) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_fixed_queue::fixed_queue_free(queue, free_cb);
}
int fixed_queue_get_dequeue_fd(const fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_get_dequeue_fd(queue);
}
int fixed_queue_get_enqueue_fd(const fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_get_enqueue_fd(queue);
}
list_t* fixed_queue_get_list(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_get_list(queue);
}
bool fixed_queue_is_empty(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_is_empty(queue);
}
size_t fixed_queue_length(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_length(queue);
}
fixed_queue_t* fixed_queue_new(size_t capacity) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_new(capacity);
}
void fixed_queue_register_dequeue(fixed_queue_t* queue, reactor_t* reactor,
                                  fixed_queue_cb ready_cb, void* context) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_fixed_queue::fixed_queue_register_dequeue(queue, reactor,
                                                            ready_cb, context);
}
void* fixed_queue_try_dequeue(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_try_dequeue(queue);
}
bool fixed_queue_try_enqueue(fixed_queue_t* queue, void* data) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_try_enqueue(queue, data);
}
void* fixed_queue_try_peek_first(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_try_peek_first(queue);
}
void* fixed_queue_try_peek_last(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_try_peek_last(queue);
}
void* fixed_queue_try_remove_from_queue(fixed_queue_t* queue, void* data) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  return test::mock::osi_fixed_queue::fixed_queue_try_remove_from_queue(queue,
                                                                        data);
}
void fixed_queue_unregister_dequeue(fixed_queue_t* queue) {
  mock_function_count_map[__func__]++;
  inc_func_call_count(__func__);
  test::mock::osi_fixed_queue::fixed_queue_unregister_dequeue(queue);
}
// Mocked functions complete
Loading