comparison fuzz/fuzz-harness.c @ 1809:fd00aeff38fd

fuzz: add -q quiet argument for standalone fuzzers. travis has a log length limit
author Matt Johnston <matt@ucc.asn.au>
date Sun, 07 Mar 2021 21:26:34 +0800
parents 8179eabe16c9
children be236878efcf
comparison
equal deleted inserted replaced
1808:42daf3044618 1809:fd00aeff38fd
5 extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); 5 extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
6 6
7 int main(int argc, char ** argv) { 7 int main(int argc, char ** argv) {
8 int i; 8 int i;
9 buffer *input = buf_new(100000); 9 buffer *input = buf_new(100000);
10 int quiet = 0;
10 11
11 for (i = 1; i < argc; i++) { 12 for (i = 1; i < argc; i++) {
12 #if DEBUG_TRACE 13 #if DEBUG_TRACE
13 if (strcmp(argv[i], "-v") == 0) { 14 if (strcmp(argv[i], "-v") == 0) {
14 debug_trace = 1; 15 debug_trace = 1;
15 TRACE(("debug printing on")) 16 TRACE(("debug printing on"))
16 } 17 }
17 #endif 18 #endif
19 if (strcmp(argv[i], "-q") == 0) {
20 printf("Running quiet\n");
21 quiet = 1;
22 }
18 } 23 }
19 24
20 int old_fuzz_wrapfds = 0; 25 int old_fuzz_wrapfds = 0;
21 for (i = 1; i < argc; i++) { 26 for (i = 1; i < argc; i++) {
22 if (argv[i][0] == '-') { 27 if (argv[i][0] == '-') {
29 buf_readfile(input, fn); 34 buf_readfile(input, fn);
30 buf_setpos(input, 0); 35 buf_setpos(input, 0);
31 36
32 /* Run twice to catch problems with statefulness */ 37 /* Run twice to catch problems with statefulness */
33 fuzz.wrapfds = old_fuzz_wrapfds; 38 fuzz.wrapfds = old_fuzz_wrapfds;
34 printf("Running %s once \n", fn); 39 if (!quiet) {
40 printf("Running %s once \n", fn);
41 }
35 LLVMFuzzerTestOneInput(input->data, input->len); 42 LLVMFuzzerTestOneInput(input->data, input->len);
36 printf("Running %s twice \n", fn); 43 if (!quiet) {
44 printf("Running %s twice \n", fn);
45 }
37 LLVMFuzzerTestOneInput(input->data, input->len); 46 LLVMFuzzerTestOneInput(input->data, input->len);
38 printf("Done %s\n", fn); 47 if (!quiet) {
48 printf("Done %s\n", fn);
49 }
39 50
40 /* Disable wrapfd so it won't interfere with buf_readfile() above */ 51 /* Disable wrapfd so it won't interfere with buf_readfile() above */
41 old_fuzz_wrapfds = fuzz.wrapfds; 52 old_fuzz_wrapfds = fuzz.wrapfds;
42 fuzz.wrapfds = 0; 53 fuzz.wrapfds = 0;
43 } 54 }