Bitcoin Core  27.99.0
P2P Digital Currency
fuzz.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_TEST_FUZZ_FUZZ_H
6 #define BITCOIN_TEST_FUZZ_FUZZ_H
7 
8 #include <span.h>
9 
10 #include <cstdint>
11 #include <functional>
12 #include <string_view>
13 
23 #define LIMITED_WHILE(condition, limit) \
24  for (unsigned _count{limit}; (condition) && _count; --_count)
25 
27 
28 using TypeTestOneInput = std::function<void(FuzzBufferType)>;
30  std::function<void()> init{[] {}};
31  bool hidden{false};
32 };
33 
34 void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, FuzzTargetOptions opts);
35 
36 #define FUZZ_TARGET(...) DETAIL_FUZZ(__VA_ARGS__)
37 
38 #define DETAIL_FUZZ(name, ...) \
39  void name##_fuzz_target(FuzzBufferType); \
40  struct name##_Before_Main { \
41  name##_Before_Main() \
42  { \
43  FuzzFrameworkRegisterTarget(#name, name##_fuzz_target, {__VA_ARGS__}); \
44  } \
45  } const static g_##name##_before_main; \
46  void name##_fuzz_target(FuzzBufferType buffer)
47 
48 #endif // BITCOIN_TEST_FUZZ_FUZZ_H
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:98
std::function< void(FuzzBufferType)> TypeTestOneInput
Definition: fuzz.h:28
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, FuzzTargetOptions opts)
Definition: fuzz.cpp:74
const char * name
Definition: rest.cpp:50
bool hidden
Definition: fuzz.h:31