summaryrefslogtreecommitdiff
path: root/src/fuzz/fuzz-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fuzz/fuzz-main.c')
-rw-r--r--src/fuzz/fuzz-main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/fuzz/fuzz-main.c b/src/fuzz/fuzz-main.c
index d549dc95ff..d5c9984989 100644
--- a/src/fuzz/fuzz-main.c
+++ b/src/fuzz/fuzz-main.c
@@ -4,6 +4,7 @@
#include "log.h"
#include "fileio.h"
#include "fuzz.h"
+#include "tests.h"
/* This is a test driver for the systemd fuzzers that provides main function
* for regression testing outside of oss-fuzz (https://github.com/google/oss-fuzz)
@@ -11,14 +12,17 @@
* It reads files named on the command line and passes them one by one into the
* fuzzer that it is compiled into. */
+/* This one was borrowed from
+ * https://github.com/google/oss-fuzz/blob/646fca1b506b056db3a60d32c4a1a7398f171c94/infra/base-images/base-runner/bad_build_check#L19
+ */
+#define MIN_NUMBER_OF_RUNS 4
+
int main(int argc, char **argv) {
int i, r;
size_t size;
char *name;
- log_set_max_level(LOG_DEBUG);
- log_parse_environment();
- log_open();
+ test_setup_logging(LOG_DEBUG);
for (i = 1; i < argc; i++) {
_cleanup_free_ char *buf = NULL;
@@ -31,7 +35,9 @@ int main(int argc, char **argv) {
}
printf("%s... ", name);
fflush(stdout);
- (void) LLVMFuzzerTestOneInput((uint8_t*)buf, size);
+ for (int j = 0; j < MIN_NUMBER_OF_RUNS; j++)
+ if (LLVMFuzzerTestOneInput((uint8_t*)buf, size) == EXIT_TEST_SKIP)
+ return EXIT_TEST_SKIP;
printf("ok\n");
}