From: drh Date: Thu, 25 Apr 2013 14:31:46 +0000 (+0000) Subject: Convert the fuzzer virtual table into a loadable extension and move it X-Git-Tag: version-3.7.17~55^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e50db1c5d25a284b30964cf64e69a02866db97b0;p=thirdparty%2Fsqlite.git Convert the fuzzer virtual table into a loadable extension and move it to the ext/misc/fuzzer.c file. FossilOrigin-Name: c8c69307f60c1d07ac666ae3797b7e3f286fd491 --- diff --git a/Makefile.in b/Makefile.in index 5c636209d8..597994c15c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -361,7 +361,6 @@ TESTSRC = \ $(TOP)/src/test_devsym.c \ $(TOP)/src/test_fs.c \ $(TOP)/src/test_func.c \ - $(TOP)/src/test_fuzzer.c \ $(TOP)/src/test_hexio.c \ $(TOP)/src/test_init.c \ $(TOP)/src/test_intarray.c \ @@ -373,7 +372,6 @@ TESTSRC = \ $(TOP)/src/test_osinst.c \ $(TOP)/src/test_pcache.c \ $(TOP)/src/test_quota.c \ - $(TOP)/src/test_regexp.c \ $(TOP)/src/test_rtree.c \ $(TOP)/src/test_schema.c \ $(TOP)/src/test_server.c \ @@ -383,11 +381,17 @@ TESTSRC = \ $(TOP)/src/test_tclvar.c \ $(TOP)/src/test_thread.c \ $(TOP)/src/test_vfs.c \ - $(TOP)/src/test_wholenumber.c \ $(TOP)/src/test_wsd.c \ $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_test.c +# Statically linked extensions +# +TESTSRC += \ + $(TOP)/ext/misc/fuzzer.c \ + $(TOP)/ext/misc/regexp.c \ + $(TOP)/ext/misc/wholenumber.c + # Source code to the library files needed by the test fixture # TESTSRC2 = \ diff --git a/Makefile.msc b/Makefile.msc index 47f815e677..982a959dc6 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -681,7 +681,6 @@ TESTSRC = \ $(TOP)\src\test_devsym.c \ $(TOP)\src\test_fs.c \ $(TOP)\src\test_func.c \ - $(TOP)\src\test_fuzzer.c \ $(TOP)\src\test_hexio.c \ $(TOP)\src\test_init.c \ $(TOP)\src\test_intarray.c \ @@ -693,7 +692,6 @@ TESTSRC = \ $(TOP)\src\test_osinst.c \ $(TOP)\src\test_pcache.c \ $(TOP)\src\test_quota.c \ - $(TOP)\src\test_regexp.c \ $(TOP)\src\test_rtree.c \ $(TOP)\src\test_schema.c \ $(TOP)\src\test_server.c \ @@ -703,11 +701,18 @@ TESTSRC = \ $(TOP)\src\test_tclvar.c \ $(TOP)\src\test_thread.c \ $(TOP)\src\test_vfs.c \ - $(TOP)\src\test_wholenumber.c \ $(TOP)\src\test_wsd.c \ $(TOP)\ext\fts3\fts3_term.c \ $(TOP)\ext\fts3\fts3_test.c +# Statically linked extensions +# +TESTSRC += \ + $(TOP)\ext\misc\fuzzer.c \ + $(TOP)\ext\misc\regexp.c \ + $(TOP)\ext\misc\wholenumber.c + + # Source code to the library files needed by the test fixture # TESTSRC2 = \ diff --git a/src/test_fuzzer.c b/ext/misc/fuzzer.c similarity index 96% rename from src/test_fuzzer.c rename to ext/misc/fuzzer.c index 10496f2ea7..c0c294b11c 100644 --- a/src/test_fuzzer.c +++ b/ext/misc/fuzzer.c @@ -141,13 +141,14 @@ ** of the strings in the second or third column of the fuzzer data table ** is 50 bytes. The maximum cost on a rule is 1000. */ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 /* If SQLITE_DEBUG is not defined, disable assert statements. */ #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) # define NDEBUG #endif -#include "sqlite3.h" #include #include #include @@ -1155,61 +1156,16 @@ static sqlite3_module fuzzerModule = { #endif /* SQLITE_OMIT_VIRTUALTABLE */ -/* -** Register the fuzzer virtual table -*/ -int fuzzer_register(sqlite3 *db){ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_fuzzer_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ int rc = SQLITE_OK; -#ifndef SQLITE_OMIT_VIRTUALTABLE + SQLITE_EXTENSION_INIT2(pApi); rc = sqlite3_create_module(db, "fuzzer", &fuzzerModule, 0); -#endif return rc; } - -#ifdef SQLITE_TEST -#include -/* -** Decode a pointer to an sqlite3 object. -*/ -extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); - -/* -** Register the echo virtual table module. -*/ -static int register_fuzzer_module( - ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ - Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ - int objc, /* Number of arguments */ - Tcl_Obj *CONST objv[] /* Command arguments */ -){ - sqlite3 *db; - if( objc!=2 ){ - Tcl_WrongNumArgs(interp, 1, objv, "DB"); - return TCL_ERROR; - } - getDbPointer(interp, Tcl_GetString(objv[1]), &db); - fuzzer_register(db); - return TCL_OK; -} - - -/* -** Register commands with the TCL interpreter. -*/ -int Sqlitetestfuzzer_Init(Tcl_Interp *interp){ - static struct { - char *zName; - Tcl_ObjCmdProc *xProc; - void *clientData; - } aObjCmd[] = { - { "register_fuzzer_module", register_fuzzer_module, 0 }, - }; - int i; - for(i=0; i