Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 720590342
  • Loading branch information
FuzzTest Team authored and copybara-github committed Feb 12, 2025
1 parent 15e7f45 commit 68a5d12
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
11 changes: 11 additions & 0 deletions fuzztest/internal/fixture_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ class FixtureWithExplicitSetUp {
static void TearDownTestSuite() {}
};

class FixtureWithReentrantSetUp {
public:
virtual ~FixtureWithReentrantSetUp() = default;

virtual void SetUp() = 0;
virtual void TearDown() = 0;

static void SetUpTestSuite() {}
static void TearDownTestSuite() {}
};

// Marker interfaces for specifying the fixture's instantiation semantics:
//
// - Per-iteration semantics: The fixture object is instantiated and discarded
Expand Down
46 changes: 36 additions & 10 deletions fuzztest/internal/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@
namespace fuzztest {
namespace internal {

template <typename Fixture, typename = void>
class FuzzTestFuzzerProvider;

#if defined(FUZZTEST_COMPATIBILITY_MODE) && defined(FUZZTEST_USE_CENTIPEDE)
#error FuzzTest compatibility mode cannot work together with Centipede.
#endif
#if defined(FUZZTEST_COMPATIBILITY_MODE)
template <typename Fixture>
class FuzzTestFuzzerProvider<
Fixture, std::enable_if_t<std::negation_v<
std::is_base_of<FixtureWithReentrantSetUp, Fixture>>>>
: public FuzzTestExternalEngineAdaptor {
public:
using FuzzTestExternalEngineAdaptor::FuzzTestExternalEngineAdaptor;
};
#elif defined(FUZZTEST_USE_CENTIPEDE)
template <typename Fixture>
class FuzzTestFuzzerProvider<
Fixture, std::enable_if_t<std::negation_v<
std::is_base_of<FixtureWithReentrantSetUp, Fixture>>>>
: public CentipedeFuzzerAdaptor {
public:
using CentipedeFuzzerAdaptor::CentipedeFuzzerAdaptor;
};
#else
template <typename Fixture>
class FuzzTestFuzzerProvider<
Fixture, std::enable_if_t<std::negation_v<
std::is_base_of<FixtureWithReentrantSetUp, Fixture>>>>
: public FuzzTestFuzzerImpl {
public:
using FuzzTestFuzzerImpl::FuzzTestFuzzerImpl;
};
#endif

void RegisterImpl(BasicTestInfo test_info, FuzzTestFuzzerFactory factory);

void ForEachTest(absl::FunctionRef<void(FuzzTest&)> func);
Expand Down Expand Up @@ -70,16 +105,7 @@ struct RegistrationToken {
typename SeedProvider>
static FuzzTestFuzzerFactory GetFuzzTestFuzzerFactory(
Registration<Fixture, TargetFunction, RegBase, SeedProvider>&& reg) {
#if defined(FUZZTEST_COMPATIBILITY_MODE) && defined(FUZZTEST_USE_CENTIPEDE)
#error FuzzTest compatibility mode cannot work together with Centipede.
#endif
#if defined(FUZZTEST_COMPATIBILITY_MODE)
using FuzzerImpl = FuzzTestExternalEngineAdaptor;
#elif defined(FUZZTEST_USE_CENTIPEDE)
using FuzzerImpl = CentipedeFuzzerAdaptor;
#else
using FuzzerImpl = FuzzTestFuzzerImpl;
#endif
using FuzzerImpl = FuzzTestFuzzerProvider<Fixture>;

return [target_function = reg.target_function_, domain = reg.GetDomains(),
seeds = reg.seeds(), seed_provider = reg.seed_provider()](
Expand Down

0 comments on commit 68a5d12

Please sign in to comment.