/ Check-in [f60657c2]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add the fuzzoomtest target to the makefiles. Invoke fuzzoomtest from releasetest.tcl.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f60657c2ae8a11f1e546c953bca07d9396142f73
User & Date: drh 2015-04-25 13:39:29
Context
2015-04-25
16:39
Fuzzershell: change the error summary output to work with releasetest.tcl. Reduce the maximum number of OOM interations. check-in: f5e6c4b2 user: drh tags: trunk
13:39
Add the fuzzoomtest target to the makefiles. Invoke fuzzoomtest from releasetest.tcl. check-in: f60657c2 user: drh tags: trunk
12:20
Fix an obscure memory leak that could follow an OOM in where.c. check-in: 08ec9f2f user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   951    951   		-o $@ $(TESTFIXTURE_SRC) $(LIBTCL) $(TLIBS)
   952    952   
   953    953   # A very detailed test running most or all test cases
   954    954   fulltest:	testfixture$(TEXE) sqlite3$(TEXE) fuzztest
   955    955   	./testfixture$(TEXE) $(TOP)/test/all.test
   956    956   
   957    957   # Really really long testing
   958         -soaktest:	testfixture$(TEXE) sqlite3$(TEXE)
          958  +soaktest:	testfixture$(TEXE) sqlite3$(TEXE) fuzzoomtest
   959    959   	./testfixture$(TEXE) $(TOP)/test/all.test -soak=1
   960    960   
   961    961   # Do extra testing but not aeverything.
   962    962   fulltestonly:	testfixture$(TEXE) sqlite3$(TEXE)
   963    963   	./testfixture$(TEXE) $(TOP)/test/full.test
   964    964   
   965    965   # Fuzz testing
   966    966   fuzztest:	fuzzershell$(TEXE)
   967    967   	./fuzzershell$(TEXE) -f $(TOP)/test/fuzzdata1.txt
   968    968   
          969  +fuzzoomtest:	fuzzershell$(TEXE)
          970  +	./fuzzershell$(TEXE) -f $(TOP)/test/fuzzdata1.txt --oom
          971  +
   969    972   # This is the common case.  Run many tests but not those that take
   970    973   # a really long time.
   971    974   #
   972    975   test:	testfixture$(TEXE) sqlite3$(TEXE) fuzztest
   973    976   	./testfixture$(TEXE) $(TOP)/test/veryquick.test
   974    977   
   975    978   # Run a test using valgrind.  This can take a really long time

Changes to Makefile.msc.

  1623   1623   
  1624   1624   extensiontest: testfixture.exe testloadext.dll
  1625   1625   	.\testfixture.exe $(TOP)\test\loadext.test
  1626   1626   
  1627   1627   fulltest:	testfixture.exe sqlite3.exe fuzztest
  1628   1628   	.\testfixture.exe $(TOP)\test\all.test
  1629   1629   
  1630         -soaktest:	testfixture.exe sqlite3.exe
         1630  +soaktest:	testfixture.exe sqlite3.exe fuzzoomtest
  1631   1631   	.\testfixture.exe $(TOP)\test\all.test -soak=1
  1632   1632   
  1633   1633   fulltestonly:	testfixture.exe sqlite3.exe fuzztest
  1634   1634   	.\testfixture.exe $(TOP)\test\full.test
  1635   1635   
  1636   1636   queryplantest:	testfixture.exe sqlite3.exe
  1637   1637   	.\testfixture.exe $(TOP)\test\permutations.test queryplanner
  1638   1638   
  1639   1639   fuzztest:	fuzzershell.exe
  1640   1640   	.\fuzzershell.exe -f $(TOP)\test\fuzzdata1.txt
  1641   1641   
         1642  +fuzzoomtest:	fuzzershell.exe
         1643  +	.\fuzzershell.exe -f $(TOP)\test\fuzzdata1.txt --oom
         1644  +
  1642   1645   test:	testfixture.exe sqlite3.exe fuzztest
  1643   1646   	.\testfixture.exe $(TOP)\test\veryquick.test
  1644   1647   
  1645   1648   smoketest:	testfixture.exe
  1646   1649   	.\testfixture.exe $(TOP)\test\main.test
  1647   1650   
  1648   1651   sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl

