]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the --timer option to fuzzcheck. Get the --timeout option working in
authordrh <drh@noemail.net>
Mon, 21 Dec 2020 12:14:59 +0000 (12:14 +0000)
committerdrh <drh@noemail.net>
Mon, 21 Dec 2020 12:14:59 +0000 (12:14 +0000)
fuzzcheck when running dbsql tests.

FossilOrigin-Name: 3b0c9b41a877c7344ef3b7c5b6981436005716e25b41b1a1ffc145520243abd3

manifest
manifest.uuid
test/fuzzcheck.c

index a355d7e3c67560564eb28b65c50627b4772d63cc..d01d5241ed75cfdbe9fee98ceb68fc5df343b964 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Always\sdeclare\sthe\ssqlite3WhereTrace\svariable,\seven\sfor\snon-debug\sbuilds.
-D 2020-12-20T14:51:17.806
+C Add\sthe\s--timer\soption\sto\sfuzzcheck.\s\sGet\sthe\s--timeout\soption\sworking\sin\nfuzzcheck\swhen\srunning\sdbsql\stests.
+D 2020-12-21T12:14:59.759
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -1035,7 +1035,7 @@ F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c
 F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830
 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
-F test/fuzzcheck.c 5f81f2cc65f13068620245f2e2c6059657d3b26be476df379ae2da539f17676d
+F test/fuzzcheck.c 95427205d6cedb8fdb95bf7738e95785c790febf782d9c1e6067baaa1adc871d
 F test/fuzzdata1.db d36e88741b4f23bcbaaf55b006290669d03c6c891cf13c7b3a53bc1b097b693f
 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -1893,7 +1893,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b79f59f9ad897d5bd4b9d17e6219bc765b02450bfe14dc020485f221ba6b02cb
-R 44577f8a1c7518c34582de96a91b2e8b
+P 88d93ee380b6fd87474545f20ade874ba05c784c787ce9c45ebfcffed3795308
+R 27ec1c9c08574b257c1035ec83dd9754
 U drh
-Z 174bdbab8294579fbf084a8c0c09510f
+Z b0ca2a90328c04cad0677f000624e900
index a92964c8e90043e51573d8c067539905f7cb288a..8e9af402ebc4d1f4c3994aa6528697130b4f495d 100644 (file)
@@ -1 +1 @@
-88d93ee380b6fd87474545f20ade874ba05c784c787ce9c45ebfcffed3795308
\ No newline at end of file
+3b0c9b41a877c7344ef3b7c5b6981436005716e25b41b1a1ffc145520243abd3
\ No newline at end of file
index cf49956b471260269b0fbf934d35e2582e97d4cd..c6ad4cd5c3799dc726f2e086a73769edb35a50ff 100644 (file)
@@ -455,7 +455,12 @@ static void blobListFree(Blob *p){
   }
 }
 
