From db4bd32cc31789fc017f5db0b86a69ee43e41575 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 23 Oct 2019 21:46:53 +0000 Subject: tests: Skip unnecessary fuzzer initialisation. Hold ECCVerifyHandle only when needed. --- src/test/fuzz/deserialize.cpp | 7 +++++++ src/test/fuzz/fuzz.cpp | 13 +++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/test/fuzz/deserialize.cpp b/src/test/fuzz/deserialize.cpp index 3a6876ad39..bcd8691359 100644 --- a/src/test/fuzz/deserialize.cpp +++ b/src/test/fuzz/deserialize.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,12 @@ #include +void initialize() +{ + // Fuzzers using pubkey must hold an ECCVerifyHandle. + static const auto verify_handle = MakeUnique(); +} + void test_one_input(const std::vector& buffer) { CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION); diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index a8a108cd18..44256ce867 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -4,11 +4,9 @@ #include +#include #include - -#include -#include - +#include static bool read_stdin(std::vector& data) { @@ -23,10 +21,8 @@ static bool read_stdin(std::vector& data) } // Default initialization: Override using a non-weak initialize(). -__attribute__((weak)) -void initialize() +__attribute__((weak)) void initialize() { - const static auto verify_handle = MakeUnique(); } // This function is used by libFuzzer @@ -50,7 +46,8 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) // the main(...) function. __attribute__((weak)) #endif -int main(int argc, char **argv) +int +main(int argc, char** argv) { initialize(); #ifdef __AFL_INIT -- cgit v1.2.3 From c2f964a6745be085f2891c909d6c998687de9080 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 24 Oct 2019 08:07:59 +0000 Subject: tests: Remove Cygwin WinMain workaround --- src/test/fuzz/fuzz.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src') diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index 44256ce867..da4e623e98 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -40,14 +40,9 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) return 0; } -// Disabled under WIN32 due to clash with Cygwin's WinMain. -#ifndef WIN32 // Declare main(...) "weak" to allow for libFuzzer linking. libFuzzer provides // the main(...) function. -__attribute__((weak)) -#endif -int -main(int argc, char** argv) +__attribute__((weak)) int main(int argc, char** argv) { initialize(); #ifdef __AFL_INIT -- cgit v1.2.3