]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance the fuzzcheck testing tool with new command-line options:
authordrh <>
Sat, 15 Mar 2025 23:42:32 +0000 (23:42 +0000)
committerdrh <>
Sat, 15 Mar 2025 23:42:32 +0000 (23:42 +0000)
--brief, and --slice M N.

FossilOrigin-Name: e64132723db0c4f2b9a58932a93beb1671e42006eebc1aeaa8f320e717043051

manifest
manifest.uuid
test/fuzzcheck.c

index 3abd0f8344e0c2e09e03fbdc6d331f7fea2f1388..dc9851a03aba021515b29f0943386553a01c2fc9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Make\suse\sof\sthe\sC99\sflexible\sarray\sfeature,\swhen\savailable,\sso\sthat\nthe\s-fsanitize=bounds-strict\soption\scan\sbe\sused,\swhen\savailable.\n[forum:/forumpost/311dbf9a1cadfae6|Forum\sthread\s311dbf9a1c].
-D 2025-03-15T19:55:19.890
+C Enhance\sthe\sfuzzcheck\stesting\stool\swith\snew\scommand-line\soptions:\n--brief,\sand\s--slice\sM\sN.
+D 2025-03-15T23:42:32.735
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
@@ -1278,7 +1278,7 @@ F test/fuzz3.test 70ba57260364b83e964707b9d4b5625284239768ab907dd387c740c0370ce3
 F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830
 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
-F test/fuzzcheck.c e94511f5f5b8c134c83535b4799004b85ead69ed8375d74e9af90e41549a82ad
+F test/fuzzcheck.c 19f8af47a5c4ee2c3943fdee270f1f14e3d83fe968a9737a7557fb4e3c06efc1
 F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517
 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -2213,9 +2213,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 2dd5b6895a3b23c2b9cbf0c1c1e802faf8f2b41ef60819eea25d609755266e64 f101c46cf83e532fd33034abccba496bf395ef10c161af003211614d6581d5eb
-R cffcee5ac5b13fdb08ee088881970bf2
-T +closed f101c46cf83e532fd33034abccba496bf395ef10c161af003211614d6581d5eb
+P d4307a0d43f42e96ec06ad2c1d8d0f5c8ecae759bae8231b1998633089809f49
+R b41c223f32c59ab49558d35f05a2bfa9
 U drh
-Z 5f005a89032955065b39a2e143d5c279
+Z 01a995e61d39142e747ab20e203c7c6f
 # Remove this line to create a well-formed Fossil manifest.
index d6e3fced3adfabaa4b8569c315b816750f10d9ff..ed9e64db29bbfcbc8c28c460df378326e8834970 100644 (file)
@@ -1 +1 @@
-d4307a0d43f42e96ec06ad2c1d8d0f5c8ecae759bae8231b1998633089809f49
+e64132723db0c4f2b9a58932a93beb1671e42006eebc1aeaa8f320e717043051
index 7d5da2ce2787b5617e71da52adf5cb58b0999da0..09898d7b35fc6c6f7e8a3f78260eb58297210785 100644 (file)
@@ -391,6 +391,21 @@ static void renderDbSqlForCLI(
   if( nSql>0 && zSql[nSql-1]!='\n' ) fprintf(out, "\n");
 }
 
+/*
+** Find the tail (the last component) of a pathname.
+*/
+static const char *pathTail(const char *zPath){
+  const char *zTail = zPath;
+  while( zPath[0] ){
+    if( zPath[0]=='/' && zPath[1]!=0 ) zTail = &zPath[1];
+#ifndef __unix__
+    if( zPath[0]=='\\' && zPath[1]!=0 ) zTail = &zPath[1];
+#endif
+    zPath++;
+  }
+  return zTail;
+}
+
 /*
 ** Read the complete content of a file into memory.  Add a 0x00 terminator
 ** and return a pointer to the result.
@@ -1847,6 +1862,7 @@ static void showHelp(void){
 "Read databases and SQL scripts from SOURCE-DB and execute each script against\n"
 "each database, checking for crashes and memory leaks.\n"
 "Options:\n"
+"  --brief              Output only a summary of results at the end\n"
 "  --cell-size-check    Set the PRAGMA cell_size_check=ON\n"
 "  --dbid M..N          Use only the databases where dbid between M and N\n"
 "                       \"M..\" for M and afterwards. Just \"M\" for M only\n"
@@ -1873,6 +1889,7 @@ static void showHelp(void){
 "  --result-trace       Show the results of each SQL command\n"
 "  --script             Output CLI script instead of running tests\n"
 "  --skip N             Skip the first N test cases\n"
+"  --slice M N          Run only the M-th out of each group of N tests\n"
 "  --spinner            Use a spinner to show progress\n"
 "  --sqlid M..N         Use only SQL where sqlid between M..N\n"
 "                       \"M..\" for M and afterwards. Just \"M\" for M only\n"
@@ -1887,6 +1904,7 @@ static void showHelp(void){
 int main(int argc, char **argv){
   sqlite3_int64 iBegin;        /* Start time of this program */
   int quietFlag = 0;           /* True if --quiet or -q */
+  int briefFlag = 0;           /* Output summary report at the end */
   int verboseFlag = 0;         /* True if --verbose or -v */
   char *zInsSql = 0;           /* SQL statement for --load-db or --load-sql */
   int iFirstInsArg = 0;        /* First argv[] for --load-db or --load-sql */
