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

Commit 8205588c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "legacy: Replace stub osi with mock osi"

parents 54e7fa0a 487cc591
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -159,6 +159,13 @@ filegroup {
  ],
}

filegroup {
  name: "TestMockOsi",
    srcs: [
      "mock/mock_osi_*.cc",
    ],
}

filegroup {
  name: "TestMockStackAcl",
  srcs: [
+100 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:10
 *
 *  mockcify.pl ver 0.3.0
 */

#include <cstdint>
#include <functional>
#include <map>
#include <string>

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

// Mock include file to share data between tests and mock
#include "test/mock/mock_osi_alarm.h"

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace osi_alarm {

// Function state capture and return values, if needed
struct alarm_cancel alarm_cancel;
struct alarm_cleanup alarm_cleanup;
struct alarm_debug_dump alarm_debug_dump;
struct alarm_free alarm_free;
struct alarm_get_remaining_ms alarm_get_remaining_ms;
struct alarm_is_scheduled alarm_is_scheduled;
struct alarm_new alarm_new;
struct alarm_new_periodic alarm_new_periodic;
struct alarm_set alarm_set;
struct alarm_set_on_mloop alarm_set_on_mloop;

}  // namespace osi_alarm
}  // namespace mock
}  // namespace test

// Mocked functions, if any
void alarm_cancel(alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  test::mock::osi_alarm::alarm_cancel(alarm);
}
void alarm_cleanup(void) {
  mock_function_count_map[__func__]++;
  test::mock::osi_alarm::alarm_cleanup();
}
void alarm_debug_dump(int fd) {
  mock_function_count_map[__func__]++;
  test::mock::osi_alarm::alarm_debug_dump(fd);
}
void alarm_free(alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  test::mock::osi_alarm::alarm_free(alarm);
}
uint64_t alarm_get_remaining_ms(const alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  return test::mock::osi_alarm::alarm_get_remaining_ms(alarm);
}
bool alarm_is_scheduled(const alarm_t* alarm) {
  mock_function_count_map[__func__]++;
  return test::mock::osi_alarm::alarm_is_scheduled(alarm);
}
alarm_t* alarm_new(const char* name) {
  mock_function_count_map[__func__]++;
  return test::mock::osi_alarm::alarm_new(name);
}
alarm_t* alarm_new_periodic(const char* name) {
  mock_function_count_map[__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__]++;
  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__]++;
  test::mock::osi_alarm::alarm_set_on_mloop(alarm, interval_ms, cb, data);
}
// Mocked functions complete
// END mockcify generation
+185 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:10
 *
 *  mockcify.pl ver 0.3.0
 */

#include <cstdint>
#include <functional>
#include <map>
#include <string>

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

// Original included files, if any
// NOTE: Since this is a mock file with mock definitions some number of
//       include files may not be required.  The include-what-you-use
//       still applies, but crafting proper inclusion is out of scope
//       for this effort.  This compilation unit may compile as-is, or
//       may need attention to prune from (or add to ) the inclusion set.
#include <base/cancelable_callback.h>
#include <base/logging.h>
#include <errno.h>
#include <fcntl.h>
#include <hardware/bluetooth.h>
#include <inttypes.h>
#include <malloc.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
#include <time.h>

#include <mutex>

#include "check.h"
#include "internal_include/bt_target.h"
#include "osi/include/alarm.h"
#include "osi/include/allocator.h"
#include "osi/include/fixed_queue.h"
#include "osi/include/list.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/semaphore.h"
#include "osi/include/thread.h"
#include "osi/include/wakelock.h"
#include "stack/include/btu.h"

// Mocked compile conditionals, if any