Changes to main.mk.

   632    632   	-DSQLITE_ENABLE_FTS3=1                                               \
   633    633   		$(TESTSRC) $(TOP)/src/tclsqlite.c sqlite3.c fts3amal.c       \
   634    634   		-o testfixture$(EXE) $(LIBTCL) $(THREADLIB)
   635    635   
   636    636   fulltest:	testfixture$(EXE) sqlite3$(EXE) fuzztest
   637    637   	./testfixture$(EXE) $(TOP)/test/all.test
   638    638   
   639         -soaktest:	testfixture$(EXE) sqlite3$(EXE)
          639  +soaktest:	testfixture$(EXE) sqlite3$(EXE) fuzzoomtest
   640    640   	./testfixture$(EXE) $(TOP)/test/all.test -soak=1
   641    641   
   642    642   fulltestonly:	testfixture$(EXE) sqlite3$(EXE) fuzztest
   643    643   	./testfixture$(EXE) $(TOP)/test/full.test
   644    644   
   645    645   queryplantest:	testfixture$(EXE) sqlite3$(EXE)
   646    646   	./testfixture$(EXE) $(TOP)/test/permutations.test queryplanner
   647    647   
   648    648   fuzztest:	fuzzershell$(EXE)
   649    649   	./fuzzershell$(EXE) -f $(TOP)/test/fuzzdata1.txt
   650    650   
          651  +fuzzoomtest:	fuzzershell$(EXE)
          652  +	./fuzzershell$(EXE) -f $(TOP)/test/fuzzdata1.txt --oom
          653  +
   651    654   test:	testfixture$(EXE) sqlite3$(EXE) fuzztest
   652    655   	./testfixture$(EXE) $(TOP)/test/veryquick.test
   653    656   
   654    657   # Run a test using valgrind.  This can take a really long time
   655    658   # because valgrind is so much slower than a native machine.
   656    659   #
   657    660   valgrindtest:	testfixture$(EXE) sqlite3$(EXE) fuzzershell$(EXE)

