aboutsummaryrefslogtreecommitdiff
path: root/src/tclsqlite.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-06-07 14:28:16 +0000
committerdan <dan@noemail.net>2010-06-07 14:28:16 +0000
commitc1a60c51dccd08559019b0bd37ede73a569b4351 (patch)
tree5df0d912b57939548a4773f47032299664ff9088 /src/tclsqlite.c
parent23f719207f7e109f42ac17c976d264b4d97ea272 (diff)
downloadsqlite-c1a60c51dccd08559019b0bd37ede73a569b4351.tar.gz
sqlite-c1a60c51dccd08559019b0bd37ede73a569b4351.zip
Refactor some of the global variables and commands used by tester.tcl.
FossilOrigin-Name: c2edf8e17f874d0ca4e94b75575bf6e14eea1f05
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r--src/tclsqlite.c65
1 files changed, 55 insertions, 10 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index d8d0fd2b9..85126f455 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -3490,21 +3490,49 @@ static char zMainloop[] =
;
#endif
-#define TCLSH_MAIN main /* Needed to fake out mktclapp */
-int TCLSH_MAIN(int argc, char **argv){
- Tcl_Interp *interp;
-
- /* Call sqlite3_shutdown() once before doing anything else. This is to
- ** test that sqlite3_shutdown() can be safely called by a process before
- ** sqlite3_initialize() is. */
- sqlite3_shutdown();
+#ifdef SQLITE_TEST
+static void init_all(Tcl_Interp *);
+static int init_all_cmd(
+ ClientData cd,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
- Tcl_FindExecutable(argv[0]);
- interp = Tcl_CreateInterp();
+ Tcl_Interp *slave;
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "SLAVE");
+ return TCL_ERROR;
+ }
+
+ slave = Tcl_GetSlave(interp, Tcl_GetString(objv[1]));
+ if( !slave ){
+ return TCL_ERROR;
+ }
+
+ init_all(slave);
+ return TCL_OK;
+}
+#endif
+
+/*
+** Configure the interpreter passed as the first argument to have access
+** to the commands and linked variables that make up:
+**
+** * the [sqlite3] extension itself,
+**
+** * If SQLITE_TCLMD5 or SQLITE_TEST is defined, the Md5 commands, and
+**
+** * If SQLITE_TEST is set, the various test interfaces used by the Tcl
+** test suite.
+*/
+static void init_all(Tcl_Interp *interp){
Sqlite3_Init(interp);
+
#if defined(SQLITE_TEST) || defined(SQLITE_TCLMD5)
Md5_Init(interp);
#endif
+
#ifdef SQLITE_TEST
{
extern int Sqliteconfig_Init(Tcl_Interp*);
@@ -3562,11 +3590,28 @@ int TCLSH_MAIN(int argc, char **argv){
Sqlitetestintarray_Init(interp);
Sqlitetestvfs_Init(interp);
+ Tcl_CreateObjCommand(interp,"load_testfixture_extensions",init_all_cmd,0,0);
+
#ifdef SQLITE_SSE
Sqlitetestsse_Init(interp);
#endif
}
#endif
+}
+
+#define TCLSH_MAIN main /* Needed to fake out mktclapp */
+int TCLSH_MAIN(int argc, char **argv){
+ Tcl_Interp *interp;
+
+ /* Call sqlite3_shutdown() once before doing anything else. This is to
+ ** test that sqlite3_shutdown() can be safely called by a process before
+ ** sqlite3_initialize() is. */
+ sqlite3_shutdown();
+
+ Tcl_FindExecutable(argv[0]);
+
+ interp = Tcl_CreateInterp();
+ init_all(interp);
if( argc>=2 ){
int i;
char zArgc[32];