Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
fuzz
fuzz.h
Go to the documentation of this file.
1
// Copyright (c) 2009-present 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 <cstdint>
9
#include <functional>
10
#include <span>
11
#include <string_view>
12
22
#define LIMITED_WHILE(condition, limit) \
23
for (unsigned _count{limit}; (condition) && _count; --_count)
24
25
using
FuzzBufferType
= std::span<const uint8_t>;
26
27
using
TypeTestOneInput
= std::function<void(
FuzzBufferType
)>;
28
struct
FuzzTargetOptions
{
29
std::function<void()>
init
{[] {}};
30
bool
hidden
{
false
};
31
};
32
33
void
FuzzFrameworkRegisterTarget
(std::string_view
name
,
TypeTestOneInput
target,
FuzzTargetOptions
opts);
34
35
#define FUZZ_TARGET(...) DETAIL_FUZZ(__VA_ARGS__)
36
37
#define DETAIL_FUZZ(name, ...) \
38
void name##_fuzz_target(FuzzBufferType); \
39
struct name##_Before_Main { \
40
name##_Before_Main() \
41
{ \
42
FuzzFrameworkRegisterTarget(#name, name##_fuzz_target, {__VA_ARGS__}); \
43
} \
44
} const static g_##name##_before_main; \
45
void name##_fuzz_target(FuzzBufferType buffer)
46
47
#endif
// BITCOIN_TEST_FUZZ_FUZZ_H
FuzzBufferType
std::span< const uint8_t > FuzzBufferType
Definition
fuzz.h:25
TypeTestOneInput
std::function< void(FuzzBufferType)> TypeTestOneInput
Definition
fuzz.h:27
FuzzFrameworkRegisterTarget
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, FuzzTargetOptions opts)
Definition
fuzz.cpp:76
init
Definition
bitcoin-gui.cpp:17
name
const char * name
Definition
rest.cpp:48
FuzzTargetOptions
Definition
fuzz.h:28
FuzzTargetOptions::hidden
bool hidden
Definition
fuzz.h:30
Generated on
for Bitcoin Core by
1.17.0