4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
11 *************************************************************************
13 ** This file contains extensions to the the "tclsqlite.c" module used for
14 ** testing. Basically, all of the other "test_*.c" modules are linked
15 ** into the enhanced tclsh used for testing (and named "testfixture" or
16 ** "testfixture.exe") using logic encoded by this file.
18 ** The code in this file used to be found in tclsqlite3.c, contained within
19 ** #if SQLITE_TEST ... #endif. It is factored out into this separate module
20 ** in an effort to keep the tclsqlite.c file pure.
23 #if defined(INCLUDE_SQLITE_TCL_H)
24 # include "sqlite_tcl.h"
27 # ifndef SQLITE_TCLAPI
28 # define SQLITE_TCLAPI
32 /* Needed for the setrlimit() system call on unix */
34 #include <sys/resource.h>
37 /* Forward declaration */
38 static int SQLITE_TCLAPI
load_testfixture_extensions(
46 ** This routine is the primary export of this file.
48 ** Configure the interpreter passed as the first argument to have access
49 ** to the commands and linked variables that make up:
51 ** * the [sqlite3] extension itself,
53 ** * If SQLITE_TCLMD5 or SQLITE_TEST is defined, the Md5 commands, and
55 ** * If SQLITE_TEST is set, the various test interfaces used by the Tcl
58 const char *sqlite3TestInit(Tcl_Interp
*interp
){
59 extern int Sqlite3_Init(Tcl_Interp
*);
60 extern int Sqliteconfig_Init(Tcl_Interp
*);
61 extern int Sqlitetest1_Init(Tcl_Interp
*);
62 extern int Sqlitetest2_Init(Tcl_Interp
*);
63 extern int Sqlitetest3_Init(Tcl_Interp
*);
64 extern int Sqlitetest4_Init(Tcl_Interp
*);
65 extern int Sqlitetest5_Init(Tcl_Interp
*);
66 extern int Sqlitetest6_Init(Tcl_Interp
*);
67 extern int Sqlitetest8_Init(Tcl_Interp
*);
68 extern int Sqlitetest9_Init(Tcl_Interp
*);
69 extern int Sqlitetestasync_Init(Tcl_Interp
*);
70 extern int Sqlitetest_autoext_Init(Tcl_Interp
*);
71 extern int Sqlitetest_blob_Init(Tcl_Interp
*);
72 extern int Sqlitetest_demovfs_Init(Tcl_Interp
*);
73 extern int Sqlitetest_func_Init(Tcl_Interp
*);
74 extern int Sqlitetest_hexio_Init(Tcl_Interp
*);
75 extern int Sqlitetest_init_Init(Tcl_Interp
*);
76 extern int Sqlitetest_malloc_Init(Tcl_Interp
*);
77 extern int Sqlitetest_mutex_Init(Tcl_Interp
*);
78 extern int Sqlitetestschema_Init(Tcl_Interp
*);
79 extern int Sqlitetestsse_Init(Tcl_Interp
*);
80 extern int Sqlitetesttclvar_Init(Tcl_Interp
*);
81 extern int Sqlitetestfs_Init(Tcl_Interp
*);
82 extern int SqlitetestThread_Init(Tcl_Interp
*);
83 extern int SqlitetestOnefile_Init();
84 extern int SqlitetestOsinst_Init(Tcl_Interp
*);
85 extern int Sqlitetestbackup_Init(Tcl_Interp
*);
86 extern int Sqlitetestintarray_Init(Tcl_Interp
*);
87 extern int Sqlitetestvfs_Init(Tcl_Interp
*);
88 extern int Sqlitetestrtree_Init(Tcl_Interp
*);
89 extern int Sqlitetestrtreedoc_Init(Tcl_Interp
*);
90 extern int Sqlitequota_Init(Tcl_Interp
*);
91 extern int Sqlitemultiplex_Init(Tcl_Interp
*);
92 extern int SqliteSuperlock_Init(Tcl_Interp
*);
93 extern int SqlitetestSyscall_Init(Tcl_Interp
*);
94 #if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
95 extern int TestSession_Init(Tcl_Interp
*);
97 extern int Md5_Init(Tcl_Interp
*);
98 extern int Fts5tcl_Init(Tcl_Interp
*);
99 extern int SqliteRbu_Init(Tcl_Interp
*);
100 extern int Sqlitetesttcl_Init(Tcl_Interp
*);
101 #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)
102 extern int Sqlitetestfts3_Init(Tcl_Interp
*interp
);
104 #ifdef SQLITE_ENABLE_ZIPVFS
105 extern int Zipvfs_Init(Tcl_Interp
*);
107 extern int TestExpert_Init(Tcl_Interp
*);
108 extern int Sqlitetest_window_Init(Tcl_Interp
*);
109 extern int Sqlitetestvdbecov_Init(Tcl_Interp
*);
110 extern int TestRecover_Init(Tcl_Interp
*);
114 /* Since the primary use case for this binary is testing of SQLite,
115 ** be sure to generate core files if we crash */
118 getrlimit(RLIMIT_CORE
, &x
);
119 x
.rlim_cur
= x
.rlim_max
;
120 setrlimit(RLIMIT_CORE
, &x
);
124 if( Tcl_GetCommandInfo(interp
, "sqlite3", &cmdInfo
)==0 ){
125 Sqlite3_Init(interp
);
127 #ifdef SQLITE_ENABLE_ZIPVFS
131 Sqliteconfig_Init(interp
);
132 Sqlitetest1_Init(interp
);
133 Sqlitetest2_Init(interp
);
134 Sqlitetest3_Init(interp
);
135 Sqlitetest4_Init(interp
);
136 Sqlitetest5_Init(interp
);
137 Sqlitetest6_Init(interp
);
138 Sqlitetest8_Init(interp
);
139 Sqlitetest9_Init(interp
);
140 Sqlitetestasync_Init(interp
);
141 Sqlitetest_autoext_Init(interp
);
142 Sqlitetest_blob_Init(interp
);
143 Sqlitetest_demovfs_Init(interp
);
144 Sqlitetest_func_Init(interp
);
145 Sqlitetest_hexio_Init(interp
);
146 Sqlitetest_init_Init(interp
);
147 Sqlitetest_malloc_Init(interp
);
148 Sqlitetest_mutex_Init(interp
);
149 Sqlitetestschema_Init(interp
);
150 Sqlitetesttclvar_Init(interp
);
151 Sqlitetestfs_Init(interp
);
152 SqlitetestThread_Init(interp
);
153 SqlitetestOnefile_Init();
154 SqlitetestOsinst_Init(interp
);
155 Sqlitetestbackup_Init(interp
);
156 Sqlitetestintarray_Init(interp
);
157 Sqlitetestvfs_Init(interp
);
158 Sqlitetestrtree_Init(interp
);
159 Sqlitetestrtreedoc_Init(interp
);
160 Sqlitequota_Init(interp
);
161 Sqlitemultiplex_Init(interp
);
162 SqliteSuperlock_Init(interp
);
163 SqlitetestSyscall_Init(interp
);
164 #if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
165 TestSession_Init(interp
);
167 Fts5tcl_Init(interp
);
168 SqliteRbu_Init(interp
);
169 Sqlitetesttcl_Init(interp
);
171 #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)
172 Sqlitetestfts3_Init(interp
);
174 TestExpert_Init(interp
);
175 Sqlitetest_window_Init(interp
);
176 Sqlitetestvdbecov_Init(interp
);
177 TestRecover_Init(interp
);
179 Tcl_CreateObjCommand(
180 interp
, "load_testfixture_extensions", load_testfixture_extensions
,0,0
185 /* tclcmd: load_testfixture_extensions
187 static int SQLITE_TCLAPI
load_testfixture_extensions(
191 Tcl_Obj
*CONST objv
[]
196 Tcl_WrongNumArgs(interp
, 1, objv
, "SLAVE");
200 slave
= Tcl_GetSlave(interp
, Tcl_GetString(objv
[1]));
205 (void)sqlite3TestInit(slave
);