namespace test {
namespace mock {
namespace osi_alarm {

// Shared state between mocked functions and tests
// Name: alarm_cancel
// Params: alarm_t* alarm
// Return: void
struct alarm_cancel {
  std::function<void(alarm_t* alarm)> body{[](alarm_t* alarm) {}};
  void operator()(alarm_t* alarm) { body(alarm); };
};
extern struct alarm_cancel alarm_cancel;

// Name: alarm_cleanup
// Params: void
// Return: void
struct alarm_cleanup {
  std::function<void(void)> body{[](void) {}};
  void operator()(void) { body(); };
};
extern struct alarm_cleanup alarm_cleanup;

// Name: alarm_debug_dump
// Params: int fd
// Return: void
struct alarm_debug_dump {
  std::function<void(int fd)> body{[](int fd) {}};
  void operator()(int fd) { body(fd); };
};
extern struct alarm_debug_dump alarm_debug_dump;

// Name: alarm_free
// Params: alarm_t* alarm
// Return: void
struct alarm_free {
  std::function<void(alarm_t* alarm)> body{[](alarm_t* alarm) {}};
  void operator()(alarm_t* alarm) { body(alarm); };
};
extern struct alarm_free alarm_free;

// Name: alarm_get_remaining_ms
// Params: const alarm_t* alarm
// Return: uint64_t
struct alarm_get_remaining_ms {
  uint64_t return_value{0};
  std::function<uint64_t(const alarm_t* alarm)> body{
      [this](const alarm_t* alarm) { return return_value; }};
  uint64_t operator()(const alarm_t* alarm) { return body(alarm); };
};
extern struct alarm_get_remaining_ms alarm_get_remaining_ms;

// Name: alarm_is_scheduled
// Params: const alarm_t* alarm
// Return: bool
struct alarm_is_scheduled {
  bool return_value{false};
  std::function<bool(const alarm_t* alarm)> body{
      [this](const alarm_t* alarm) { return return_value; }};
  bool operator()(const alarm_t* alarm) { return body(alarm); };
};
extern struct alarm_is_scheduled alarm_is_scheduled;

// Name: alarm_new
// Params: const char* name
// Return: alarm_t*
struct alarm_new {
  alarm_t* return_value{0};
  std::function<alarm_t*(const char* name)> body{
      [this](const char* name) { return return_value; }};
  alarm_t* operator()(const char* name) { return body(name); };
};
extern struct alarm_new alarm_new;

// Name: alarm_new_periodic
// Params: const char* name
// Return: alarm_t*
struct alarm_new_periodic {
  alarm_t* return_value{0};
  std::function<alarm_t*(const char* name)> body{
      [this](const char* name) { return return_value; }};
  alarm_t* operator()(const char* name) { return body(name); };
};
extern struct alarm_new_periodic alarm_new_periodic;

// Name: alarm_set
// Params: alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb, void* data
// Return: void
struct alarm_set {
  std::function<void(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
                     void* data)>
      body{[](alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
              void* data) {}};
  void operator()(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
                  void* data) {
    body(alarm, interval_ms, cb, data);
  };
};
extern struct alarm_set alarm_set;

// Name: alarm_set_on_mloop
// Params: alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb, void* data
// Return: void
struct alarm_set_on_mloop {
  std::function<void(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
                     void* data)>
      body{[](alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
              void* data) {}};
  void operator()(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
                  void* data) {
    body(alarm, interval_ms, cb, data);
  };
};
extern struct alarm_set_on_mloop alarm_set_on_mloop;

}  // namespace osi_alarm
}  // namespace mock
}  // namespace test

// END mockcify generation
 No newline at end of file
+95 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:8
 *
 *  mockcify.pl ver 0.3.0
 */

#include <cstdint>
#include <functional>
#include <map>
#include <string>

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

// Mock include file to share data between tests and mock
#include "test/mock/mock_osi_allocation_tracker.h"

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace osi_allocation_tracker {

// Function state capture and return values, if needed
struct allocation_tracker_expect_no_allocations
    allocation_tracker_expect_no_allocations;
struct allocation_tracker_init allocation_tracker_init;
struct allocation_tracker_notify_alloc allocation_tracker_notify_alloc;
struct allocation_tracker_notify_free allocation_tracker_notify_free;
struct allocation_tracker_reset allocation_tracker_reset;
struct allocation_tracker_resize_for_canary
    allocation_tracker_resize_for_canary;
struct allocation_tracker_uninit allocation_tracker_uninit;
struct osi_allocator_debug_dump osi_allocator_debug_dump;

}  // namespace osi_allocation_tracker
}  // namespace mock
}  // namespace test

// Mocked functions, if any
size_t allocation_tracker_expect_no_allocations(void) {
  mock_function_count_map[__func__]++;
  return test::mock::osi_allocation_tracker::
      allocation_tracker_expect_no_allocations();
}
void allocation_tracker_init(void) {
  mock_function_count_map[__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__]++;
  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__]++;
  return test::mock::osi_allocation_tracker::allocation_tracker_notify_free(
      allocator_id, ptr);
}
void allocation_tracker_reset(void) {
  mock_function_count_map[__func__]++;
  test::mock::osi_allocation_tracker::allocation_tracker_reset();
}
size_t allocation_tracker_resize_for_canary(size_t size) {
  mock_function_count_map[__func__]++;
  return test::mock::osi_allocation_tracker::
      allocation_tracker_resize_for_canary(size);
}
void allocation_tracker_uninit(void) {
  mock_function_count_map[__func__]++;
  test::mock::osi_allocation_tracker::allocation_tracker_uninit();
}
void osi_allocator_debug_dump(int fd) {
  mock_function_count_map[__func__]++;
  test::mock::osi_allocation_tracker::osi_allocator_debug_dump(fd);
}
// Mocked functions complete
// END mockcify generation
+148 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:8
 *
 *  mockcify.pl ver 0.3.0
 */

