Skip to content

Commit fafca47

Browse files
author
MarcoFalke
committed
fuzz: Hide script_assets_test_minimizer
Can be reviewed with --ignore-all-space
1 parent e51f6c4 commit fafca47

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

src/test/fuzz/fuzz.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
1515

16-
std::map<std::string_view, std::tuple<TypeTestOneInput, TypeInitialize>>& FuzzTargets()
16+
std::map<std::string_view, std::tuple<TypeTestOneInput, TypeInitialize, TypeHidden>>& FuzzTargets()
1717
{
18-
static std::map<std::string_view, std::tuple<TypeTestOneInput, TypeInitialize>> g_fuzz_targets;
18+
static std::map<std::string_view, std::tuple<TypeTestOneInput, TypeInitialize, TypeHidden>> g_fuzz_targets;
1919
return g_fuzz_targets;
2020
}
2121

22-
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init)
22+
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init, TypeHidden hidden)
2323
{
24-
const auto it_ins = FuzzTargets().try_emplace(name, std::move(target), std::move(init));
24+
const auto it_ins = FuzzTargets().try_emplace(name, std::move(target), std::move(init), hidden);
2525
Assert(it_ins.second);
2626
}
2727

@@ -31,6 +31,7 @@ void initialize()
3131
{
3232
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
3333
for (const auto& t : FuzzTargets()) {
34+
if (std::get<2>(t.second)) continue;
3435
std::cout << t.first << std::endl;
3536
}
3637
Assert(false);

src/test/fuzz/fuzz.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,26 @@ using FuzzBufferType = Span<const uint8_t>;
1515

1616
using TypeTestOneInput = std::function<void(FuzzBufferType)>;
1717
using TypeInitialize = std::function<void()>;
18+
using TypeHidden = bool;
1819

19-
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init);
20+
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init, TypeHidden hidden);
2021

21-
inline void FuzzFrameworkEmptyFun() {}
22+
inline void FuzzFrameworkEmptyInitFun() {}
2223

2324
#define FUZZ_TARGET(name) \
24-
FUZZ_TARGET_INIT(name, FuzzFrameworkEmptyFun)
25-
26-
#define FUZZ_TARGET_INIT(name, init_fun) \
27-
void name##_fuzz_target(FuzzBufferType); \
28-
struct name##_Before_Main { \
29-
name##_Before_Main() \
30-
{ \
31-
FuzzFrameworkRegisterTarget(#name, name##_fuzz_target, init_fun); \
32-
} \
33-
} const static g_##name##_before_main; \
25+
FUZZ_TARGET_INIT(name, FuzzFrameworkEmptyInitFun)
26+
27+
#define FUZZ_TARGET_INIT(name, init_fun) \
28+
FUZZ_TARGET_INIT_HIDDEN(name, init_fun, false)
29+
30+
#define FUZZ_TARGET_INIT_HIDDEN(name, init_fun, hidden) \
31+
void name##_fuzz_target(FuzzBufferType); \
32+
struct name##_Before_Main { \
33+
name##_Before_Main() \
34+
{ \
35+
FuzzFrameworkRegisterTarget(#name, name##_fuzz_target, init_fun, hidden); \
36+
} \
37+
} const static g_##name##_before_main; \
3438
void name##_fuzz_target(FuzzBufferType buffer)
3539

3640
#endif // BITCOIN_TEST_FUZZ_FUZZ_H

src/test/fuzz/script_assets_test_minimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ ECCVerifyHandle handle;
190190

191191
} // namespace
192192

193-
FUZZ_TARGET(script_assets_test_minimizer)
193+
FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, FuzzFrameworkEmptyInitFun, /* hidden */ true)
194194
{
195195
if (buffer.size() < 2 || buffer.back() != '\n' || buffer[buffer.size() - 2] != ',') return;
196196
const std::string str((const char*)buffer.data(), buffer.size() - 2);

0 commit comments

Comments
 (0)