aboutsummaryrefslogtreecommitdiff
path: root/test/ossshell.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/ossshell.c')
-rw-r--r--test/ossshell.c33
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);