]>
Commit | Line | Data |
---|---|---|
7db7d5b7 JR |
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
2 | /*** | |
96b2fb93 | 3 | Copyright © 2018 Jonathan Rudenberg |
7db7d5b7 JR |
4 | ***/ |
5 | ||
6 | #include "alloc-util.h" | |
7 | #include "log.h" | |
8 | #include "fileio.h" | |
9 | #include "fuzz.h" | |
10 | ||
11 | /* This is a test driver for the systemd fuzzers that provides main function | |
12 | * for regression testing outside of oss-fuzz (https://github.com/google/oss-fuzz) | |
13 | * | |
14 | * It reads files named on the command line and passes them one by one into the | |
15 | * fuzzer that it is compiled into. */ | |
16 | ||
17 | int main(int argc, char **argv) { | |
18 | int i, r; | |
19 | size_t size; | |
20 | char *name; | |
21 | ||
22 | log_set_max_level(LOG_DEBUG); | |
b872843c ZJS |
23 | log_parse_environment(); |
24 | log_open(); | |
25 | ||
7db7d5b7 JR |
26 | for (i = 1; i < argc; i++) { |
27 | _cleanup_free_ char *buf = NULL; | |
28 | ||
29 | name = argv[i]; | |
30 | r = read_full_file(name, &buf, &size); | |
31 | if (r < 0) { | |
32 | log_error_errno(r, "Failed to open '%s': %m", name); | |
33 | return EXIT_FAILURE; | |
34 | } | |
35 | printf("%s... ", name); | |
36 | fflush(stdout); | |
74449567 | 37 | (void) LLVMFuzzerTestOneInput((uint8_t*)buf, size); |
7db7d5b7 JR |
38 | printf("ok\n"); |
39 | } | |
b872843c | 40 | |
7db7d5b7 JR |
41 | return EXIT_SUCCESS; |
42 | } |