Enhance the fuzzershell --uniquecases option to output results in order of

increasing runtime and to include the runtime in the comment separator of
the output.

FossilOrigin-Name: 04630b989d8794b9ed2553f4d223de2b322437c5
This commit is contained in:
drh 2015-05-01 20:34:47 +00:00
parent b3df0c675c
commit c843016e36
3 changed files with 42 additions and 28 deletions

View File

@ -1,5 +1,5 @@
C Enhance\sfuzzershell\sto\saccept\smultiple\sinput\sfiles.\s\sAdd\sthe\stest/fuzzdata2.txt\nfuzz\stest\scontent.
D 2015-05-01T19:21:12.995
C Enhance\sthe\sfuzzershell\s--uniquecases\soption\sto\soutput\sresults\sin\sorder\sof\nincreasing\sruntime\sand\sto\sinclude\sthe\sruntime\sin\sthe\scomment\sseparator\sof\nthe\soutput.
D 2015-05-01T20:34:47.283
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e628c50e237251fc7e768bef14ee7e822ad69e69
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -1208,7 +1208,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 32816d2c54e7243504ab8af6d9b4323ed1206342
F tool/fuzzershell.c beafb3f10b02fedab02d364054290d93cfa42c8e
F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
@ -1256,7 +1256,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 9a45409cc4078f2b6e68aa777f6ab86a14309833
R 3a133cb00e1f62fffce773de23d1e308
P ab5523aafe4817232388d28ea99be0953e7dccf3
R 4fd9e5d40fbea2385d9a56050bcd9320
U drh
Z 8894bd22b6f91dc8094aac398d313abb
Z 553d78dd29d30462935dd4f96d370f3a

View File

@ -1 +1 @@
ab5523aafe4817232388d28ea99be0953e7dccf3
04630b989d8794b9ed2553f4d223de2b322437c5

View File

@ -396,6 +396,20 @@ static int integerValue(const char *zArg){
return (int)(isNeg? -v : v);
}
/* Return the current wall-clock time */
static sqlite3_int64 timeOfDay(void){
static sqlite3_vfs *clockVfs = 0;
sqlite3_int64 t;
if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){
clockVfs->xCurrentTimeInt64(clockVfs, &t);
}else{
double r;
clockVfs->xCurrentTime(clockVfs, &r);
t = (sqlite3_int64)(r*86400000.0);
}
return t;
}
int main(int argc, char **argv){
char *zIn = 0; /* Input text */
@ -420,7 +434,6 @@ int main(int argc, char **argv){
int doAutovac = 0; /* True for --autovacuum */
char *zSql; /* SQL to run */
char *zToFree = 0; /* Call sqlite3_free() on this afte running zSql */
const char *zCkGlob = 0; /* Inputs must match this glob */
int verboseFlag = 0; /* --verbose or -v flag */
int quietFlag = 0; /* --quiet or -q flag */
int nTest = 0; /* Number of test cases run */
@ -438,6 +451,7 @@ int main(int argc, char **argv){
int nInFile = 0; /* Number of input files to read */
char **azInFile = 0; /* Array of input file names */
int jj; /* Loop counter for azInFile[] */
sqlite3_int64 iStart, iEnd; /* Start and end-times for a test case */
zFailCode = getenv("TEST_FAILURE");
@ -565,10 +579,10 @@ int main(int argc, char **argv){
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);
"CREATE TABLE testcase(sql BLOB PRIMARY KEY, tm) 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)",
"INSERT OR IGNORE INTO testcase(sql,tm)VALUES(?1,?2)",
-1, &pStmt, 0);
if( rc ) abendError("%s", sqlite3_errmsg(dataDb));
}
@ -635,23 +649,9 @@ int main(int argc, char **argv){
}
}
for(iNext=i; iNext<nIn && strncmp(&zIn[iNext],"/****<",6)!=0; iNext++){}
/* Store unique test cases in the in the dataDb database if the
** --unique-cases flag is present
*/
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 ){
zIn[iNext] = cSaved;
continue;
}
/* Print out the SQL of the next test case is --verbose is enabled
*/
@ -707,6 +707,7 @@ int main(int argc, char **argv){
if( zEncoding ) sqlexec(db, "PRAGMA encoding=%s", zEncoding);
if( pageSize ) sqlexec(db, "PRAGMA pagesize=%d", pageSize);
if( doAutovac ) sqlexec(db, "PRAGMA auto_vacuum=FULL");
iStart = timeOfDay();
g.bOomEnable = 1;
if( verboseFlag ){
zErrMsg = 0;
@ -719,11 +720,12 @@ int main(int argc, char **argv){
rc = sqlite3_exec(db, zSql, execNoop, 0, 0);
}
g.bOomEnable = 0;
iEnd = timeOfDay();
rc = sqlite3_close(db);
if( rc ){
abendError("sqlite3_close() failed with rc=%d", rc);
}
if( sqlite3_memory_used()>0 ){
if( !zDataOut && sqlite3_memory_used()>0 ){
abendError("memory in use after close: %lld bytes",sqlite3_memory_used());
}
if( oomFlag ){
@ -751,6 +753,17 @@ int main(int argc, char **argv){
}
}while( oomCnt>0 );
/* Store unique test cases in the in the dataDb database if the
** --unique-cases flag is present
*/
if( zDataOut ){
sqlite3_bind_blob(pStmt, 1, &zIn[i], iNext-i, SQLITE_STATIC);
sqlite3_bind_int64(pStmt, 2, iEnd - iStart);
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_DONE ) abendError("%s", sqlite3_errmsg(dataDb));
sqlite3_reset(pStmt);
}
/* Free the SQL from the current test case
*/
if( zToFree ){
@ -802,10 +815,11 @@ int main(int argc, char **argv){
if( out==0 ) abendError("cannot open %s for writing", zDataOut);
if( nHeader>0 ) fwrite(zIn, nHeader, 1, out);
sqlite3_finalize(pStmt);
rc = sqlite3_prepare_v2(dataDb, "SELECT sql FROM testcase", -1, &pStmt, 0);
rc = sqlite3_prepare_v2(dataDb, "SELECT sql, tm FROM testcase ORDER BY tm, sql",
-1, &pStmt, 0);
if( rc ) abendError("%s", sqlite3_errmsg(dataDb));
while( sqlite3_step(pStmt)==SQLITE_ROW ){
fprintf(out,"/****<%d>****/", ++n);
fprintf(out,"/****<%d:%dms>****/", ++n, sqlite3_column_int(pStmt,1));
fwrite(sqlite3_column_blob(pStmt,0),sqlite3_column_bytes(pStmt,0),1,out);
}
fclose(out);