]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fuzzershell enhancements: (1) Add the --verbose and --quiet flags
authordrh <drh@noemail.net>
Fri, 24 Apr 2015 13:00:59 +0000 (13:00 +0000)
committerdrh <drh@noemail.net>
Fri, 24 Apr 2015 13:00:59 +0000 (13:00 +0000)
(2) Show percentage complete and final test count for multi-test inputs
(3) Omit trace and result logs unless the --verbose flag is used.

FossilOrigin-Name: ed202ffac2eb85be9a18dca2a051ea3be16f8893

manifest
manifest.uuid
tool/fuzzershell.c

index d1717e9040c08d2767c6f97d3854d9727259596c..f376c2c1f082f79e7c1e4c985aab0802cd6561db 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sfaulty\sassert()\sin\sthe\s"AS"\salias\sresolution\slogic\sof\sthe\sparser.
-D 2015-04-23T13:37:05.307
+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
 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 bcdca60b54654c8fc25fd215953d9b6bb55fd7d4
+F tool/fuzzershell.c 3be743ebd5b3180bbdb7c9697e24266f0310a2b3
 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 01c50cee37bfaddfecdda014728c35a1be1d991a
-R b16870d1654f6de484a72bbc7fa9d1f0
+P b5e43602833249aa4b73337bf85b7f308450dab6
+R b0719606050e6afe7643fbdae717ee50
 U drh
-Z cee60c918913e56f32da2a16c41282ec
+Z 31a0db1eda9943be19c2f2bb68a342b0
index 77658405b16edb8871fdec4f21c98b6c33a943e9..314cf594a03ac39bf2a8557257cc58b5e182fa67 100644 (file)
@@ -1 +1 @@
-b5e43602833249aa4b73337bf85b7f308450dab6
\ No newline at end of file
+ed202ffac2eb85be9a18dca2a051ea3be16f8893
\ No newline at end of file
index c13046050900c536e248e619cfd4d9bb0bf34ba1..dbfa77c0fc78662c12aaaae94e9b2561275071fd 100644 (file)
@@ -138,6 +138,9 @@ static int execCallback(void *NotUsed, int argc, char **argv, char **colv){
   }
   return 0;
 }
+static int execNoop(void *NotUsed, int argc, char **argv, char **colv){
+  return 0;
+}
 
 /*
 ** This callback is invoked by sqlite3_trace() as each SQL statement
@@ -251,9 +254,13 @@ static void showHelp(void){
 "  --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"
   );
 }
 
@@ -352,6 +359,11 @@ int main(int argc, char **argv){
   char *zToFree = 0;            /* Call sqlite3_free() on this afte running zSql */
   int iMode = FZMODE_Generic;   /* Operating mode */
   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 */
+  int multiTest = 0;            /* True if there will be multiple test cases */
+  int lastPct = -1;             /* Previous percentage done output */
 
 
   g.zArgv0 = argv[0];
@@ -417,6 +429,10 @@ int main(int argc, char **argv){
         szPCache = integerValue(argv[i+2]);
         i += 2;
       }else
