]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
The first simple test-case appears to be working now.
authordrh <drh@noemail.net>
Tue, 29 Mar 2011 18:21:59 +0000 (18:21 +0000)
committerdrh <drh@noemail.net>
Tue, 29 Mar 2011 18:21:59 +0000 (18:21 +0000)
FossilOrigin-Name: dd41155bc7459cafc1a2d5c75233193abfbac05d

manifest
manifest.uuid
src/test_fuzzer.c
test/fuzzer1.test

index 8148ffca724ca025ea3153f2e6de5b850e1c4b5c..20d5dc398cbc9ac0d741d33983043ba4271194a0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Further\simprovements\sto\sthe\sfuzzer.\s\sIt\sstill\sis\snot\squite\sworking.\s\sPausing\nto\swork\son\sother\sthings....
-D 2011-03-29T14:08:09.188
+C The\sfirst\ssimple\stest-case\sappears\sto\sbe\sworking\snow.
+D 2011-03-29T18:21:59.753
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 6c96e694f446500449f683070b906de9fce17b88
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -202,7 +202,7 @@ F src/test_config.c 62f0f8f934b1d5c7e4cd4f506ae453a1117b47d7
 F src/test_demovfs.c 0aed671636735116fc872c5b03706fd5612488b5
 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
 F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5
-F src/test_fuzzer.c 3e402dd5e6c4f096fdc92c52e775e8fad85bce9b
+F src/test_fuzzer.c 1427f9b54dbb6fa4742bd611adcd9b0abedfc083
 F src/test_hexio.c 1237f000ec7a491009b1233f5c626ea71bce1ea2
 F src/test_init.c 5d624ffd0409d424cf9adbfe1f056b200270077c
 F src/test_intarray.c d879bbf8e4ce085ab966d1f3c896a7c8b4f5fc99
@@ -476,7 +476,7 @@ F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167
 F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
 F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
 F test/fuzz_malloc.test dd7001ac86d09c154a7dff064f4739c60e2b312c
-F test/fuzzer1.test a5d60f618443b86b5f5a695a41d01b7d8697345d
+F test/fuzzer1.test a81a50d7ba6005d9cc98bf58b8aae8c3e73e11a6
 F test/hook.test f04c3412463f8ec117c1c704c74ca0f627ce733a
 F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4
 F test/in.test 19b642bb134308980a92249750ea4ce3f6c75c2d
@@ -918,7 +918,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P fb4c31eac8a7290f61c50a3552245660e1271871
-R 86b6649d084e41c015babc3a0e3fb294
+P 5f2f2fce40f43debeb0492c9b460b85c7dad2bde
+R 1ce7df4d179ed6c133db387973d1e6f3
 U drh
-Z 67d6460bdc70fd366585e4c8607ab8f4
+Z 6cf1874f37d2b9758d183fd9153a451e
index 09a1e57cc721fad0ef118c575d49de4839db4dca..98b1b08a7b9c4aef9e97000b524fdf00d952f37f 100644 (file)
@@ -1 +1 @@
-5f2f2fce40f43debeb0492c9b460b85c7dad2bde
\ No newline at end of file
+dd41155bc7459cafc1a2d5c75233193abfbac05d
\ No newline at end of file
index 82f35a2f51c66afcb292c1a7a72b396cc57b088c..9a5f8c5930eb6d1c4d421cfafea47cd022047c37 100644 (file)
@@ -255,14 +255,17 @@ static int fuzzerRender(
   }
   n = pStem->n;
   z = *pzBuf;
-  memcpy(z, pStem->zBasis, n);
-  memcpy(&z[n], pRule->zTo, pRule->nTo);
-  memcpy(&z[n+pRule->nTo], &pStem->zBasis[n+pRule->nFrom], 
-         pStem->nBasis-n-pRule->nFrom+1);
+  if( n<0 ){
+    memcpy(z, pStem->zBasis, pStem->nBasis+1);
+  }else{
+    memcpy(z, pStem->zBasis, n);
+    memcpy(&z[n], pRule->zTo, pRule->nTo);
+    memcpy(&z[n+pRule->nTo], &pStem->zBasis[n+pRule->nFrom], 
+           pStem->nBasis-n-pRule->nFrom+1);
+  }
   return SQLITE_OK;
 }
 
