/ Check-in [1ef24e89]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved automatic detection of dbsqlfuzz cases in fuzzcheck.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dbsqlfuzz-in-fuzzcheck
Files: files | file ages | folders
SHA3-256:1ef24e89c9630fd383ba32f5aefcf9c27907f27f5072f3537a1cfd75a093a8d7
User & Date: drh 2019-01-25 04:43:26
Context
2019-01-25
13:03
In fuzzcheck, activate vdbe_debug for dbsqlfuzz cases when using the -vvvvv verbosity level or above. check-in: 2e6f7c2a user: drh tags: dbsqlfuzz-in-fuzzcheck
04:43
Improved automatic detection of dbsqlfuzz cases in fuzzcheck. check-in: 1ef24e89 user: drh tags: dbsqlfuzz-in-fuzzcheck
04:00
Add the ability to process dbsqlfuzz cases in fuzzcheck and add an initial set of interesting dbsqlfuzz cases. check-in: fb9074ff user: drh tags: dbsqlfuzz-in-fuzzcheck
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to test/fuzzcheck.c.

   600    600     FuzzCtx *p = (FuzzCtx*)pClientData;
   601    601     sqlite3_int64 iNow = timeOfDay();
   602    602     int rc = iNow>=p->iCutoffTime;
   603    603     sqlite3_int64 iDiff = iNow - p->iLastCb;
   604    604     if( iDiff > p->mxInterval ) p->mxInterval = iDiff;
   605    605     p->nCb++;
   606    606     if( rc==0 && p->mxCb>0 && p->mxCb<=p->nCb ) rc = 1;
   607         -  if( rc && !p->timeoutHit && eVerbosity ){
          607  +  if( rc && !p->timeoutHit && eVerbosity>=2 ){
   608    608       printf("Timeout on progress callback %d\n", p->nCb);
   609    609       fflush(stdout);
   610    610       p->timeoutHit = 1;
   611    611     }
   612    612     return rc;
   613    613   }
   614    614   
................................................................................
   649    649   ** Run the SQL text
   650    650   */
   651    651   static int runDbSql(sqlite3 *db, const char *zSql){
   652    652     int rc;
   653    653     sqlite3_stmt *pStmt;
   654    654     while( isspace(zSql[0]) ) zSql++;
   655    655     if( zSql[0]==0 ) return SQLITE_OK;
   656         -  if( eVerbosity>=3 ){
          656  +  if( eVerbosity>=4 ){
   657    657       printf("RUNNING-SQL: [%s]\n", zSql);
   658    658       fflush(stdout);
   659    659     }
   660    660     rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
   661    661     if( rc==SQLITE_OK ){
   662    662       while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){
   663         -      if( eVerbosity>=4 ){
          663  +      if( eVerbosity>=5 ){
   664    664           int j;
   665    665           for(j=0; j<sqlite3_column_count(pStmt); j++){
   666    666             if( j ) printf(",");
   667    667             switch( sqlite3_column_type(pStmt, j) ){
   668    668               case SQLITE_NULL: {
   669    669                 printf("NULL");
   670    670                 break;
................................................................................
   702    702                 printf("'");
   703    703                 break;
   704    704               }
   705    705             } /* End switch() */
   706    706           } /* End for() */
   707    707           printf("\n");
   708    708           fflush(stdout);
   709         -      } /* End if( eVerbosity>=4 ) */
          709  +      } /* End if( eVerbosity>=5 ) */
   710    710       } /* End while( SQLITE_ROW */
   711         -    if( rc!=SQLITE_DONE && eVerbosity>=3 ){
          711  +    if( rc!=SQLITE_DONE && eVerbosity>=4 ){
   712    712         printf("SQL-ERROR: (%d) %s\n", rc, sqlite3_errmsg(db));
   713    713         fflush(stdout);
   714    714       }
   715         -  }else if( eVerbosity>=3 ){
          715  +  }else if( eVerbosity>=4 ){
   716    716       printf("SQL-ERROR (%d): %s\n", rc, sqlite3_errmsg(db));
   717    717       fflush(stdout);    
   718    718     } /* End if( SQLITE_OK ) */
   719    719     return sqlite3_finalize(pStmt);
   720    720   }
   721    721   
   722    722   /* Invoke this routine to run a single test case */
................................................................................
   741    741               sqlite3_memory_used(), nAlloc);
   742    742       exit(1);
   743    743     }
   744    744     memset(&cx, 0, sizeof(cx));
   745    745     iSql = decodeDatabase((unsigned char*)aData, (int)nByte, &aDb, &nDb);
   746    746     if( iSql<0 ) return 0;
   747    747     nSql = nByte - iSql;
   748         -  if( eVerbosity>=2 ){
          748  +  if( eVerbosity>=3 ){
   749    749       printf(
   750    750         "****** %d-byte input, %d-byte database, %d-byte script "
   751    751         "******\n", (int)nByte, nDb, nSql);
   752    752       fflush(stdout);
   753    753     }
   754    754     rc = sqlite3_open(0, &cx.db);
   755    755     if( rc ) return 1;
................................................................................
   826    826     }
   827    827   testrun_finished:
   828    828     sqlite3_free(zSql);
   829    829     rc = sqlite3_close(cx.db);
   830    830     if( rc!=SQLITE_OK ){
   831    831       fprintf(stdout, "sqlite3_close() returns %d\n", rc);
   832    832     }
   833         -  if( eVerbosity ){
          833  +  if( eVerbosity>=2 ){
   834    834       fprintf(stdout, "Peak memory usages: %f MB\n",
   835    835          sqlite3_memory_highwater(1) / 1000000.0);
   836    836     }
   837    837     if( sqlite3_memory_used()!=0 ){
   838    838       int nAlloc = 0;
   839    839       int nNotUsed = 0;
   840    840       sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &nAlloc, &nNotUsed, 0);
................................................................................
   850    850   ***************************************************************************/
   851    851   
   852    852   /* Look at a SQL text and try to determine if it begins with a database
   853    853   ** description, such as would be found in a dbsqlfuzz test case.  Return
   854    854   ** true if this does appear to be a dbsqlfuzz test case and false otherwise.
   855    855   */
   856    856   static int isDbSql(unsigned char *a, int n){
          857  +  unsigned char buf[12];
          858  +  int i;
   857    859     if( n>4 && memcmp(a,"\n--\n",4)==0 ) return 1;
   858    860     while( n>0 && isspace(a[0]) ){ a++; n--; }
   859         -  if( n>8 && memcmp(a,"53514c69",8)==0 ) return 1;
          861  +  for(i=0; n>0 && i<8; n--, a++){
          862  +    if( isxdigit(a[0]) ) buf[i++] = a[0];
          863  +  }
          864  +  if( i==8 && memcmp(buf,"53514c69",8)==0 ) return 1;
   860    865     return 0;
   861    866   }
   862    867   
   863    868   
   864    869   /* Methods for the VHandle object
   865    870   */
   866    871   static int inmemClose(sqlite3_file *pFile){