+      if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
+        quietFlag = 1;
+        verboseFlag = 0;
+      }else
       if( strcmp(z,"scratch")==0 ){
         if( i>=argc-2 ) abendError("missing arguments on %s", argv[i]);
         nScratch = integerValue(argv[i+1]);
@@ -429,6 +445,10 @@ int main(int argc, char **argv){
       if( strcmp(z,"utf16be")==0 ){
         zEncoding = "utf16be";
       }else
+      if( strcmp(z,"verbose")==0 || strcmp(z,"v")==0 ){
+        quietFlag = 0;
+        verboseFlag = 1;
+      }else
       {
         abendError("unknown option: %s", argv[i]);
       }
@@ -436,7 +456,7 @@ int main(int argc, char **argv){
       abendError("unknown argument: %s", argv[i]);
     }
   }
-  sqlite3_config(SQLITE_CONFIG_LOG, shellLog, 0);
+  if( verboseFlag ) sqlite3_config(SQLITE_CONFIG_LOG, shellLog, 0);
   if( nHeap>0 ){
     pHeap = malloc( nHeap );
     if( pHeap==0 ) fatalError("cannot allocate %d-byte heap\n", nHeap);
@@ -479,14 +499,15 @@ int main(int argc, char **argv){
       abendError("unable to open initialization database \"%s\"", zInitDb);
     }
   }
-  for(i=0; i<nIn; i=iNext){
+  for(i=nTest=0; i<nIn; i=iNext, nTest++){
     char cSaved;
     if( strncmp(&zIn[i], "/****<",6)==0 ){
       char *z = strstr(&zIn[i], ">****/");
       if( z ){
         z += 6;
-        printf("%.*s\n", (int)(z-&zIn[i]), &zIn[i]);
+        if( verboseFlag ) printf("%.*s\n", (int)(z-&zIn[i]), &zIn[i]);
         i += (int)(z-&zIn[i]);
+        multiTest = 1;
       }
     }
     for(iNext=i; iNext<nIn && strncmp(&zIn[iNext],"/****<",6)!=0; iNext++){}
@@ -517,16 +538,25 @@ int main(int argc, char **argv){
       }
       sqlite3_backup_finish(pBackup);
     }
-    sqlite3_trace(db, traceCallback, 0);
+    if( verboseFlag ) sqlite3_trace(db, traceCallback, 0);
     sqlite3_create_function(db, "eval", 1, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0);
     sqlite3_create_function(db, "eval", 2, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0);
     sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 1000000);
     if( zEncoding ) sqlexec(db, "PRAGMA encoding=%s", zEncoding);
     if( pageSize ) sqlexec(db, "PRAGMA pagesize=%d", pageSize);
     if( doAutovac ) sqlexec(db, "PRAGMA auto_vacuum=FULL");
-    printf("INPUT (offset: %d, size: %d): [%s]\n",
-            i, (int)strlen(&zIn[i]), &zIn[i]);
     zSql = &zIn[i];
+    if( verboseFlag ){
+      printf("INPUT (offset: %d, size: %d): [%s]\n",
+              i, (int)strlen(&zIn[i]), &zIn[i]);
+    }else if( multiTest && !quietFlag ){
+      int pct = 100*(i+strlen(zSql))/nIn;
+      if( pct!=lastPct ){
+        printf("%d%%\r", pct);
+        fflush(stdout);
+        lastPct = pct;
+      }
+    }
     switch( iMode ){
       case FZMODE_Glob:
         zSql = zToFree = sqlite3_mprintf("SELECT glob(%s);", zSql);
@@ -538,18 +568,20 @@ int main(int argc, char **argv){
         zSql = zToFree = sqlite3_mprintf("SELECT strftime(%s);", zSql);
         break;
     }
-    rc = sqlite3_exec(db, zSql, execCallback, 0, &zErrMsg);
+    zErrMsg = 0;
+    rc = sqlite3_exec(db, zSql, verboseFlag ? execCallback : execNoop, 0, &zErrMsg);
     if( zToFree ){
       sqlite3_free(zToFree);
       zToFree = 0;
     }
     zIn[iNext] = cSaved;
-
-    printf("RESULT-CODE: %d\n", rc);
-    if( zErrMsg ){
-      printf("ERROR-MSG: [%s]\n", zErrMsg);
-      sqlite3_free(zErrMsg);
+    if( verboseFlag ){
+      printf("RESULT-CODE: %d\n", rc);
+      if( zErrMsg ){
+        printf("ERROR-MSG: [%s]\n", zErrMsg);
+      }
     }
+    sqlite3_free(zErrMsg);
     rc = sqlite3_close(db);
     if( rc ){
       abendError("sqlite3_close() failed with rc=%d", rc);
@@ -558,6 +590,9 @@ int main(int argc, char **argv){
       abendError("memory in use after close: %lld bytes", sqlite3_memory_used());
     }
   }
+  if( nTest>1 && !quietFlag ){
+    printf("%d tests with no errors\n", nTest);
+  }
   free(zIn);
   free(pHeap);
   free(pLook);