/src/cmp_tool/test/fuzz/fuzz_helpers.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) Meta Platforms, Inc. and affiliates. |
3 | | * All rights reserved. |
4 | | * |
5 | | * This source code is licensed under both the BSD-style license (found in the |
6 | | * LICENSE.BSD-3.Zstandard file in the 3rdparty_licenses directory) and the GPLv2 |
7 | | * (found in the LICENSE.GPL-2 file in the 3rdparty_licenses directory). |
8 | | * You may select, at your option, one of the above-listed licenses. |
9 | | */ |
10 | | |
11 | | /** |
12 | | * Helper functions for fuzzing. |
13 | | */ |
14 | | |
15 | | #ifndef FUZZ_HELPERS_H |
16 | | #define FUZZ_HELPERS_H |
17 | | |
18 | | #include <stdio.h> |
19 | | #include <stdint.h> |
20 | | |
21 | | #ifdef __cplusplus |
22 | | extern "C" { |
23 | | #endif |
24 | | |
25 | | |
26 | 0 | #define FUZZ_QUOTE_IMPL(str) #str |
27 | 0 | #define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str) |
28 | | |
29 | | /** |
30 | | * Asserts for fuzzing that are always enabled. |
31 | | */ |
32 | | #define FUZZ_ASSERT_MSG(cond, msg) \ |
33 | 95.5k | ((cond) ? (void)0 \ |
34 | 95.5k | : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \ |
35 | 0 | __LINE__, FUZZ_QUOTE(cond), (msg)), \ |
36 | 0 | abort())) |
37 | 95.5k | #define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), ""); |
38 | | |
39 | | void *FUZZ_malloc(size_t size); |
40 | | |
41 | | char *FUZZ_buf_to_file(const uint8_t *buf, size_t size); |
42 | | int FUZZ_delete_file(const char *path_name); |
43 | | |
44 | | #ifdef __cplusplus |
45 | | } |
46 | | #endif |
47 | | |
48 | | #endif |