-/* Return the current wall-clock time */
+/* Return the current wall-clock time
+**
+** The number of milliseconds since the julian epoch.
+** 1907-01-01 00:00:00  ->  210866716800000
+** 2021-01-01 00:00:00  ->  212476176000000
+*/
 static sqlite3_int64 timeOfDay(void){
   static sqlite3_vfs *clockVfs = 0;
   sqlite3_int64 t;
@@ -713,6 +718,7 @@ static int progress_handler(void *pClientData) {
   sqlite3_int64 iNow = timeOfDay();
   int rc = iNow>=p->iCutoffTime;
   sqlite3_int64 iDiff = iNow - p->iLastCb;
+  /* printf("time-remaining: %lld\n", p->iCutoffTime - iNow); */
   if( iDiff > p->mxInterval ) p->mxInterval = iDiff;
   p->nCb++;
   if( rc==0 && p->mxCb>0 && p->mxCb<=p->nCb ) rc = 1;
@@ -835,7 +841,7 @@ static int runDbSql(sqlite3 *db, const char *zSql){
 }
 
 /* Invoke this routine to run a single test case */
-int runCombinedDbSqlInput(const uint8_t *aData, size_t nByte){
+int runCombinedDbSqlInput(const uint8_t *aData, size_t nByte, int iTimeout){
   int rc;                    /* SQLite API return value */
   int iSql;                  /* Index in aData[] of start of SQL */
   unsigned char *aDb = 0;    /* Decoded database content */
@@ -882,7 +888,7 @@ int runCombinedDbSqlInput(const uint8_t *aData, size_t nByte){
   ** elapsed since the start of the test.
   */
   cx.iLastCb = timeOfDay();
-  cx.iCutoffTime = cx.iLastCb + giTimeout;  /* Now + giTimeout seconds */
+  cx.iCutoffTime = cx.iLastCb + (iTimeout<giTimeout ? iTimeout : giTimeout);
   cx.mxCb = mxProgressCb;
 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
   sqlite3_progress_handler(cx.db, 10, progress_handler, (void*)&cx);
@@ -1433,7 +1439,7 @@ static void showHelp(void){
 "  --skip N             Skip the first N test cases\n"
 "  --spinner            Use a spinner to show progress\n"
 "  --sqlid N            Use only SQL where sqlid=N\n"
-"  --timeout N          Abort if any single test needs more than N seconds\n"
+"  --timeout N          Maximum time for any one test in N millseconds\n"
 "  -v|--verbose         Increased output.  Repeat for more output.\n"
 "  --vdbe-debug         Activate VDBE debugging.\n"
   );
@@ -1471,7 +1477,7 @@ int main(int argc, char **argv){
   const char *zFailCode = 0;   /* Value of the TEST_FAILURE env variable */
   int cellSzCkFlag = 0;        /* --cell-size-check */
   int sqlFuzz = 0;             /* True for SQL fuzz. False for DB fuzz */
-  int iTimeout = 120;          /* Default 120-second timeout */
+  int iTimeout = 120000;       /* Default 120-second timeout */
   int nMem = 0;                /* Memory limit override */
   int nMemThisDb = 0;          /* Memory limit set by the CONFIG table */
   char *zExpDb = 0;            /* Write Databases to files in this directory */
@@ -1482,7 +1488,9 @@ int main(int argc, char **argv){
   int nativeMalloc = 0;        /* Turn off MEMSYS3/5 and lookaside if true */
   sqlite3_vfs *pDfltVfs;       /* The default VFS */
   int openFlags4Data;          /* Flags for sqlite3_open_v2() */
+  int bTimer = 0;              /* Show elapse time for each test */
   int nV;                      /* How much to increase verbosity with -vvvv */
+  sqlite3_int64 tmStart;       /* Start of each test */
 
   registerOomSimulator();
   sqlite3_initialize();
@@ -1597,6 +1605,9 @@ int main(int argc, char **argv){
       if( strcmp(z,"spinner")==0 ){
         bSpinner = 1;
       }else
+      if( strcmp(z,"timer")==0 ){
+        bTimer = 1;
+      }else
       if( strcmp(z,"sqlid")==0 ){
         if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
         onlySqlid = integerValue(argv[++i]);
@@ -1894,6 +1905,7 @@ int main(int argc, char **argv){
     */
     if( !verboseFlag && !quietFlag && !bSpinner ) printf("%s:", zDbName);
     for(pSql=g.pFirstSql; pSql; pSql=pSql->pNext){
+      tmStart = timeOfDay();
       if( isDbSql(pSql->a, pSql->sz) ){
         sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, "sqlid=%d",pSql->id);
         if( bSpinner ){
@@ -1917,9 +1929,13 @@ int main(int argc, char **argv){
         if( nSkip>0 ){
           nSkip--;
         }else{
-          runCombinedDbSqlInput(pSql->a, pSql->sz);
+          runCombinedDbSqlInput(pSql->a, pSql->sz, iTimeout);
         }
         nTest++;
+        if( bTimer ){
+          sqlite3_int64 tmEnd = timeOfDay();
+          printf("%lld %s\n", tmEnd - tmStart, g.zTestName);
+        }
         g.zTestName[0] = 0;
         disableOom();
         continue;
@@ -1972,7 +1988,7 @@ int main(int argc, char **argv){
           sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 100000000);
           sqlite3_limit(db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH, 50);
           if( cellSzCkFlag ) runSql(db, "PRAGMA cell_size_check=ON", runFlags);
-          setAlarm(iTimeout);
+          setAlarm((iTimeout+999)/1000);
 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
           if( sqlFuzz || vdbeLimitFlag ){
             sqlite3_progress_handler(db, 100000, progressHandler,
@@ -1998,6 +2014,10 @@ int main(int argc, char **argv){
         }
         reformatVfs();
         nTest++;
+        if( bTimer ){
+          sqlite3_int64 tmEnd = timeOfDay();
+          printf("%lld %s\n", tmEnd - tmStart, g.zTestName);
+        }
         g.zTestName[0] = 0;
 
         /* Simulate an error if the TEST_FAILURE environment variable is "5".