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

Commit 1e3d186f authored by Qasim Javed's avatar Qasim Javed Committed by Cherrypicker Worker
Browse files

Separate out fake timer.

We need fake timers for unit tests. Fuzz tests also use fake timers.
This CL separates out fake timers from fuzz testing code so that they
can be used independently.

Bug: 243662087
Tag: #gd-refactor
Test: gd/fuzz/run --host acl_manager

Change-Id: I83b0d80ee71df24c435b411cab3ff7375fe4ba86
(cherry picked from commit 107f632a)
Merged-In: I83b0d80ee71df24c435b411cab3ff7375fe4ba86
parent 900f9124
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -228,10 +228,11 @@ cc_library {
        "libbluetooth_gd_defaults",
        "libbluetooth_gd_defaults",
    ],
    ],
    srcs: [
    srcs: [
        ":BluetoothOsSources_fuzz",
        ":BluetoothOsSources_fake_timer",
    ],
    ],
    cflags: [
    cflags: [
        "-DFUZZ_TARGET",
        "-DFUZZ_TARGET",
        "-DUSE_FAKE_TIMERS",
    ],
    ],
}
}


@@ -489,6 +490,7 @@ cc_defaults {
    ],
    ],
    cflags: [
    cflags: [
        "-DFUZZ_TARGET",
        "-DFUZZ_TARGET",
        "-DUSE_FAKE_TIMERS",
    ],
    ],
    target: {
    target: {
        android: {
        android: {
+4 −4
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@
#include "hci/fuzz/fuzz_hci_layer.h"
#include "hci/fuzz/fuzz_hci_layer.h"
#include "hci/hci_layer.h"
#include "hci/hci_layer.h"
#include "module.h"
#include "module.h"
#include "os/fuzz/fake_timerfd.h"
#include "os/fake_timer/fake_timerfd.h"
#include "os/log.h"
#include "os/log.h"


#include <fuzzer/FuzzedDataProvider.h>
#include <fuzzer/FuzzedDataProvider.h>
@@ -31,9 +31,9 @@ using bluetooth::fuzz::GetArbitraryBytes;
using bluetooth::hci::AclManager;
using bluetooth::hci::AclManager;
using bluetooth::hci::HciLayer;
using bluetooth::hci::HciLayer;
using bluetooth::hci::fuzz::FuzzHciLayer;
using bluetooth::hci::fuzz::FuzzHciLayer;
using bluetooth::os::fuzz::fake_timerfd_advance;
using bluetooth::os::fake_timer::fake_timerfd_advance;
using bluetooth::os::fuzz::fake_timerfd_cap_at;
using bluetooth::os::fake_timer::fake_timerfd_cap_at;
using bluetooth::os::fuzz::fake_timerfd_reset;
using bluetooth::os::fake_timer::fake_timerfd_reset;


extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  FuzzedDataProvider dataProvider(data, size);
  FuzzedDataProvider dataProvider(data, size);
+4 −4
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@
#include "hci/fuzz/hci_layer_fuzz_client.h"
#include "hci/fuzz/hci_layer_fuzz_client.h"
#include "hci/hci_layer.h"
#include "hci/hci_layer.h"
#include "module.h"
#include "module.h"
#include "os/fuzz/fake_timerfd.h"
#include "os/fake_timer/fake_timerfd.h"
#include "os/log.h"
#include "os/log.h"


#include <fuzzer/FuzzedDataProvider.h>
#include <fuzzer/FuzzedDataProvider.h>
@@ -31,9 +31,9 @@ using bluetooth::fuzz::GetArbitraryBytes;
using bluetooth::hal::HciHal;
using bluetooth::hal::HciHal;
using bluetooth::hal::fuzz::FuzzHciHal;
using bluetooth::hal::fuzz::FuzzHciHal;
using bluetooth::hci::fuzz::HciLayerFuzzClient;
using bluetooth::hci::fuzz::HciLayerFuzzClient;
using bluetooth::os::fuzz::fake_timerfd_advance;
using bluetooth::os::fake_timer::fake_timerfd_advance;
using bluetooth::os::fuzz::fake_timerfd_cap_at;
using bluetooth::os::fake_timer::fake_timerfd_cap_at;
using bluetooth::os::fuzz::fake_timerfd_reset;
using bluetooth::os::fake_timer::fake_timerfd_reset;


extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  FuzzedDataProvider dataProvider(data, size);
  FuzzedDataProvider dataProvider(data, size);
+2 −2
Original line number Original line Diff line number Diff line
@@ -93,8 +93,8 @@ name: "BluetoothOsBenchmarkSources",
}
}


filegroup {
filegroup {
    name: "BluetoothOsSources_fuzz",
    name: "BluetoothOsSources_fake_timer",
    srcs: [
    srcs: [
        "fuzz/fake_timerfd.cc",
        "fake_timer/fake_timerfd.cc",
    ],
    ],
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include "os/fuzz/fake_timerfd.h"
#include "os/fake_timer/fake_timerfd.h"


#include <sys/eventfd.h>
#include <sys/eventfd.h>
#include <unistd.h>
#include <unistd.h>
@@ -23,7 +23,7 @@


namespace bluetooth {
namespace bluetooth {
namespace os {
namespace os {
namespace fuzz {
namespace fake_timer {


class FakeTimerFd {
class FakeTimerFd {
 public:
 public:
@@ -134,6 +134,6 @@ void fake_timerfd_cap_at(uint64_t ms) {
  max_clock = ms;
  max_clock = ms;
}
}


}  // namespace fuzz
}  // namespace fake_timer
}  // namespace os
}  // namespace os
}  // namespace bluetooth
}  // namespace bluetooth
Loading