#include <cstdint>
#include <functional>
#include <map>
#include <string>

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

// Original included files, if any
// NOTE: Since this is a mock file with mock definitions some number of
//       include files may not be required.  The include-what-you-use
//       still applies, but crafting proper inclusion is out of scope
//       for this effort.  This compilation unit may compile as-is, or
//       may need attention to prune from (or add to ) the inclusion set.
#include <base/logging.h>
#include <stdlib.h>
#include <string.h>

#include <mutex>
#include <unordered_map>

#include "check.h"
#include "osi/include/allocation_tracker.h"
#include "osi/include/allocator.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"

// Mocked compile conditionals, if any

namespace test {
namespace mock {
namespace osi_allocation_tracker {

// Shared state between mocked functions and tests
// Name: allocation_tracker_expect_no_allocations
// Params: void
// Return: size_t
struct allocation_tracker_expect_no_allocations {
  size_t return_value{0};
  std::function<size_t(void)> body{[this](void) { return return_value; }};
  size_t operator()(void) { return body(); };
};
extern struct allocation_tracker_expect_no_allocations
    allocation_tracker_expect_no_allocations;

// Name: allocation_tracker_init
// Params: void
// Return: void
struct allocation_tracker_init {
  std::function<void(void)> body{[](void) {}};
  void operator()(void) { body(); };
};
extern struct allocation_tracker_init allocation_tracker_init;

// Name: allocation_tracker_notify_alloc
// Params: uint8_t allocator_id, void* ptr, size_t requested_size
// Return: void*
struct allocation_tracker_notify_alloc {
  void* return_value{};
  std::function<void*(uint8_t allocator_id, void* ptr, size_t requested_size)>
      body{[this](uint8_t allocator_id, void* ptr, size_t requested_size) {
        return return_value;
      }};
  void* operator()(uint8_t allocator_id, void* ptr, size_t requested_size) {
    return body(allocator_id, ptr, requested_size);
  };
};
extern struct allocation_tracker_notify_alloc allocation_tracker_notify_alloc;

// Name: allocation_tracker_notify_free
// Params:  uint8_t allocator_id, void* ptr
// Return: void*
struct allocation_tracker_notify_free {
  void* return_value{};
  std::function<void*(uint8_t allocator_id, void* ptr)> body{
      [this](uint8_t allocator_id, void* ptr) { return return_value; }};
  void* operator()(uint8_t allocator_id, void* ptr) {
    return body(allocator_id, ptr);
  };
};
extern struct allocation_tracker_notify_free allocation_tracker_notify_free;

// Name: allocation_tracker_reset
// Params: void
// Return: void
struct allocation_tracker_reset {
  std::function<void(void)> body{[](void) {}};
  void operator()(void) { body(); };
};
extern struct allocation_tracker_reset allocation_tracker_reset;

// Name: allocation_tracker_resize_for_canary
// Params: size_t size
// Return: size_t
struct allocation_tracker_resize_for_canary {
  size_t return_value{0};
  std::function<size_t(size_t size)> body{
      [this](size_t size) { return return_value; }};
  size_t operator()(size_t size) { return body(size); };
};
extern struct allocation_tracker_resize_for_canary
    allocation_tracker_resize_for_canary;

// Name: allocation_tracker_uninit
// Params: void
// Return: void
struct allocation_tracker_uninit {
  std::function<void(void)> body{[](void) {}};
  void operator()(void) { body(); };
};
extern struct allocation_tracker_uninit allocation_tracker_uninit;

// Name: osi_allocator_debug_dump
// Params: int fd
// Return: void
struct osi_allocator_debug_dump {
  std::function<void(int fd)> body{[](int fd) {}};
  void operator()(int fd) { body(fd); };
};
extern struct osi_allocator_debug_dump osi_allocator_debug_dump;

}  // namespace osi_allocation_tracker
}  // namespace mock
}  // namespace test

// END mockcify generation
 No newline at end of file
Loading