]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/fuzz/fuzz-main.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 #include "alloc-util.h"
9 /* This is a test driver for the systemd fuzzers that provides main function
10 * for regression testing outside of oss-fuzz (https://github.com/google/oss-fuzz)
12 * It reads files named on the command line and passes them one by one into the
13 * fuzzer that it is compiled into. */
15 /* This one was borrowed from
16 * https://github.com/google/oss-fuzz/blob/646fca1b506b056db3a60d32c4a1a7398f171c94/infra/base-images/base-runner/bad_build_check#L19
18 #define MIN_NUMBER_OF_RUNS 4
20 int main(int argc
, char **argv
) {
25 test_setup_logging(LOG_DEBUG
);
27 for (i
= 1; i
< argc
; i
++) {
28 _cleanup_free_
char *buf
= NULL
;
31 r
= read_full_file(name
, &buf
, &size
);
33 log_error_errno(r
, "Failed to open '%s': %m", name
);
36 printf("%s... ", name
);
38 for (int j
= 0; j
< MIN_NUMBER_OF_RUNS
; j
++)
39 (void) LLVMFuzzerTestOneInput((uint8_t*)buf
, size
);