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

Commit f236bf4f authored by Billy Huang's avatar Billy Huang Committed by Gerrit Code Review
Browse files

Merge "rfcomm-fuzzer: initialize callback mock" into main

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

#include <cstdint>
#include <iostream>
@@ -103,6 +104,15 @@ public:
  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

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) {
  auto fakes = std::make_unique<Fakes>();
  auto mocks = std::make_unique<Mocks>();

  FuzzedDataProvider fdp(data, size);