1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add the --show-errors and --show-max-delay command-line options to the

ossshell test program.

FossilOrigin-Name: 626bdca98e0cd78ae873d97e75bb7d544ca18759c9f1e67f4adf03daca7fe5bf
This commit is contained in:
drh
2017-03-17 14:59:40 +00:00
parent 59d705ab80
commit f53524b4f7
4 changed files with 97 additions and 19 deletions

View File

@ -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);