mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Enhance the fuzztest utility with the --prng-seed option. Always reseed the
PRNG prior to each test. FossilOrigin-Name: 8c5187f69d719b69aa6eaf2dc8f89243e5979222
This commit is contained in:
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Combine\sthe\simplementations\sof\sthe\s".tables"\sand\s".indexes"\scommands\sin\sthe\ncommand-line\sshell.\s\sThe\s".indexes"\scommand\snow\sputs\sthe\sindexes\sin\smultiple\ncolumns,\sjust\slike\s".tables"\sand\sshows\sall\sindexes\sin\sall\sattached\sdatabases.
|
C Enhance\sthe\sfuzztest\sutility\swith\sthe\s--prng-seed\soption.\s\sAlways\sreseed\sthe\nPRNG\sprior\sto\seach\stest.
|
||||||
D 2016-12-24T21:32:40.591
|
D 2016-12-26T00:15:56.766
|
||||||
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
|
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
|
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
|
||||||
@ -816,7 +816,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1
|
|||||||
F test/fuzz3.test b47377143f0c80f91ed29d722861077ff34415d5
|
F test/fuzz3.test b47377143f0c80f91ed29d722861077ff34415d5
|
||||||
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
|
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
|
||||||
F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26
|
F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26
|
||||||
F test/fuzzcheck.c 5592b19e07b9061833a35eaf78869ad0c8b6cf33
|
F test/fuzzcheck.c b5a3e54b100e65b008452a2d29193c7132af0b05
|
||||||
F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664
|
F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664
|
||||||
F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973
|
F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973
|
||||||
F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
|
F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
|
||||||
@ -1539,7 +1539,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 2f481b854f04bec546eb172d1b6dbc88067d3fda
|
P def29333655691c7d54451193be13445a2857d29
|
||||||
R c83fd4223f5b56b5947d45d91cd58312
|
R e04e5338dd0157c18f4661e2b40e485c
|
||||||
U drh
|
U drh
|
||||||
Z f50c0755f44c554bddf33086d9d8e98a
|
Z 34d4889fdc22385ba735ec50d68d537d
|
||||||
|
@ -1 +1 @@
|
|||||||
def29333655691c7d54451193be13445a2857d29
|
8c5187f69d719b69aa6eaf2dc8f89243e5979222
|
@ -133,6 +133,7 @@ static struct GlobalVars {
|
|||||||
Blob *pFirstDb; /* Content of first template database */
|
Blob *pFirstDb; /* Content of first template database */
|
||||||
int nSql; /* Number of SQL scripts */
|
int nSql; /* Number of SQL scripts */
|
||||||
Blob *pFirstSql; /* First SQL script */
|
Blob *pFirstSql; /* First SQL script */
|
||||||
|
unsigned int uRandom; /* Seed for the SQLite PRNG */
|
||||||
char zTestName[100]; /* Name of current test */
|
char zTestName[100]; /* Name of current test */
|
||||||
} g;
|
} g;
|
||||||
|
|
||||||
@ -595,10 +596,18 @@ static int inmemFullPathname(
|
|||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Always use the same random see, for repeatability.
|
||||||
|
*/
|
||||||
|
static int inmemRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
|
||||||
|
memset(zBuf, 0, nBuf);
|
||||||
|
memcpy(zBuf, &g.uRandom, nBuf<sizeof(g.uRandom) ? nBuf : sizeof(g.uRandom));
|
||||||
|
return nBuf;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Register the VFS that reads from the g.aFile[] set of files.
|
** Register the VFS that reads from the g.aFile[] set of files.
|
||||||
*/
|
*/
|
||||||
static void inmemVfsRegister(void){
|
static void inmemVfsRegister(int makeDefault){
|
||||||
static sqlite3_vfs inmemVfs;
|
static sqlite3_vfs inmemVfs;
|
||||||
sqlite3_vfs *pDefault = sqlite3_vfs_find(0);
|
sqlite3_vfs *pDefault = sqlite3_vfs_find(0);
|
||||||
inmemVfs.iVersion = 3;
|
inmemVfs.iVersion = 3;
|
||||||
@ -609,10 +618,10 @@ static void inmemVfsRegister(void){
|
|||||||
inmemVfs.xDelete = inmemDelete;
|
inmemVfs.xDelete = inmemDelete;
|
||||||
inmemVfs.xAccess = inmemAccess;
|
inmemVfs.xAccess = inmemAccess;
|
||||||
inmemVfs.xFullPathname = inmemFullPathname;
|
inmemVfs.xFullPathname = inmemFullPathname;
|
||||||
inmemVfs.xRandomness = pDefault->xRandomness;
|
inmemVfs.xRandomness = inmemRandomness;
|
||||||
inmemVfs.xSleep = pDefault->xSleep;
|
inmemVfs.xSleep = pDefault->xSleep;
|
||||||
inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64;
|
inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64;
|
||||||
sqlite3_vfs_register(&inmemVfs, 0);
|
sqlite3_vfs_register(&inmemVfs, makeDefault);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -800,6 +809,7 @@ static void showHelp(void){
|
|||||||
" -m TEXT Add a description to the database\n"
|
" -m TEXT Add a description to the database\n"
|
||||||
" --native-vfs Use the native VFS for initially empty database files\n"
|
" --native-vfs Use the native VFS for initially empty database files\n"
|
||||||
" --oss-fuzz Enable OSS-FUZZ testing\n"
|
" --oss-fuzz Enable OSS-FUZZ testing\n"
|
||||||
|
" --prng-seed N Seed value for the PRGN inside of SQLite\n"
|
||||||
" --rebuild Rebuild and vacuum the database file\n"
|
" --rebuild Rebuild and vacuum the database file\n"
|
||||||
" --result-trace Show the results of each SQL command\n"
|
" --result-trace Show the results of each SQL command\n"
|
||||||
" --sqlid N Use only SQL where sqlid=N\n"
|
" --sqlid N Use only SQL where sqlid=N\n"
|
||||||
@ -844,6 +854,7 @@ int main(int argc, char **argv){
|
|||||||
void *pHeap = 0; /* Heap for use by SQLite */
|
void *pHeap = 0; /* Heap for use by SQLite */
|
||||||
int ossFuzz = 0; /* enable OSS-FUZZ testing */
|
int ossFuzz = 0; /* enable OSS-FUZZ testing */
|
||||||
int ossFuzzThisDb = 0; /* ossFuzz value for this particular database */
|
int ossFuzzThisDb = 0; /* ossFuzz value for this particular database */
|
||||||
|
sqlite3_vfs *pDfltVfs; /* The default VFS */
|
||||||
|
|
||||||
iBegin = timeOfDay();
|
iBegin = timeOfDay();
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
@ -851,6 +862,8 @@ int main(int argc, char **argv){
|
|||||||
#endif
|
#endif
|
||||||
g.zArgv0 = argv[0];
|
g.zArgv0 = argv[0];
|
||||||
zFailCode = getenv("TEST_FAILURE");
|
zFailCode = getenv("TEST_FAILURE");
|
||||||
|
pDfltVfs = sqlite3_vfs_find(0);
|
||||||
|
inmemVfsRegister(1);
|
||||||
for(i=1; i<argc; i++){
|
for(i=1; i<argc; i++){
|
||||||
const char *z = argv[i];
|
const char *z = argv[i];
|
||||||
if( z[0]=='-' ){
|
if( z[0]=='-' ){
|
||||||
@ -907,6 +920,10 @@ int main(int argc, char **argv){
|
|||||||
if( strcmp(z,"oss-fuzz")==0 ){
|
if( strcmp(z,"oss-fuzz")==0 ){
|
||||||
ossFuzz = 1;
|
ossFuzz = 1;
|
||||||
}else
|
}else
|
||||||
|
if( strcmp(z,"prng-seed")==0 ){
|
||||||
|
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||||
|
g.uRandom = atoi(argv[++i]);
|
||||||
|
}else
|
||||||
if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
|
if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
|
||||||
quietFlag = 1;
|
quietFlag = 1;
|
||||||
verboseFlag = 0;
|
verboseFlag = 0;
|
||||||
@ -957,7 +974,8 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
/* Process each source database separately */
|
/* Process each source database separately */
|
||||||
for(iSrcDb=0; iSrcDb<nSrcDb; iSrcDb++){
|
for(iSrcDb=0; iSrcDb<nSrcDb; iSrcDb++){
|
||||||
rc = sqlite3_open(azSrcDb[iSrcDb], &db);
|
rc = sqlite3_open_v2(azSrcDb[iSrcDb], &db,
|
||||||
|
SQLITE_OPEN_READONLY, pDfltVfs->zName);
|
||||||
if( rc ){
|
if( rc ){
|
||||||
fatalError("cannot open source database %s - %s",
|
fatalError("cannot open source database %s - %s",
|
||||||
azSrcDb[iSrcDb], sqlite3_errmsg(db));
|
azSrcDb[iSrcDb], sqlite3_errmsg(db));
|
||||||
@ -1135,10 +1153,8 @@ int main(int argc, char **argv){
|
|||||||
sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nMemThisDb, 128);
|
sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nMemThisDb, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the in-memory virtual filesystem
|
/* Reset the in-memory virtual filesystem */
|
||||||
*/
|
|
||||||
formatVfs();
|
formatVfs();
|
||||||
inmemVfsRegister();
|
|
||||||
|
|
||||||
/* Run a test using each SQL script against each database.
|
/* Run a test using each SQL script against each database.
|
||||||
*/
|
*/
|
||||||
@ -1163,6 +1179,7 @@ int main(int argc, char **argv){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
createVFile("main.db", pDb->sz, pDb->a);
|
createVFile("main.db", pDb->sz, pDb->a);
|
||||||
|
sqlite3_randomness(0,0);
|
||||||
if( ossFuzzThisDb ){
|
if( ossFuzzThisDb ){
|
||||||
#ifndef SQLITE_OSS_FUZZ
|
#ifndef SQLITE_OSS_FUZZ
|
||||||
fatalError("--oss-fuzz not supported: recompile with -DSQLITE_OSS_FUZZ");
|
fatalError("--oss-fuzz not supported: recompile with -DSQLITE_OSS_FUZZ");
|
||||||
|
Reference in New Issue
Block a user