1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

The first simple test-case appears to be working now.

FossilOrigin-Name: dd41155bc7459cafc1a2d5c75233193abfbac05d
This commit is contained in:
drh
2011-03-29 18:21:59 +00:00
parent 72384dc28f
commit c8e27ab5da
4 changed files with 59 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
C Further\simprovements\sto\sthe\sfuzzer.\s\sIt\sstill\sis\snot\squite\sworking.\s\sPausing\nto\swork\son\sother\sthings.... C The\sfirst\ssimple\stest-case\sappears\sto\sbe\sworking\snow.
D 2011-03-29T14:08:09.188 D 2011-03-29T18:21:59.753
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 6c96e694f446500449f683070b906de9fce17b88 F Makefile.in 6c96e694f446500449f683070b906de9fce17b88
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -202,7 +202,7 @@ F src/test_config.c 62f0f8f934b1d5c7e4cd4f506ae453a1117b47d7
F src/test_demovfs.c 0aed671636735116fc872c5b03706fd5612488b5 F src/test_demovfs.c 0aed671636735116fc872c5b03706fd5612488b5
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5 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_hexio.c 1237f000ec7a491009b1233f5c626ea71bce1ea2
F src/test_init.c 5d624ffd0409d424cf9adbfe1f056b200270077c F src/test_init.c 5d624ffd0409d424cf9adbfe1f056b200270077c
F src/test_intarray.c d879bbf8e4ce085ab966d1f3c896a7c8b4f5fc99 F src/test_intarray.c d879bbf8e4ce085ab966d1f3c896a7c8b4f5fc99
@@ -476,7 +476,7 @@ F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5 F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
F test/fuzz_malloc.test dd7001ac86d09c154a7dff064f4739c60e2b312c F test/fuzz_malloc.test dd7001ac86d09c154a7dff064f4739c60e2b312c
F test/fuzzer1.test a5d60f618443b86b5f5a695a41d01b7d8697345d F test/fuzzer1.test a81a50d7ba6005d9cc98bf58b8aae8c3e73e11a6
F test/hook.test f04c3412463f8ec117c1c704c74ca0f627ce733a F test/hook.test f04c3412463f8ec117c1c704c74ca0f627ce733a
F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4 F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4
F test/in.test 19b642bb134308980a92249750ea4ce3f6c75c2d F test/in.test 19b642bb134308980a92249750ea4ce3f6c75c2d
@@ -918,7 +918,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P fb4c31eac8a7290f61c50a3552245660e1271871 P 5f2f2fce40f43debeb0492c9b460b85c7dad2bde
R 86b6649d084e41c015babc3a0e3fb294 R 1ce7df4d179ed6c133db387973d1e6f3
U drh U drh
Z 67d6460bdc70fd366585e4c8607ab8f4 Z 6cf1874f37d2b9758d183fd9153a451e

View File

@@ -1 +1 @@
5f2f2fce40f43debeb0492c9b460b85c7dad2bde dd41155bc7459cafc1a2d5c75233193abfbac05d

View File

@@ -255,14 +255,17 @@ static int fuzzerRender(
} }
n = pStem->n; n = pStem->n;
z = *pzBuf; z = *pzBuf;
memcpy(z, pStem->zBasis, n); if( n<0 ){
memcpy(&z[n], pRule->zTo, pRule->nTo); memcpy(z, pStem->zBasis, pStem->nBasis+1);
memcpy(&z[n+pRule->nTo], &pStem->zBasis[n+pRule->nFrom], }else{
pStem->nBasis-n-pRule->nFrom+1); 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; return SQLITE_OK;
} }
/* /*
** Compute a hash on zBasis. ** Compute a hash on zBasis.
*/ */
@@ -279,6 +282,35 @@ static fuzzer_cost fuzzerCost(fuzzer_stem *pStem){
return pStem->rBaseCost + pStem->pRule->rCost; 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 ** 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 ** 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 */ /* Found a rewrite case. Make sure it is not a duplicate */
int rc = fuzzerSeen(pCur, pStem); int rc = fuzzerSeen(pCur, pStem);
if( rc<0 ) return -1; if( rc<0 ) return -1;
if( rc==0 ) return 1; if( rc==0 ){
return 1;
}
} }
} }
pStem->n = -1; pStem->n = -1;
@@ -417,17 +451,23 @@ static int fuzzerNext(sqlite3_vtab_cursor *cur){
*/ */
while( (pStem = pCur->pStem)!=0 ){ while( (pStem = pCur->pStem)!=0 ){
if( fuzzerAdvance(pCur, pStem) ){ if( fuzzerAdvance(pCur, pStem) ){
pCur->pStem = fuzzerInsert(pStem->pNext, pStem); pCur->pStem = pStem = fuzzerInsert(pStem->pNext, pStem);
if( pCur->pStem!=pStem && (rc = fuzzerSeen(pCur, pStem))!=0 ){ if( (rc = fuzzerSeen(pCur, pStem))!=0 ){
if( rc<0 ) return SQLITE_NOMEM; if( rc<0 ) return SQLITE_NOMEM;
continue; continue;
}else{
return SQLITE_OK; /* New word found */
} }
return SQLITE_OK; /* New word found */
} }
pCur->pStem = pStem->pNext; pCur->pStem = pStem->pNext;
pStem->pNext = pCur->pDone; pStem->pNext = pCur->pDone;
pCur->pDone = pStem; 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 /* Reach this point only if queue has been exhausted and there is

View File

@@ -41,7 +41,7 @@ do_test fuzzer1-1.3 {
db eval { db eval {
SELECT word, distance FROM f1 WHERE word MATCH 'abcde' 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 finish_test