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

Commit 94eb812f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I93a12c06,Ifcd63195 into main

* changes:
  mock: Update mock_osi_allocator|stub_osi with OsiObject
  Distribute packet sources to fuzzers
parents 8dae3679 557052be
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -430,6 +430,7 @@ cc_fuzz {
        "BluetoothGeneratedDumpsysDataSchema_h",
    ],
    srcs: [
        ":BluetoothPacketSources",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestFakeOsi",
@@ -483,6 +484,7 @@ cc_fuzz {
        "BluetoothGeneratedDumpsysDataSchema_h",
    ],
    srcs: [
        ":BluetoothPacketSources",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestFakeOsi",
@@ -531,6 +533,7 @@ cc_fuzz {
        "BluetoothGeneratedDumpsysDataSchema_h",
    ],
    srcs: [
        ":BluetoothPacketSources",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestFakeOsi",
@@ -574,6 +577,7 @@ cc_fuzz {
        "BluetoothGeneratedDumpsysDataSchema_h",
    ],
    srcs: [
        ":BluetoothPacketSources",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestFakeOsi",
@@ -621,6 +625,7 @@ cc_fuzz {
        "BluetoothGeneratedDumpsysDataSchema_h",
    ],
    srcs: [
        ":BluetoothPacketSources",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestFakeOsi",
@@ -1370,6 +1375,7 @@ cc_test {
        "packages/modules/Bluetooth/system/gd",
    ],
    srcs: [
        ":BluetoothPacketSources",
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestMockMainShim",
+16 −0
Original line number Diff line number Diff line
@@ -23,10 +23,26 @@
// Mock include file to share data between tests and mock
#include "test/mock/mock_osi_allocator.h"

#include "osi/include/allocator.h"
#include "test/common/mock_functions.h"

// Mocked internal structures, if any

OsiObject::OsiObject(void* ptr) : ptr_(ptr) {}

OsiObject::OsiObject(const void* ptr) : ptr_(const_cast<void*>(ptr)) {}

OsiObject::~OsiObject() {
  if (ptr_ != nullptr) {
    osi_free(ptr_);
  }
}

void* OsiObject::Release() {
  void* ptr = ptr_;
  ptr_ = nullptr;
  return ptr;
}
namespace test {
namespace mock {
namespace osi_allocator {
+16 −0
Original line number Diff line number Diff line
@@ -47,6 +47,22 @@
#define UNUSED_ATTR
#endif

OsiObject::OsiObject(void* ptr) : ptr_(ptr) {}

OsiObject::OsiObject(const void* ptr) : ptr_(const_cast<void*>(ptr)) {}

OsiObject::~OsiObject() {
  if (ptr_ != nullptr) {
    osi_free(ptr_);
  }
}

void* OsiObject::Release() {
  void* ptr = ptr_;
  ptr_ = nullptr;
  return ptr;
}

struct StringComparison {
  bool operator()(char const* lhs, char const* rhs) const {
    return strcmp(lhs, rhs) < 0;