Changes to test/releasetest.tcl.

   107    107       -DSQLITE_ENABLE_RTREE=1
   108    108       -DSQLITE_ENABLE_MEMSYS5=1
   109    109       -DSQLITE_ENABLE_MEMSYS3=1
   110    110       -DSQLITE_ENABLE_COLUMN_METADATA=1
   111    111       -DSQLITE_ENABLE_STAT4
   112    112       -DSQLITE_MAX_ATTACHED=125
   113    113     }
          114  +  "Fast-One" {
          115  +    -O6
          116  +    -DSQLITE_ENABLE_FTS4=1
          117  +    -DSQLITE_ENABLE_RTREE=1
          118  +    -DSQLITE_ENABLE_STAT4
          119  +    -DSQLITE_MAX_ATTACHED=125
          120  +  }
   114    121     "Device-One" {
   115    122       -O2
   116    123       -DSQLITE_DEBUG=1
   117    124       -DSQLITE_DEFAULT_AUTOVACUUM=1
   118    125       -DSQLITE_DEFAULT_CACHE_SIZE=64
   119    126       -DSQLITE_DEFAULT_PAGE_SIZE=1024
   120    127       -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
................................................................................
   213    220       "Unlock-Notify"           "QUICKTEST_INCLUDE=notify2.test test"
   214    221       "Update-Delete-Limit"     test
   215    222       "Extra-Robustness"        test
   216    223       "Device-Two"              test
   217    224       "No-lookaside"            test
   218    225       "Devkit"                  test
   219    226       "Sanitize"                {QUICKTEST_OMIT=func4.test,nan.test test}
          227  +    "Fast-One"                fuzzoomtest
   220    228       "Valgrind"                valgrindtest
   221    229       "Default"                 "threadtest fulltest"
   222    230       "Device-One"              fulltest
   223    231     }
   224    232     Linux-i686 {
   225    233       "Devkit"                  test
   226    234       "Have-Not"                test
................................................................................
   649    657       incr NTEST
   650    658       run_test_suite $zConfig $target $config_options
   651    659   
   652    660       # If the configuration included the SQLITE_DEBUG option, then remove
   653    661       # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
   654    662       # add it and run veryquick.test.
   655    663       if {$target!="checksymbols" && $target!="valgrindtest"
   656         -           && !$::BUILDONLY && $::QUICK<2} {
          664  +           && $target!="fuzzoomtest" && !$::BUILDONLY && $::QUICK<2} {
   657    665         set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
   658    666         set xtarget $target
   659    667         regsub -all {fulltest[a-z]*} $xtarget test xtarget
          668  +      regsub -all {fuzzoomtest} $xtarget fuzztest xtarget
   660    669         if {$debug_idx < 0} {
   661    670           incr NTEST
   662    671           append config_options " -DSQLITE_DEBUG=1"
   663    672           run_test_suite "${zConfig}_debug" $xtarget $config_options
   664    673         } else {
   665    674           incr NTEST
   666    675           regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options

Changes to tool/fuzzershell.c.

    35     35   **    (5)  An error is raised if there is a memory leak.
    36     36   **
    37     37   ** The input text can be divided into separate test cases using comments
    38     38   ** of the form:
    39     39   **
    40     40   **       |****<...>****|
    41     41   **
    42         -** where the "..." is arbitrary text, except the "|" should really be "/".
    43         -** ("|" is used here to avoid compiler errors about nested comments.)
           42  +** where the "..." is arbitrary text. (Except the "|" should really be "/".
           43  +** "|" is used here to avoid compiler errors about nested comments.)
    44     44   ** A separate in-memory SQLite database is created to run each test case.
    45     45   ** This feature allows the "queue" of AFL to be captured into a single big
    46     46   ** file using a command like this:
    47     47   **
    48     48   **    (for i in id:*; do echo '|****<'$i'>****|'; cat $i; done) >~/all-queue.txt
    49     49   **
    50     50   ** (Once again, change the "|" to "/") Then all elements of the AFL queue
................................................................................
    56     56   ** program aborts if the close fails or if there is any unfreed memory after
    57     57   ** the close.
    58     58   **
    59     59   ** New test cases can be appended to all-queue.txt at any time.  If redundant
    60     60   ** test cases are added, they can be eliminated by running:
    61     61   **
    62     62   **    fuzzershell -f ~/all-queue.txt --unique-cases ~/unique-cases.txt
    63         -**
    64     63   */
    65     64   #include <stdio.h>
    66     65   #include <stdlib.h>
    67     66   #include <string.h>
    68     67   #include <stdarg.h>
    69     68   #include <ctype.h>
    70     69   #include "sqlite3.h"
................................................................................
    80     79     int nOomFault;                   /* Increments for each OOM fault */
    81     80     int bOomOnce;                    /* Fail just once if true */
    82     81     int bOomEnable;                  /* True to enable OOM simulation */
    83     82     int nOomBrkpt;                   /* Number of calls to oomFault() */
    84     83     char zTestName[100];             /* Name of current test */
    85     84   } g;
    86     85   
           86  +/*
           87  +** Maximum number of iterations for an OOM test
           88  +*/
           89  +#ifndef OOM_MAX
           90  +# define OOM_MAX 1000
           91  +#endif
           92  +
    87     93   /*
    88     94   ** This routine is called when a simulated OOM occurs.  It exists as a
    89     95   ** convenient place to set a debugger breakpoint.
    90     96   */
    91     97   static void oomFault(void){
    92     98     g.nOomBrkpt++; /* Prevent oomFault() from being optimized out */
    93     99   }
................................................................................
   611    617     for(nTest=0; i<nIn; i=iNext, nTest++, g.zTestName[0]=0){
   612    618       char cSaved;
   613    619       if( strncmp(&zIn[i], "/****<",6)==0 ){
   614    620         char *z = strstr(&zIn[i], ">****/");
   615    621         if( z ){
   616    622           z += 6;
   617    623           sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, "%.*s", 
   618         -                         (int)(z-&zIn[i]), &zIn[i]);
          624  +                         (int)(z-&zIn[i]) - 12, &zIn[i+6]);
   619    625           if( verboseFlag ){
   620    626             printf("%.*s\n", (int)(z-&zIn[i]), &zIn[i]);
   621    627             fflush(stdout);
   622    628           }
   623    629           i += (int)(z-&zIn[i]);
   624    630           multiTest = 1;
   625    631         }
................................................................................
   638    644         zIn[iNext] = cSaved;
   639    645         continue;
   640    646       }
   641    647       zSql = &zIn[i];
   642    648       if( verboseFlag ){
   643    649         printf("INPUT (offset: %d, size: %d): [%s]\n",
   644    650                 i, (int)strlen(&zIn[i]), &zIn[i]);
   645         -      fflush(stdout);
   646    651       }else if( multiTest && !quietFlag ){
   647         -      int pct = oomFlag ? 100*iNext/nIn : ((10*iNext)/nIn)*10;
   648         -      if( pct!=lastPct ){
   649         -        if( lastPct<0 ) printf("fuzz test:");
   650         -        printf(" %d%%", pct);
   651         -        fflush(stdout);
   652         -        lastPct = pct;
          652  +      if( oomFlag ){
          653  +        printf("%s\n", g.zTestName);
          654  +      }else{
          655  +        int pct = (10*iNext)/nIn;
          656  +        if( pct!=lastPct ){
          657  +          if( lastPct<0 ) printf("fuzz test:");
          658  +          printf(" %d%%", pct*10);
          659  +          lastPct = pct;
          660  +        }
   653    661         }
   654    662       }
          663  +    fflush(stdout);
   655    664       switch( iMode ){
   656    665         case FZMODE_Glob:
   657    666           zSql = zToFree = sqlite3_mprintf("SELECT glob(%s);", zSql);
   658    667           break;
   659    668         case FZMODE_Printf:
   660    669           zSql = zToFree = sqlite3_mprintf("SELECT printf(%s);", zSql);
   661    670           break;
................................................................................
   721    730         if( rc ){
   722    731           abendError("sqlite3_close() failed with rc=%d", rc);
   723    732         }
   724    733         if( sqlite3_memory_used()>0 ){
   725    734           abendError("memory in use after close: %lld bytes", sqlite3_memory_used());
   726    735         }
   727    736         if( oomFlag ){
   728         -        if( g.nOomFault==0 || oomCnt>2000 ){
          737  +        if( g.nOomFault==0 || oomCnt>OOM_MAX ){
   729    738             if( g.bOomOnce ){
   730    739               oomCnt = g.iOomCntdown = 1;
   731    740               g.bOomOnce = 0;
   732    741             }else{
   733    742               oomCnt = 0;
   734    743             }
   735    744           }else{
................................................................................
   765    774           /* If TEST_FAILURE is something other than 5, just exit the test
   766    775           ** early */
   767    776           printf("\nExit early due to TEST_FAILURE being set");
   768    777           break;
   769    778         }
   770    779       }
   771    780     }
   772         -  if( !verboseFlag && multiTest && !quietFlag ) printf("\n");
          781  +  if( !verboseFlag && multiTest && !quietFlag && !oomFlag ) printf("\n");
   773    782     if( nTest>1 && !quietFlag ){
   774    783       printf("%d fuzz tests with no errors\nSQLite %s %s\n",
   775    784              nTest, sqlite3_libversion(), sqlite3_sourceid());
   776    785     }
   777    786     if( zDataOut ){
   778    787       int n = 0;
   779    788       FILE *out = fopen(zDataOut, "wb");