diff options
author | drh <drh@noemail.net> | 2017-03-17 14:59:40 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-03-17 14:59:40 +0000 |
commit | f53524b4f72be7e7cf96fdec983000c9e4c5a85a (patch) | |
tree | af52bb1e85287f7eec74d34df2ebf1c2aef4c2a2 /test/ossshell.c | |
parent | 59d705ab808645ac865ad14e19d47f688064005f (diff) | |
download | sqlite-f53524b4f72be7e7cf96fdec983000c9e4c5a85a.tar.gz sqlite-f53524b4f72be7e7cf96fdec983000c9e4c5a85a.zip |
Add the --show-errors and --show-max-delay command-line options to the
ossshell test program.
FossilOrigin-Name: 626bdca98e0cd78ae873d97e75bb7d544ca18759c9f1e67f4adf03daca7fe5bf
Diffstat (limited to 'test/ossshell.c')
-rw-r--r-- | test/ossshell.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ossshell.c b/test/ossshell.c index 15902a912..00cc3391c 100644 --- a/test/ossshell.c +++ b/test/ossshell.c @@ -9,6 +9,7 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "sqlite3.h" /* @@ -16,6 +17,13 @@ */ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); +/* Must match equivalent #defines in ossfuzz.c */ +#define FUZZ_SQL_TRACE 0x0001 /* Set an sqlite3_trace() callback */ +#define FUZZ_SHOW_MAX_DELAY 0x0002 /* Show maximum progress callback delay */ +#define FUZZ_SHOW_ERRORS 0x0004 /* Show SQL errors */ +extern void ossfuzz_set_debug_flags(unsigned); + + /* ** Read files named on the command-line and invoke the fuzzer for @@ -27,9 +35,32 @@ int main(int argc, char **argv){ int nErr = 0; uint8_t *zBuf = 0; size_t sz; + unsigned mDebug = 0; for(i=1; i<argc; i++){ const char *zFilename = argv[i]; + if( zFilename[0]=='-' ){ + if( zFilename[1]=='-' ) zFilename++; + if( strcmp(zFilename, "-show-errors")==0 ){ + mDebug |= FUZZ_SHOW_ERRORS; + ossfuzz_set_debug_flags(mDebug); + }else + if( strcmp(zFilename, "-show-max-delay")==0 ){ + mDebug |= FUZZ_SHOW_MAX_DELAY; + ossfuzz_set_debug_flags(mDebug); + }else + if( strcmp(zFilename, "-sql-trace")==0 ){ + mDebug |= FUZZ_SQL_TRACE; + ossfuzz_set_debug_flags(mDebug); + }else + { + printf("unknown option \"%s\"\n", argv[i]); + printf("should be one of: --show-errors --show-max-delay" + " --sql-trace\n"); + exit(1); + } + continue; + } in = fopen(zFilename, "rb"); if( in==0 ){ fprintf(stderr, "cannot open \"%s\"\n", zFilename); @@ -50,8 +81,10 @@ int main(int argc, char **argv){ nErr++; }else{ printf("%s... ", zFilename); + if( mDebug ) printf("\n"); fflush(stdout); (void)LLVMFuzzerTestOneInput(zBuf, sz); + if( mDebug ) printf("%s: ", zFilename); printf("ok\n"); } fclose(in); |