aboutsummaryrefslogtreecommitdiff
path: root/tool/fuzzershell.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-05-02 19:54:35 +0000
committerdrh <drh@noemail.net>2015-05-02 19:54:35 +0000
commit1a57c17d0f818fadfce2fc592bc33d9cdf050fed (patch)
treeed7312cdae92f5bad69867590473910a4866b125 /tool/fuzzershell.c
parent1a51337af831b65b61934e4b26ca8cd8dc63a947 (diff)
downloadsqlite-1a57c17d0f818fadfce2fc592bc33d9cdf050fed.tar.gz
sqlite-1a57c17d0f818fadfce2fc592bc33d9cdf050fed.zip
Improvements to fuzzershell: Avoid excess memory allocations when loading
many files. Show the total runtime on final output. Show individual filenames as they are processed even if they are single test-case files. FossilOrigin-Name: 34a722a2f3331c35211526c9ec055d4d9175c965
Diffstat (limited to 'tool/fuzzershell.c')
-rw-r--r--tool/fuzzershell.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c
index 6d12a2979..4eea55ba0 100644
--- a/tool/fuzzershell.c
+++ b/tool/fuzzershell.c
@@ -451,9 +451,10 @@ 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 iBegin; /* Start time for the whole program */
sqlite3_int64 iStart, iEnd; /* Start and end-times for a test case */
-
+ iBegin = timeOfDay();
zFailCode = getenv("TEST_FAILURE");
g.zArgv0 = argv[0];
zPrompt = "<stdin>";
@@ -612,13 +613,15 @@ int main(int argc, char **argv){
zPrompt = "<stdin>";
}
while( !feof(in) ){
- zIn = realloc(zIn, nAlloc);
- if( zIn==0 ) fatalError("out of memory");
got = fread(zIn+nIn, 1, nAlloc-nIn-1, in);
nIn += (int)got;
zIn[nIn] = 0;
if( got==0 ) break;
- nAlloc += nAlloc+1000;
+ if( nAlloc - nIn - 1 < 100 ){
+ nAlloc += nAlloc+1000;
+ zIn = realloc(zIn, nAlloc);
+ if( zIn==0 ) fatalError("out of memory");
+ }
}
if( in!=stdin ) fclose(in);
lastPct = -1;
@@ -670,6 +673,8 @@ int main(int argc, char **argv){
lastPct = pct;
}
}
+ }else if( nInFile>1 ){
+ printf("%s\n", zPrompt);
}
fflush(stdout);
@@ -803,8 +808,10 @@ int main(int argc, char **argv){
/* Report total number of tests run
*/
if( nTest>1 && !quietFlag ){
- printf("%s: 0 errors out of %d tests\nSQLite %s %s\n",
- g.zArgv0, nTest, sqlite3_libversion(), sqlite3_sourceid());
+ sqlite3_int64 iElapse = timeOfDay() - iBegin;
+ printf("%s: 0 errors out of %d tests in %d.%03d seconds\nSQLite %s %s\n",
+ g.zArgv0, nTest, (int)(iElapse/1000), (int)(iElapse%1000),
+ sqlite3_libversion(), sqlite3_sourceid());
}
/* Write the unique test cases if the --unique-cases flag was used