-
 /*
 ** Compute a hash on zBasis.
 */
@@ -279,6 +282,35 @@ static fuzzer_cost fuzzerCost(fuzzer_stem *pStem){
   return pStem->rBaseCost + pStem->pRule->rCost;
 }
 
+#if 0
+/*
+** Print a description of a fuzzer_stem on stderr.
+*/
+static void fuzzerStemPrint(
+  const char *zPrefix,
+  fuzzer_stem *pStem,
+  const char *zSuffix
+){
+  if( pStem->n<0 ){
+    fprintf(stderr, "%s[%s](%d)-->self%s",
+       zPrefix,
+       pStem->zBasis, pStem->rBaseCost,
+       zSuffix
+    );
+  }else{
+    char *zBuf = 0;
+    int nBuf = 0;
+    if( fuzzerRender(pStem, &zBuf, &nBuf)!=SQLITE_OK ) return;
+    fprintf(stderr, "%s[%s](%d)-->{%s}(%d)%s",
+      zPrefix,
+      pStem->zBasis, pStem->rBaseCost, zBuf, fuzzerCost(pStem),
+      zSuffix
+    );
+    sqlite3_free(zBuf);
+  }
+}
+#endif
+
 /*
 ** Return 1 if the string to which the cursor is point has already
 ** been emitted.  Return 0 if not.  Return -1 on a memory allocation
@@ -315,7 +347,9 @@ static int fuzzerAdvance(fuzzer_cursor *pCur, fuzzer_stem *pStem){
         /* Found a rewrite case.  Make sure it is not a duplicate */
         int rc = fuzzerSeen(pCur, pStem);
         if( rc<0 ) return -1;
-        if( rc==0 ) return 1;  
+        if( rc==0 ){
+          return 1;
+        }
       }
     }
     pStem->n = -1;
@@ -417,17 +451,23 @@ static int fuzzerNext(sqlite3_vtab_cursor *cur){
   */
   while( (pStem = pCur->pStem)!=0 ){
     if( fuzzerAdvance(pCur, pStem) ){
-      pCur->pStem = fuzzerInsert(pStem->pNext, pStem);
-      if( pCur->pStem!=pStem && (rc = fuzzerSeen(pCur, pStem))!=0 ){
+      pCur->pStem = pStem = fuzzerInsert(pStem->pNext, pStem);
+      if( (rc = fuzzerSeen(pCur, pStem))!=0 ){
         if( rc<0 ) return SQLITE_NOMEM;
         continue;
-      }else{
-        return SQLITE_OK;  /* New word found */
       }
+      return SQLITE_OK;  /* New word found */
     }
     pCur->pStem = pStem->pNext;
     pStem->pNext = pCur->pDone;
     pCur->pDone = pStem;
+    if( pCur->pStem ){
+      rc = fuzzerSeen(pCur, pCur->pStem);
+      if( rc<0 ) return SQLITE_NOMEM;
+      if( rc==0 ){
+        return SQLITE_OK;
+      }
+    }
   }
 
   /* Reach this point only if queue has been exhausted and there is
index aaceaf1ce14e7a6759872f9dcd6f043cdbe202e5..895d6b3b2a9bc5a7e5e9e3f383e03af9b3cb7a10 100644 (file)
@@ -41,7 +41,7 @@ do_test fuzzer1-1.3 {
   db eval {
     SELECT word, distance FROM f1 WHERE word MATCH 'abcde'
   }
-} {}
+} {abcde 0 abcda 1 ebcde 10 ebcda 11 abcdo 100 ebcdo 110 obcde 110 obcda 111 obcdo 210}
 
 
 finish_test