From d6139d3b1b606337598d7de40e2a4fd89a1782ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gl=C3=A4=C3=9Fer?= Date: Mon, 7 Jul 2025 13:10:46 +0200 Subject: [PATCH] chore: use latest cifuzz.h file --- include/cifuzz/cifuzz.h | 76 ++++++++++++----------------------------- 1 file changed, 21 insertions(+), 55 deletions(-) diff --git a/include/cifuzz/cifuzz.h b/include/cifuzz/cifuzz.h index b1d4243..d414f9f 100644 --- a/include/cifuzz/cifuzz.h +++ b/include/cifuzz/cifuzz.h @@ -10,48 +10,8 @@ #include #endif -#if defined(__CLION_IDE__) && defined(__cplusplus) -/* This code will only be seen by CLion's static analysis/preprocessing engine - * and thus doesn't have to contain any definitions, declarations are - * sufficient. It mocks enough of the Doctest classes to make CLion's test - * framework support treat it as the full Doctest library. */ -namespace doctest { -namespace detail { -struct TestSuite {}; -typedef int (*funcType)(const uint8_t *data, std::size_t size); -struct TestCase -{ - TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite, - const char* type = "", int template_id = -1); - TestCase& operator*(const char* in); -}; -int regTest(const TestCase& tc); -} -} - -/* This macro has to be defined or CLion will not show a play button, but the - * value doesn't matter. */ -#define DOCTEST_TEST_CASE - -#define CLION_TEST_PLAY_BUTTON \ -/* Silence a CLion warning about a static - * initializer with static storage duration */ \ -/* NOLINTBEGIN(cert-err58-cpp) */ \ -static const int DOCTEST_ANON_VAR_15771531 = \ - doctest::detail::regTest( \ - doctest::detail::TestCase( \ - &LLVMFuzzerTestOneInput, \ - "", \ - 1, \ - doctest::detail::TestSuite() \ -/* This string is used as the test name and has - * to be globally unique so that CLion - * generates a unique run configuration per - * test. */ \ - ) * CIFUZZ_TEST_NAME); \ -/* NOLINTEND(cert-err58-cpp) */ -#else -#define CLION_TEST_PLAY_BUTTON +#ifdef CI_FUZZ_TEST_FRAMEWORK_GTEST +#include #endif #ifdef __cplusplus @@ -63,22 +23,28 @@ static const int DOCTEST_ANON_VAR_15771531 = \ static void LLVMFuzzerTestOneInputNoReturn(const uint8_t *data, size_t size); #ifdef CIFUZZ_GCOV -CIFUZZ_C_LINKAGE void __gcov_dump(); -CIFUZZ_C_LINKAGE void __gcov_reset(); -CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - LLVMFuzzerTestOneInputNoReturn(data, size); - __gcov_dump(); - __gcov_reset(); - return 0; -} +#define DEFINE_LLVM_FUZZER_TEST_ONE_INPUT \ + CIFUZZ_C_LINKAGE void __gcov_dump(); \ + CIFUZZ_C_LINKAGE void __gcov_reset(); \ + CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput(const uint8_t *data, \ + size_t size) { \ + LLVMFuzzerTestOneInputNoReturn(data, size); \ + __gcov_dump(); \ + __gcov_reset(); \ + return 0; \ + } #else -CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - LLVMFuzzerTestOneInputNoReturn(data, size); - return 0; -} +#define DEFINE_LLVM_FUZZER_TEST_ONE_INPUT \ + CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput(const uint8_t *data, \ + size_t size) { \ + LLVMFuzzerTestOneInputNoReturn(data, size); \ + return 0; \ + } #endif -#define FUZZ_TEST void LLVMFuzzerTestOneInputNoReturn +#define FUZZ_TEST \ + DEFINE_LLVM_FUZZER_TEST_ONE_INPUT; \ + void LLVMFuzzerTestOneInputNoReturn #ifdef __APPLE__ #define DECLARE_LLVM_FUZZER_INITIALIZE_NO_RETURN \