@@ -1934,6 +1952,8 @@ int main(int argc, char **argv){
   int nV;                      /* How much to increase verbosity with -vvvv */
   sqlite3_int64 tmStart;       /* Start of each test */
   int iEstTime = 0;            /* LPF for the time-to-go */
+  int iSliceSz = 0;            /* Divide the test space into this many pieces */
+  int iSliceIdx = 0;           /* Only run the piece with this index */
 
   sqlite3_config(SQLITE_CONFIG_URI,1);
   registerOomSimulator();
@@ -1954,6 +1974,12 @@ int main(int argc, char **argv){
     if( z[0]=='-' ){
       z++;
       if( z[0]=='-' ) z++;
+      if( strcmp(z,"brief")==0 ){
+        briefFlag = 1;
+        quietFlag = 1;
+        verboseFlag = 1;
+        eVerbosity = 0;
+      }else
       if( strcmp(z,"cell-size-check")==0 ){
         cellSzCkFlag = 1;
       }else
@@ -2044,6 +2070,7 @@ int main(int argc, char **argv){
         g.uRandom = atoi(argv[++i]);
       }else
       if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
+        briefFlag = 0;
         quietFlag = 1;
         verboseFlag = 0;
         eVerbosity = 0;
@@ -2062,12 +2089,19 @@ int main(int argc, char **argv){
         if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
         nSkip = atoi(argv[++i]);
       }else
+      if( strcmp(z,"slice")==0 ){
+        if( i>=argc-2 ) fatalError("missing arguments on %s", argv[i]);
+        iSliceIdx = integerValue(argv[++i]);
+        iSliceSz = integerValue(argv[++i]);
+        /* --slice implices --brief */
+        briefFlag = 1;
+        quietFlag = 1;
+        verboseFlag = 1;
+        eVerbosity = 0;
+      }else
       if( strcmp(z,"spinner")==0 ){
         bSpinner = 1;
       }else
-      if( strcmp(z,"timer")==0 ){
-        bTimer = 1;
-      }else
       if( strcmp(z,"sqlid")==0 ){
         const char *zDotDot;
         if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
@@ -2093,10 +2127,14 @@ int main(int argc, char **argv){
         fatalError("timeout is not available on non-unix systems");
 #endif
       }else
+      if( strcmp(z,"timer")==0 ){
+        bTimer = 1;
+      }else
       if( strcmp(z,"vdbe-debug")==0 ){
         bVdbeDebug = 1;
       }else
       if( strcmp(z,"verbose")==0 ){
+        briefFlag = 0;
         quietFlag = 0;
         verboseFlag++;
         eVerbosity++;
@@ -2163,6 +2201,12 @@ int main(int argc, char **argv){
       fatalError("cannot import into more than one database");
     }
   }
+  if( iSliceSz<=iSliceIdx 
+   || iSliceSz<=0
+   || iSliceIdx<0
+  ){
+    iSliceSz = iSliceIdx = 0;
+  }
 
   /* Process each source database separately */
   for(iSrcDb=0; iSrcDb<nSrcDb; iSrcDb++){
@@ -2452,6 +2496,10 @@ int main(int argc, char **argv){
     for(pSql=g.pFirstSql; pSql; pSql=pSql->pNext){
       tmStart = timeOfDay();
       if( isDbSql(pSql->a, pSql->sz) ){
+        if( iSliceSz>0 && (nTest%iSliceSz)!=iSliceIdx ){
+          nTest++;
+          continue;
+        }
         sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, "sqlid=%d",pSql->id);
         if( bScript ){
           /* No progress output */
@@ -2510,6 +2558,10 @@ int main(int argc, char **argv){
       for(pDb=g.pFirstDb; pDb; pDb=pDb->pNext){
         int openFlags;
         const char *zVfs = "inmem";
+        if( iSliceSz>0 && (nTest%iSliceSz)!=iSliceIdx ){
+          nTest++;
+          continue;
+        }
         sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, "sqlid=%d,dbid=%d",
                          pSql->id, pDb->id);
         if( bScript ){
@@ -2616,7 +2668,20 @@ int main(int argc, char **argv){
         }
       }
     }
-    if( bScript ){
+    if( briefFlag ){
+      sqlite3_int64 iElapse = timeOfDay() - iBegin;
+      if( iSliceSz>0 ){
+        printf("%s %s: slice %d/%d of %d tests, %d.%03d seconds\n",
+               pathTail(argv[0]), pathTail(g.zDbFile),
+               iSliceIdx, iSliceSz, nTest,
+               (int)(iElapse/1000), (int)(iElapse%1000));
+      }else{
+        printf("%s %s: 0 errors, %d tests, %d.%03d seconds\n",
+               pathTail(argv[0]), pathTail(g.zDbFile), nTest,
+               (int)(iElapse/1000), (int)(iElapse%1000));
+      }
+      iBegin = timeOfDay();
+    }else if( bScript ){
       /* No progress output */
     }else if( bSpinner ){
       int nTotal = g.nDb*g.nSql;
@@ -2634,6 +2699,7 @@ int main(int argc, char **argv){
  
   } /* End loop over all source databases */
 
+           
   if( !quietFlag && !bScript ){
     sqlite3_int64 iElapse = timeOfDay() - iBegin;
     if( g.nInvariant ){