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

Commit 983dcc2e authored by Billy Huang's avatar Billy Huang Committed by Automerger Merge Worker
Browse files

Merge "rfcomm-fuzzer: initialize callback mock" into main am: f236bf4f am: f60087d1

parents 5b081c87 f60087d1
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
#include <base/location.h>
#include <base/location.h>
#include <bluetooth/log.h>
#include <bluetooth/log.h>
#include <fuzzer/FuzzedDataProvider.h>
#include <fuzzer/FuzzedDataProvider.h>
#include <gmock/gmock.h>


#include <cstdint>
#include <cstdint>
#include <iostream>
#include <iostream>
@@ -103,6 +104,15 @@ public:
  FakeBtStack fake_stack;
  FakeBtStack fake_stack;
};
};


class Mocks {
public:
  ::testing::NiceMock<bluetooth::rfcomm::MockRfcommCallback> mock_rfcomm_callback;

  Mocks() { rfcomm_callback = &mock_rfcomm_callback; }

  ~Mocks() { rfcomm_callback = nullptr; }
};

}  // namespace
}  // namespace


static int Cleanup(uint16_t* server_handle) { return RFCOMM_RemoveServer(*server_handle); }
static int Cleanup(uint16_t* server_handle) { return RFCOMM_RemoveServer(*server_handle); }
@@ -198,6 +208,7 @@ static void FuzzAsClient(FuzzedDataProvider* fdp) {


extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  auto fakes = std::make_unique<Fakes>();
  auto fakes = std::make_unique<Fakes>();
  auto mocks = std::make_unique<Mocks>();


  FuzzedDataProvider fdp(data, size);
  FuzzedDataProvider fdp(data, size);