xref: /netbsd-src/external/bsd/zstd/dist/tests/fuzz/fuzz.h (revision 3117ece4fc4a4ca4489ba793710b60b0d26bab6c)
1*3117ece4Schristos /*
2*3117ece4Schristos  * Copyright (c) Meta Platforms, Inc. and affiliates.
3*3117ece4Schristos  * All rights reserved.
4*3117ece4Schristos  *
5*3117ece4Schristos  * This source code is licensed under both the BSD-style license (found in the
6*3117ece4Schristos  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7*3117ece4Schristos  * in the COPYING file in the root directory of this source tree).
8*3117ece4Schristos  * You may select, at your option, one of the above-listed licenses.
9*3117ece4Schristos  */
10*3117ece4Schristos 
11*3117ece4Schristos /**
12*3117ece4Schristos  * Fuzz target interface.
13*3117ece4Schristos  * Fuzz targets have some common parameters passed as macros during compilation.
14*3117ece4Schristos  * Check the documentation for each individual fuzzer for more parameters.
15*3117ece4Schristos  *
16*3117ece4Schristos  * @param STATEFUL_FUZZING:
17*3117ece4Schristos  *        Define this to reuse state between fuzzer runs. This can be useful to
18*3117ece4Schristos  *        test code paths which are only executed when contexts are reused.
19*3117ece4Schristos  *        WARNING: Makes reproducing crashes much harder.
20*3117ece4Schristos  *        Default: Not defined.
21*3117ece4Schristos  * @param DEBUGLEVEL:
22*3117ece4Schristos  *        This is a parameter for the zstd library. Defining `DEBUGLEVEL=1`
23*3117ece4Schristos  *        enables assert() statements in the zstd library. Higher levels enable
24*3117ece4Schristos  *        logging, so aren't recommended. Defining `DEBUGLEVEL=1` is
25*3117ece4Schristos  *        recommended.
26*3117ece4Schristos  * @param MEM_FORCE_MEMORY_ACCESS:
27*3117ece4Schristos  *        This flag controls how the zstd library accesses unaligned memory.
28*3117ece4Schristos  *        It can be undefined, or 0 through 2. If it is undefined, it selects
29*3117ece4Schristos  *        the method to use based on the compiler.
30*3117ece4Schristos  * @param FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
31*3117ece4Schristos  *        This is the canonical flag to enable deterministic builds for fuzzing.
32*3117ece4Schristos  *        Changes to zstd for fuzzing are gated behind this define.
33*3117ece4Schristos  *        It is recommended to define this when building zstd for fuzzing.
34*3117ece4Schristos  * @param FUZZ_THIRD_PARTY_SEQ_PROD
35*3117ece4Schristos  *        This flag allows sequence producer plugin authors to replace the built-in
36*3117ece4Schristos  *        default sequence producer with their own code. If you are not a plugin
37*3117ece4Schristos  *        author, you should not define this flag. See the docs at
38*3117ece4Schristos  *        fuzz_third_party_seq_prod.h for more information.
39*3117ece4Schristos  */
40*3117ece4Schristos 
41*3117ece4Schristos #ifndef FUZZ_H
42*3117ece4Schristos #define FUZZ_H
43*3117ece4Schristos 
44*3117ece4Schristos #include <stddef.h>
45*3117ece4Schristos #include <stdint.h>
46*3117ece4Schristos 
47*3117ece4Schristos #ifdef __cplusplus
48*3117ece4Schristos extern "C" {
49*3117ece4Schristos #endif
50*3117ece4Schristos 
51*3117ece4Schristos int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size);
52*3117ece4Schristos 
53*3117ece4Schristos #ifdef __cplusplus
54*3117ece4Schristos }
55*3117ece4Schristos #endif
56*3117ece4Schristos 
57*3117ece4Schristos #endif
58