Add the --unique-cases option to fuzzershell.
FossilOrigin-Name: 7cb718491b5de77d4a73d8484324b66a36815019
This commit is contained in:
parent
1cbb7fa95c
commit
875bafa17a
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fuzzershell\senhancements:\s\s(1)\sAdd\sthe\s--verbose\sand\s--quiet\sflags\n(2)\sShow\spercentage\scomplete\sand\sfinal\stest\scount\sfor\smulti-test\sinputs\n(3)\sOmit\strace\sand\sresult\slogs\sunless\sthe\s--verbose\sflag\sis\sused.
|
||||
D 2015-04-24T13:00:59.981
|
||||
C Add\sthe\s--unique-cases\soption\sto\sfuzzershell.
|
||||
D 2015-04-24T14:47:59.444
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in faaf75b89840659d74501bea269c7e33414761c1
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -1204,7 +1204,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
|
||||
F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2
|
||||
F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1
|
||||
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
|
||||
F tool/fuzzershell.c 3be743ebd5b3180bbdb7c9697e24266f0310a2b3
|
||||
F tool/fuzzershell.c a49687f0d0eb3b60a9646054077127ae70273414
|
||||
F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
|
||||
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
|
||||
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
|
||||
@ -1252,7 +1252,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P b5e43602833249aa4b73337bf85b7f308450dab6
|
||||
R b0719606050e6afe7643fbdae717ee50
|
||||
P ed202ffac2eb85be9a18dca2a051ea3be16f8893
|
||||
R ecff9baf64ed1fb011f1359a05c25d2a
|
||||
U drh
|
||||
Z 31a0db1eda9943be19c2f2bb68a342b0
|
||||
Z 68bd4395db7df71bb884bf375d7fe437
|
||||
|
@ -1 +1 @@
|
||||
ed202ffac2eb85be9a18dca2a051ea3be16f8893
|
||||
7cb718491b5de77d4a73d8484324b66a36815019
|
@ -39,9 +39,8 @@
|
||||
**
|
||||
** where the "..." is arbitrary text, except the "|" should really be "/".
|
||||
** ("|" is used here to avoid compiler warnings about nested comments.)
|
||||
** Each such SQL comment is printed as it is encountered. A separate
|
||||
** in-memory SQLite database is created to run each chunk of SQL. This
|
||||
** feature allows the "queue" of AFL to be captured into a single big
|
||||
** A separate in-memory SQLite database is created to run each chunk of SQL.
|
||||
** This feature allows the "queue" of AFL to be captured into a single big
|
||||
** file using a command like this:
|
||||
**
|
||||
** (for i in id:*; do echo '|****<'$i'>****|'; cat $i; done) >~/all-queue.txt
|
||||
@ -49,11 +48,17 @@
|
||||
** (Once again, change the "|" to "/") Then all elements of the AFL queue
|
||||
** can be run in a single go (for regression testing, for example) by typing:
|
||||
**
|
||||
** fuzzershell -f ~/all-queue.txt >out.txt
|
||||
** fuzzershell -f ~/all-queue.txt
|
||||
**
|
||||
** After running each chunk of SQL, the database connection is closed. The
|
||||
** program aborts if the close fails or if there is any unfreed memory after
|
||||
** the close.
|
||||
**
|
||||
** New cases can be appended to all-queue.txt at any time. If redundant cases
|
||||
** are added, that can be eliminated by running:
|
||||
**
|
||||
** fuzzershell -f ~/all-queue.txt --unique-cases ~/unique-cases.txt
|
||||
**
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -246,21 +251,22 @@ static void showHelp(void){
|
||||
printf(
|
||||
"Read SQL text from standard input and evaluate it.\n"
|
||||
"Options:\n"
|
||||
" --autovacuum Enable AUTOVACUUM mode\n"
|
||||
" -f FILE Read SQL text from FILE instead of standard input\n"
|
||||
" --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n"
|
||||
" --help Show this help text\n"
|
||||
" --initdb DBFILE Initialize the in-memory database using template DBFILE\n"
|
||||
" --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n"
|
||||
" --pagesize N Set the page size to N\n"
|
||||
" --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n"
|
||||
" -q Reduced output\n"
|
||||
" --quiet Reduced output\n"
|
||||
" --scratch N SZ Configure scratch memory for N slots of SZ bytes each\n"
|
||||
" --utf16be Set text encoding to UTF-16BE\n"
|
||||
" --utf16le Set text encoding to UTF-16LE\n"
|
||||
" -v Increased output\n"
|
||||
" --verbose Increased output\n"
|
||||
" --autovacuum Enable AUTOVACUUM mode\n"
|
||||
" -f FILE Read SQL text from FILE instead of standard input\n"
|
||||
" --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n"
|
||||
" --help Show this help text\n"
|
||||
" --initdb DBFILE Initialize the in-memory database using template DBFILE\n"
|
||||
" --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n"
|
||||
" --pagesize N Set the page size to N\n"
|
||||
" --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n"
|
||||
" -q Reduced output\n"
|
||||
" --quiet Reduced output\n"
|
||||
" --scratch N SZ Configure scratch memory for N slots of SZ bytes each\n"
|
||||
" --unique-cases FILE Write all unique test cases to FILE\n"
|
||||
" --utf16be Set text encoding to UTF-16BE\n"
|
||||
" --utf16le Set text encoding to UTF-16LE\n"
|
||||
" -v Increased output\n"
|
||||
" --verbose Increased output\n"
|
||||
);
|
||||
}
|
||||
|
||||
@ -364,6 +370,9 @@ int main(int argc, char **argv){
|
||||
int nTest = 0; /* Number of test cases run */
|
||||
int multiTest = 0; /* True if there will be multiple test cases */
|
||||
int lastPct = -1; /* Previous percentage done output */
|
||||
sqlite3 *dataDb = 0; /* Database holding compacted input data */
|
||||
sqlite3_stmt *pStmt = 0; /* Statement to insert testcase into dataDb */
|
||||
const char *zDataOut = 0; /* Write compacted data to this output file */
|
||||
|
||||
|
||||
g.zArgv0 = argv[0];
|
||||
@ -439,6 +448,11 @@ int main(int argc, char **argv){
|
||||
szScratch = integerValue(argv[i+2]);
|
||||
i += 2;
|
||||
}else
|
||||
if( strcmp(z, "unique-cases")==0 ){
|
||||
if( i>=argc-1 ) abendError("missing arguments on %s", argv[i]);
|
||||
if( zDataOut ) abendError("only one --minimize allowed");
|
||||
zDataOut = argv[++i];
|
||||
}else
|
||||
if( strcmp(z,"utf16le")==0 ){
|
||||
zEncoding = "utf16le";
|
||||
}else
|
||||
@ -493,6 +507,17 @@ int main(int argc, char **argv){
|
||||
zIn[nIn] = 0;
|
||||
if( got==0 ) break;
|
||||
}
|
||||
if( in!=stdin ) fclose(in);
|
||||
if( zDataOut ){
|
||||
rc = sqlite3_open(":memory:", &dataDb);
|
||||
if( rc ) abendError("cannot open :memory: database");
|
||||
rc = sqlite3_exec(dataDb,
|
||||
"CREATE TABLE testcase(sql BLOB PRIMARY KEY) WITHOUT ROWID;",0,0,0);
|
||||
if( rc ) abendError("%s", sqlite3_errmsg(dataDb));
|
||||
rc = sqlite3_prepare_v2(dataDb, "INSERT OR IGNORE INTO testcase(sql)VALUES(?1)",
|
||||
-1, &pStmt, 0);
|
||||
if( rc ) abendError("%s", sqlite3_errmsg(dataDb));
|
||||
}
|
||||
if( zInitDb ){
|
||||
rc = sqlite3_open_v2(zInitDb, &dbInit, SQLITE_OPEN_READONLY, 0);
|
||||
if( rc!=SQLITE_OK ){
|
||||
@ -511,6 +536,13 @@ int main(int argc, char **argv){
|
||||
}
|
||||
}
|
||||
for(iNext=i; iNext<nIn && strncmp(&zIn[iNext],"/****<",6)!=0; iNext++){}
|
||||
if( zDataOut ){
|
||||
sqlite3_bind_blob(pStmt, 1, &zIn[i], iNext-i, SQLITE_STATIC);
|
||||
rc = sqlite3_step(pStmt);
|
||||
if( rc!=SQLITE_DONE ) abendError("%s", sqlite3_errmsg(dataDb));
|
||||
sqlite3_reset(pStmt);
|
||||
continue;
|
||||
}
|
||||
cSaved = zIn[iNext];
|
||||
zIn[iNext] = 0;
|
||||
if( zCkGlob && sqlite3_strglob(zCkGlob,&zIn[i])!=0 ){
|
||||
@ -591,7 +623,23 @@ int main(int argc, char **argv){
|
||||
}
|
||||
}
|
||||
if( nTest>1 && !quietFlag ){
|
||||
printf("%d tests with no errors\n", nTest);
|
||||
printf("%d tests with no errors\nSQLite %s %s\n",
|
||||
nTest, sqlite3_libversion(), sqlite3_sourceid());
|
||||
}
|
||||
if( zDataOut ){
|
||||
FILE *out = fopen(zDataOut, "wb");
|
||||
int n = 0;
|
||||
if( out==0 ) abendError("cannot open %s for writing", zDataOut);
|
||||
sqlite3_finalize(pStmt);
|
||||
rc = sqlite3_prepare_v2(dataDb, "SELECT sql FROM testcase", -1, &pStmt, 0);
|
||||
if( rc ) abendError("%s", sqlite3_errmsg(dataDb));
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||
fprintf(out,"/****<%d>****/", ++n);
|
||||
fwrite(sqlite3_column_blob(pStmt,0),sqlite3_column_bytes(pStmt,0),1,out);
|
||||
}
|
||||
fclose(out);
|
||||
sqlite3_finalize(pStmt);
|
||||
sqlite3_close(dataDb);
|
||||
}
|
||||
free(zIn);
|
||||
free(pHeap);
|
||||
|
Loading…
x
Reference in New Issue
Block a user