10
10
#include < stdint.h>
11
11
#endif
12
12
13
- #if defined(__CLION_IDE__) && defined(__cplusplus)
14
- /* This code will only be seen by CLion's static analysis/preprocessing engine
15
- * and thus doesn't have to contain any definitions, declarations are
16
- * sufficient. It mocks enough of the Doctest classes to make CLion's test
17
- * framework support treat it as the full Doctest library. */
18
- namespace doctest {
19
- namespace detail {
20
- struct TestSuite {};
21
- typedef int (*funcType)(const uint8_t *data, std::size_t size);
22
- struct TestCase
23
- {
24
- TestCase (funcType test, const char * file, unsigned line, const TestSuite& test_suite,
25
- const char * type = " " , int template_id = -1 );
26
- TestCase& operator *(const char * in);
27
- };
28
- int regTest (const TestCase& tc);
29
- }
30
- }
31
-
32
- /* This macro has to be defined or CLion will not show a play button, but the
33
- * value doesn't matter. */
34
- #define DOCTEST_TEST_CASE
35
-
36
- #define CLION_TEST_PLAY_BUTTON \
37
- /* Silence a CLion warning about a static
38
- * initializer with static storage duration */ \
39
- /* NOLINTBEGIN(cert-err58-cpp) */ \
40
- static const int DOCTEST_ANON_VAR_15771531 = \
41
- doctest::detail::regTest ( \
42
- doctest::detail::TestCase ( \
43
- &LLVMFuzzerTestOneInput, \
44
- " " , \
45
- 1 , \
46
- doctest::detail::TestSuite () \
47
- /* This string is used as the test name and has
48
- * to be globally unique so that CLion
49
- * generates a unique run configuration per
50
- * test. */ \
51
- ) * CIFUZZ_TEST_NAME); \
52
- /* NOLINTEND(cert-err58-cpp) */
53
- #else
54
- #define CLION_TEST_PLAY_BUTTON
13
+ #ifdef CI_FUZZ_TEST_FRAMEWORK_GTEST
14
+ #include < cifuzz/cifuzz_gtest.h>
55
15
#endif
56
16
57
17
#ifdef __cplusplus
@@ -63,22 +23,28 @@ static const int DOCTEST_ANON_VAR_15771531 = \
63
23
static void LLVMFuzzerTestOneInputNoReturn (const uint8_t *data, size_t size);
64
24
65
25
#ifdef CIFUZZ_GCOV
66
- CIFUZZ_C_LINKAGE void __gcov_dump ();
67
- CIFUZZ_C_LINKAGE void __gcov_reset ();
68
- CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) {
69
- LLVMFuzzerTestOneInputNoReturn (data, size);
70
- __gcov_dump ();
71
- __gcov_reset ();
72
- return 0 ;
73
- }
26
+ #define DEFINE_LLVM_FUZZER_TEST_ONE_INPUT \
27
+ CIFUZZ_C_LINKAGE void __gcov_dump (); \
28
+ CIFUZZ_C_LINKAGE void __gcov_reset (); \
29
+ CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput (const uint8_t *data, \
30
+ size_t size) { \
31
+ LLVMFuzzerTestOneInputNoReturn (data, size); \
32
+ __gcov_dump (); \
33
+ __gcov_reset (); \
34
+ return 0 ; \
35
+ }
74
36
#else
75
- CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) {
76
- LLVMFuzzerTestOneInputNoReturn (data, size);
77
- return 0 ;
78
- }
37
+ #define DEFINE_LLVM_FUZZER_TEST_ONE_INPUT \
38
+ CIFUZZ_C_LINKAGE int LLVMFuzzerTestOneInput (const uint8_t *data, \
39
+ size_t size) { \
40
+ LLVMFuzzerTestOneInputNoReturn (data, size); \
41
+ return 0 ; \
42
+ }
79
43
#endif
80
44
81
- #define FUZZ_TEST void LLVMFuzzerTestOneInputNoReturn
45
+ #define FUZZ_TEST \
46
+ DEFINE_LLVM_FUZZER_TEST_ONE_INPUT; \
47
+ void LLVMFuzzerTestOneInputNoReturn
82
48
83
49
#ifdef __APPLE__
84
50
#define DECLARE_LLVM_FUZZER_INITIALIZE_NO_RETURN \
0 commit comments