2020-12-31 09:48:25 +01:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2019-01-25 18:35:36 -05:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_TEST_FUZZ_FUZZ_H
|
|
|
|
#define BITCOIN_TEST_FUZZ_FUZZ_H
|
|
|
|
|
2020-12-03 16:42:49 +01:00
|
|
|
#include <cstdint>
|
|
|
|
#include <functional>
|
|
|
|
#include <string_view>
|
2019-01-25 18:35:36 -05:00
|
|
|
#include <vector>
|
|
|
|
|
2020-12-03 16:42:49 +01:00
|
|
|
using TypeTestOneInput = std::function<void(const std::vector<uint8_t>&)>;
|
|
|
|
using TypeInitialize = std::function<void()>;
|
|
|
|
|
|
|
|
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init);
|
|
|
|
|
2020-12-20 18:19:43 -05:00
|
|
|
inline void FuzzFrameworkEmptyFun() {}
|
2020-12-03 16:42:49 +01:00
|
|
|
|
|
|
|
#define FUZZ_TARGET(name) \
|
|
|
|
FUZZ_TARGET_INIT(name, FuzzFrameworkEmptyFun)
|
|
|
|
|
|
|
|
#define FUZZ_TARGET_INIT(name, init_fun) \
|
|
|
|
void name##_fuzz_target(const std::vector<uint8_t>&); \
|
|
|
|
struct name##_Before_Main { \
|
|
|
|
name##_Before_Main() \
|
|
|
|
{ \
|
|
|
|
FuzzFrameworkRegisterTarget(#name, name##_fuzz_target, init_fun); \
|
|
|
|
} \
|
|
|
|
} const static g_##name##_before_main; \
|
|
|
|
void name##_fuzz_target(const std::vector<uint8_t>& buffer)
|
2019-01-25 18:35:36 -05:00
|
|
|
|
|
|
|
#endif // BITCOIN_TEST_FUZZ_FUZZ_H
|