Bitcoin Core
22.99.0
P2P Digital Currency
src
test
fuzz
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
18
#define LIMITED_WHILE(condition, limit) \
19
for (unsigned _count{limit}; (condition) && _count; --_count)
20
21
using
FuzzBufferType
=
Span<const uint8_t>
;
22
23
using
TypeTestOneInput
= std::function<void(
FuzzBufferType
)>;
24
using
TypeInitialize
= std::function<void()>;
25
using
TypeHidden
= bool;
26
27
void
FuzzFrameworkRegisterTarget
(std::string_view
name
,
TypeTestOneInput
target,
TypeInitialize
init
,
TypeHidden
hidden);
28
29
inline
void
FuzzFrameworkEmptyInitFun
() {}
30
31
#define FUZZ_TARGET(name) \
32
FUZZ_TARGET_INIT(name, FuzzFrameworkEmptyInitFun)
33
34
#define FUZZ_TARGET_INIT(name, init_fun) \
35
FUZZ_TARGET_INIT_HIDDEN(name, init_fun, false)
36
37
#define FUZZ_TARGET_INIT_HIDDEN(name, init_fun, hidden) \
38
void name##_fuzz_target(FuzzBufferType); \
39
struct name##_Before_Main { \
40
name##_Before_Main() \
41
{ \
42
FuzzFrameworkRegisterTarget(#name, name##_fuzz_target, init_fun, hidden); \
43
} \
44
} const static g_##name##_before_main; \
45
void name##_fuzz_target(FuzzBufferType buffer)
46
47
#endif // BITCOIN_TEST_FUZZ_FUZZ_H
FuzzFrameworkEmptyInitFun
void FuzzFrameworkEmptyInitFun()
Definition:
fuzz.h:29
FuzzFrameworkRegisterTarget
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init, TypeHidden hidden)
Definition:
fuzz.cpp:56
TypeInitialize
std::function< void()> TypeInitialize
Definition:
fuzz.h:24
Span
A Span is an object that can refer to a contiguous sequence of objects.
Definition:
span.h:96
span.h
TypeHidden
bool TypeHidden
Definition:
fuzz.h:25
name
const char * name
Definition:
rest.cpp:52
TypeTestOneInput
std::function< void(FuzzBufferType)> TypeTestOneInput
Definition:
fuzz.h:23
init
Definition:
bitcoin-gui.cpp:16
Generated on Fri Feb 18 2022 20:03:47 for Bitcoin Core by
1.8.17