| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2008 June 18 | 2 ** 2008 June 18 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** This file contains test logic for the sqlite3_mutex interfaces. | 12 ** This file contains test logic for the sqlite3_mutex interfaces. |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 #include "tcl.h" | 15 #include "tcl.h" |
| 16 #include "sqlite3.h" | 16 #include "sqlite3.h" |
| 17 #include "sqliteInt.h" | 17 #include "sqliteInt.h" |
| 18 #include <stdlib.h> | 18 #include <stdlib.h> |
| 19 #include <assert.h> | 19 #include <assert.h> |
| 20 #include <string.h> | 20 #include <string.h> |
| 21 | 21 |
| 22 /* defined in test1.c */ | 22 /* defined in main.c */ |
| 23 const char *sqlite3TestErrorName(int); | 23 extern const char *sqlite3ErrName(int); |
| 24 | 24 |
| 25 /* A countable mutex */ | 25 /* A countable mutex */ |
| 26 struct sqlite3_mutex { | 26 struct sqlite3_mutex { |
| 27 sqlite3_mutex *pReal; | 27 sqlite3_mutex *pReal; |
| 28 int eType; | 28 int eType; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 /* State variables */ | 31 /* State variables */ |
| 32 static struct test_mutex_globals { | 32 static struct test_mutex_globals { |
| 33 int isInstalled; /* True if installed */ | 33 int isInstalled; /* True if installed */ |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 Tcl_Obj *CONST objv[] | 141 Tcl_Obj *CONST objv[] |
| 142 ){ | 142 ){ |
| 143 int rc; | 143 int rc; |
| 144 | 144 |
| 145 if( objc!=1 ){ | 145 if( objc!=1 ){ |
| 146 Tcl_WrongNumArgs(interp, 1, objv, ""); | 146 Tcl_WrongNumArgs(interp, 1, objv, ""); |
| 147 return TCL_ERROR; | 147 return TCL_ERROR; |
| 148 } | 148 } |
| 149 | 149 |
| 150 rc = sqlite3_shutdown(); | 150 rc = sqlite3_shutdown(); |
| 151 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); | 151 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
| 152 return TCL_OK; | 152 return TCL_OK; |
| 153 } | 153 } |
| 154 | 154 |
| 155 /* | 155 /* |
| 156 ** sqlite3_initialize | 156 ** sqlite3_initialize |
| 157 */ | 157 */ |
| 158 static int test_initialize( | 158 static int test_initialize( |
| 159 void * clientData, | 159 void * clientData, |
| 160 Tcl_Interp *interp, | 160 Tcl_Interp *interp, |
| 161 int objc, | 161 int objc, |
| 162 Tcl_Obj *CONST objv[] | 162 Tcl_Obj *CONST objv[] |
| 163 ){ | 163 ){ |
| 164 int rc; | 164 int rc; |
| 165 | 165 |
| 166 if( objc!=1 ){ | 166 if( objc!=1 ){ |
| 167 Tcl_WrongNumArgs(interp, 1, objv, ""); | 167 Tcl_WrongNumArgs(interp, 1, objv, ""); |
| 168 return TCL_ERROR; | 168 return TCL_ERROR; |
| 169 } | 169 } |
| 170 | 170 |
| 171 rc = sqlite3_initialize(); | 171 rc = sqlite3_initialize(); |
| 172 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); | 172 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
| 173 return TCL_OK; | 173 return TCL_OK; |
| 174 } | 174 } |
| 175 | 175 |
| 176 /* | 176 /* |
| 177 ** install_mutex_counters BOOLEAN | 177 ** install_mutex_counters BOOLEAN |
| 178 */ | 178 */ |
| 179 static int test_install_mutex_counters( | 179 static int test_install_mutex_counters( |
| 180 void * clientData, | 180 void * clientData, |
| 181 Tcl_Interp *interp, | 181 Tcl_Interp *interp, |
| 182 int objc, | 182 int objc, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 }else{ | 223 }else{ |
| 224 assert( g.m.xMutexAlloc ); | 224 assert( g.m.xMutexAlloc ); |
| 225 rc = sqlite3_config(SQLITE_CONFIG_MUTEX, &g.m); | 225 rc = sqlite3_config(SQLITE_CONFIG_MUTEX, &g.m); |
| 226 memset(&g.m, 0, sizeof(sqlite3_mutex_methods)); | 226 memset(&g.m, 0, sizeof(sqlite3_mutex_methods)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 if( rc==SQLITE_OK ){ | 229 if( rc==SQLITE_OK ){ |
| 230 g.isInstalled = isInstall; | 230 g.isInstalled = isInstall; |
| 231 } | 231 } |
| 232 | 232 |
| 233 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); | 233 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
| 234 return TCL_OK; | 234 return TCL_OK; |
| 235 } | 235 } |
| 236 | 236 |
| 237 /* | 237 /* |
| 238 ** read_mutex_counters | 238 ** read_mutex_counters |
| 239 */ | 239 */ |
| 240 static int test_read_mutex_counters( | 240 static int test_read_mutex_counters( |
| 241 void * clientData, | 241 void * clientData, |
| 242 Tcl_Interp *interp, | 242 Tcl_Interp *interp, |
| 243 int objc, | 243 int objc, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 if( Tcl_GetIndexFromObjStruct(interp, objv[1], aOpt, s, "flag", 0, &i) ){ | 348 if( Tcl_GetIndexFromObjStruct(interp, objv[1], aOpt, s, "flag", 0, &i) ){ |
| 349 if( Tcl_GetIntFromObj(interp, objv[1], &i) ){ | 349 if( Tcl_GetIntFromObj(interp, objv[1], &i) ){ |
| 350 return TCL_ERROR; | 350 return TCL_ERROR; |
| 351 } | 351 } |
| 352 }else{ | 352 }else{ |
| 353 i = aOpt[i].iValue; | 353 i = aOpt[i].iValue; |
| 354 } | 354 } |
| 355 | 355 |
| 356 rc = sqlite3_config(i); | 356 rc = sqlite3_config(i); |
| 357 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); | 357 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
| 358 return TCL_OK; | 358 return TCL_OK; |
| 359 } | 359 } |
| 360 | 360 |
| 361 static sqlite3 *getDbPointer(Tcl_Interp *pInterp, Tcl_Obj *pObj){ | 361 static sqlite3 *getDbPointer(Tcl_Interp *pInterp, Tcl_Obj *pObj){ |
| 362 sqlite3 *db; | 362 sqlite3 *db; |
| 363 Tcl_CmdInfo info; | 363 Tcl_CmdInfo info; |
| 364 char *zCmd = Tcl_GetString(pObj); | 364 char *zCmd = Tcl_GetString(pObj); |
| 365 if( Tcl_GetCommandInfo(pInterp, zCmd, &info) ){ | 365 if( Tcl_GetCommandInfo(pInterp, zCmd, &info) ){ |
| 366 db = *((sqlite3 **)info.objClientData); | 366 db = *((sqlite3 **)info.objClientData); |
| 367 }else{ | 367 }else{ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ | 430 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ |
| 431 Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); | 431 Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); |
| 432 } | 432 } |
| 433 | 433 |
| 434 Tcl_LinkVar(interp, "disable_mutex_init", | 434 Tcl_LinkVar(interp, "disable_mutex_init", |
| 435 (char*)&g.disableInit, TCL_LINK_INT); | 435 (char*)&g.disableInit, TCL_LINK_INT); |
| 436 Tcl_LinkVar(interp, "disable_mutex_try", | 436 Tcl_LinkVar(interp, "disable_mutex_try", |
| 437 (char*)&g.disableTry, TCL_LINK_INT); | 437 (char*)&g.disableTry, TCL_LINK_INT); |
| 438 return SQLITE_OK; | 438 return SQLITE_OK; |
| 439 } | 439 } |
| OLD | NEW |