Enhance mutex testing to include APP and VFS static mutexes.
FossilOrigin-Name: 1025873fdfd9e7e53094c48af1a79c60ae50ae97
This commit is contained in:
parent
93de653844
commit
28ae577a3d
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\sstatic\smutexes\sfor\suse\sby\sthe\sbuilt-in\s/\sthird-party\sVFSs\sand\suse\sthe\sbuilt-in\sVFS\smutex\swhere\sappropriate.
|
C Enhance\smutex\stesting\sto\sinclude\sAPP\sand\sVFS\sstatic\smutexes.
|
||||||
D 2015-07-03T21:38:09.670
|
D 2015-07-03T23:11:36.336
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 78db7e3b643002849258892ab2a9df10c24ee63d
|
F Makefile.in 78db7e3b643002849258892ab2a9df10c24ee63d
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@ -365,7 +365,7 @@ F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4
|
|||||||
F src/test_malloc.c 208f09a4e21defa496bc1094fcfadea19385a112
|
F src/test_malloc.c 208f09a4e21defa496bc1094fcfadea19385a112
|
||||||
F src/test_multiplex.c 9fefd23f6cc3fa9bf0748a5e453167e7b9f193ce
|
F src/test_multiplex.c 9fefd23f6cc3fa9bf0748a5e453167e7b9f193ce
|
||||||
F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3
|
F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3
|
||||||
F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f
|
F src/test_mutex.c 486bea424c66005d587e8272b2a742a25d251c73
|
||||||
F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10
|
F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10
|
||||||
F src/test_osinst.c 5423dc1d355f594371f27dd292ca54bd320b8196
|
F src/test_osinst.c 5423dc1d355f594371f27dd292ca54bd320b8196
|
||||||
F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00
|
F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00
|
||||||
@ -868,7 +868,7 @@ F test/multiplex.test efd015ca0b5b4a57dc9535b8feb1273eebeadb60
|
|||||||
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
|
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
|
||||||
F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101
|
F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101
|
||||||
F test/multiplex4.test e8ae4c4bd70606a5727743241f13b5701990abe4
|
F test/multiplex4.test e8ae4c4bd70606a5727743241f13b5701990abe4
|
||||||
F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41
|
F test/mutex1.test e0a44072d98189003deae4b091106f085d94bea8
|
||||||
F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
|
F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
|
||||||
F test/nan.test e9648b9d007c7045242af35e11a984d4b169443a
|
F test/nan.test e9648b9d007c7045242af35e11a984d4b169443a
|
||||||
F test/nolock.test 0540dd96f39b8876e3ffdd8814fad0ea425efeee
|
F test/nolock.test 0540dd96f39b8876e3ffdd8814fad0ea425efeee
|
||||||
@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 0778825d0ec9315c70659fae8d0640b209049dd8
|
P b202e2a1d73d104d795d2252b1c6f61d65bfb295
|
||||||
R c3e93636a97f33c44303b10895e73ee1
|
R 1dd264571c6a612a20dc2b3433c44096
|
||||||
U mistachkin
|
U mistachkin
|
||||||
Z 0231ff1cbe7c5e5e0d327907d22772e6
|
Z 47fb3c7897d245bf0611496fd190514f
|
||||||
|
@ -1 +1 @@
|
|||||||
b202e2a1d73d104d795d2252b1c6f61d65bfb295
|
1025873fdfd9e7e53094c48af1a79c60ae50ae97
|
@ -19,9 +19,18 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define MAX_MUTEXES (SQLITE_MUTEX_STATIC_VFS3+1)
|
||||||
|
|
||||||
/* defined in main.c */
|
/* defined in main.c */
|
||||||
extern const char *sqlite3ErrName(int);
|
extern const char *sqlite3ErrName(int);
|
||||||
|
|
||||||
|
static const char *aName[MAX_MUTEXES+1] = {
|
||||||
|
"fast", "recursive", "static_master", "static_mem",
|
||||||
|
"static_open", "static_prng", "static_lru", "static_pmem",
|
||||||
|
"static_app1", "static_app2", "static_app3", "static_vfs1",
|
||||||
|
"static_vfs2", "static_vfs3", 0
|
||||||
|
};
|
||||||
|
|
||||||
/* A countable mutex */
|
/* A countable mutex */
|
||||||
struct sqlite3_mutex {
|
struct sqlite3_mutex {
|
||||||
sqlite3_mutex *pReal;
|
sqlite3_mutex *pReal;
|
||||||
@ -30,13 +39,13 @@ struct sqlite3_mutex {
|
|||||||
|
|
||||||
/* State variables */
|
/* State variables */
|
||||||
static struct test_mutex_globals {
|
static struct test_mutex_globals {
|
||||||
int isInstalled; /* True if installed */
|
int isInstalled; /* True if installed */
|
||||||
int disableInit; /* True to cause sqlite3_initalize() to fail */
|
int disableInit; /* True to cause sqlite3_initalize() to fail */
|
||||||
int disableTry; /* True to force sqlite3_mutex_try() to fail */
|
int disableTry; /* True to force sqlite3_mutex_try() to fail */
|
||||||
int isInit; /* True if initialized */
|
int isInit; /* True if initialized */
|
||||||
sqlite3_mutex_methods m; /* Interface to "real" mutex system */
|
sqlite3_mutex_methods m; /* Interface to "real" mutex system */
|
||||||
int aCounter[8]; /* Number of grabs of each type of mutex */
|
int aCounter[MAX_MUTEXES]; /* Number of grabs of each type of mutex */
|
||||||
sqlite3_mutex aStatic[6]; /* The six static mutexes */
|
sqlite3_mutex aStatic[MAX_MUTEXES]; /* The static mutexes */
|
||||||
} g = {0};
|
} g = {0};
|
||||||
|
|
||||||
/* Return true if the countable mutex is currently held */
|
/* Return true if the countable mutex is currently held */
|
||||||
@ -78,7 +87,8 @@ static sqlite3_mutex *counterMutexAlloc(int eType){
|
|||||||
sqlite3_mutex *pRet = 0;
|
sqlite3_mutex *pRet = 0;
|
||||||
|
|
||||||
assert( g.isInit );
|
assert( g.isInit );
|
||||||
assert(eType<8 && eType>=0);
|
assert( eType>=SQLITE_MUTEX_FAST );
|
||||||
|
assert( eType<=SQLITE_MUTEX_STATIC_VFS3 );
|
||||||
|
|
||||||
pReal = g.m.xMutexAlloc(eType);
|
pReal = g.m.xMutexAlloc(eType);
|
||||||
if( !pReal ) return 0;
|
if( !pReal ) return 0;
|
||||||
@ -86,7 +96,10 @@ static sqlite3_mutex *counterMutexAlloc(int eType){
|
|||||||
if( eType==SQLITE_MUTEX_FAST || eType==SQLITE_MUTEX_RECURSIVE ){
|
if( eType==SQLITE_MUTEX_FAST || eType==SQLITE_MUTEX_RECURSIVE ){
|
||||||
pRet = (sqlite3_mutex *)malloc(sizeof(sqlite3_mutex));
|
pRet = (sqlite3_mutex *)malloc(sizeof(sqlite3_mutex));
|
||||||
}else{
|
}else{
|
||||||
pRet = &g.aStatic[eType-2];
|
int eStaticType = eType - (SQLITE_MUTEX_RECURSIVE + 1);
|
||||||
|
assert( eStaticType>=0 );
|
||||||
|
assert( eStaticType<MAX_MUTEXES );
|
||||||
|
pRet = &g.aStatic[eStaticType];
|
||||||
}
|
}
|
||||||
|
|
||||||
pRet->eType = eType;
|
pRet->eType = eType;
|
||||||
@ -110,6 +123,8 @@ static void counterMutexFree(sqlite3_mutex *p){
|
|||||||
*/
|
*/
|
||||||
static void counterMutexEnter(sqlite3_mutex *p){
|
static void counterMutexEnter(sqlite3_mutex *p){
|
||||||
assert( g.isInit );
|
assert( g.isInit );
|
||||||
|
assert( p->eType>=0 );
|
||||||
|
assert( p->eType<MAX_MUTEXES );
|
||||||
g.aCounter[p->eType]++;
|
g.aCounter[p->eType]++;
|
||||||
g.m.xMutexEnter(p->pReal);
|
g.m.xMutexEnter(p->pReal);
|
||||||
}
|
}
|
||||||
@ -119,6 +134,8 @@ static void counterMutexEnter(sqlite3_mutex *p){
|
|||||||
*/
|
*/
|
||||||
static int counterMutexTry(sqlite3_mutex *p){
|
static int counterMutexTry(sqlite3_mutex *p){
|
||||||
assert( g.isInit );
|
assert( g.isInit );
|
||||||
|
assert( p->eType>=0 );
|
||||||
|
assert( p->eType<MAX_MUTEXES );
|
||||||
g.aCounter[p->eType]++;
|
g.aCounter[p->eType]++;
|
||||||
if( g.disableTry ) return SQLITE_BUSY;
|
if( g.disableTry ) return SQLITE_BUSY;
|
||||||
return g.m.xMutexTry(p->pReal);
|
return g.m.xMutexTry(p->pReal);
|
||||||
@ -245,10 +262,6 @@ static int test_read_mutex_counters(
|
|||||||
){
|
){
|
||||||
Tcl_Obj *pRet;
|
Tcl_Obj *pRet;
|
||||||
int ii;
|
int ii;
|
||||||
char *aName[8] = {
|
|
||||||
"fast", "recursive", "static_master", "static_mem",
|
|
||||||
"static_open", "static_prng", "static_lru", "static_pmem"
|
|
||||||
};
|
|
||||||
|
|
||||||
if( objc!=1 ){
|
if( objc!=1 ){
|
||||||
Tcl_WrongNumArgs(interp, 1, objv, "");
|
Tcl_WrongNumArgs(interp, 1, objv, "");
|
||||||
@ -257,7 +270,7 @@ static int test_read_mutex_counters(
|
|||||||
|
|
||||||
pRet = Tcl_NewObj();
|
pRet = Tcl_NewObj();
|
||||||
Tcl_IncrRefCount(pRet);
|
Tcl_IncrRefCount(pRet);
|
||||||
for(ii=0; ii<8; ii++){
|
for(ii=0; ii<MAX_MUTEXES; ii++){
|
||||||
Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(aName[ii], -1));
|
Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(aName[ii], -1));
|
||||||
Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(g.aCounter[ii]));
|
Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(g.aCounter[ii]));
|
||||||
}
|
}
|
||||||
@ -283,7 +296,7 @@ static int test_clear_mutex_counters(
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ii=0; ii<8; ii++){
|
for(ii=0; ii<MAX_MUTEXES; ii++){
|
||||||
g.aCounter[ii] = 0;
|
g.aCounter[ii] = 0;
|
||||||
}
|
}
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
@ -371,6 +384,56 @@ static sqlite3 *getDbPointer(Tcl_Interp *pInterp, Tcl_Obj *pObj){
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static sqlite3_mutex *getStaticMutexPointer(
|
||||||
|
Tcl_Interp *pInterp,
|
||||||
|
Tcl_Obj *pObj
|
||||||
|
){
|
||||||
|
int iMutex;
|
||||||
|
if( Tcl_GetIndexFromObj(pInterp, pObj, aName, "mutex name", 0, &iMutex) ){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
assert( iMutex!=SQLITE_MUTEX_FAST && iMutex!=SQLITE_MUTEX_RECURSIVE );
|
||||||
|
return counterMutexAlloc(iMutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_enter_static_mutex(
|
||||||
|
void * clientData,
|
||||||
|
Tcl_Interp *interp,
|
||||||
|
int objc,
|
||||||
|
Tcl_Obj *CONST objv[]
|
||||||
|
){
|
||||||
|
sqlite3_mutex *pMutex;
|
||||||
|
if( objc!=2 ){
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "NAME");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
pMutex = getStaticMutexPointer(interp, objv[1]);
|
||||||
|
if( !pMutex ){
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
sqlite3_mutex_enter(pMutex);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_leave_static_mutex(
|
||||||
|
void * clientData,
|
||||||
|
Tcl_Interp *interp,
|
||||||
|
int objc,
|
||||||
|
Tcl_Obj *CONST objv[]
|
||||||
|
){
|
||||||
|
sqlite3_mutex *pMutex;
|
||||||
|
if( objc!=2 ){
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "NAME");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
pMutex = getStaticMutexPointer(interp, objv[1]);
|
||||||
|
if( !pMutex ){
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
sqlite3_mutex_leave(pMutex);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int test_enter_db_mutex(
|
static int test_enter_db_mutex(
|
||||||
void * clientData,
|
void * clientData,
|
||||||
Tcl_Interp *interp,
|
Tcl_Interp *interp,
|
||||||
@ -418,6 +481,9 @@ int Sqlitetest_mutex_Init(Tcl_Interp *interp){
|
|||||||
{ "sqlite3_initialize", (Tcl_ObjCmdProc*)test_initialize },
|
{ "sqlite3_initialize", (Tcl_ObjCmdProc*)test_initialize },
|
||||||
{ "sqlite3_config", (Tcl_ObjCmdProc*)test_config },
|
{ "sqlite3_config", (Tcl_ObjCmdProc*)test_config },
|
||||||
|
|
||||||
|
{ "enter_static_mutex", (Tcl_ObjCmdProc*)test_enter_static_mutex },
|
||||||
|
{ "leave_static_mutex", (Tcl_ObjCmdProc*)test_leave_static_mutex },
|
||||||
|
|
||||||
{ "enter_db_mutex", (Tcl_ObjCmdProc*)test_enter_db_mutex },
|
{ "enter_db_mutex", (Tcl_ObjCmdProc*)test_enter_db_mutex },
|
||||||
{ "leave_db_mutex", (Tcl_ObjCmdProc*)test_leave_db_mutex },
|
{ "leave_db_mutex", (Tcl_ObjCmdProc*)test_leave_db_mutex },
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ proc mutex_counters {varname} {
|
|||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# Tests mutex1-1.* test that sqlite3_config() returns SQLITE_MISUSE if
|
# Tests mutex1-1.* test that sqlite3_config() returns SQLITE_MISUSE if
|
||||||
# is called at the wrong time. And that the first time sqlite3_initialize
|
# is called at the wrong time. And that the first time sqlite3_initialize
|
||||||
# is called it obtains the 'static_master' mutex 3 times and a recursive
|
# is called it obtains the 'static_master' mutex 3 times and a recursive
|
||||||
# mutex (sqlite3Config.pInitMutex) twice. Subsequent calls are no-ops
|
# mutex (sqlite3Config.pInitMutex) twice. Subsequent calls are no-ops
|
||||||
# that do not require any mutexes.
|
# that do not require any mutexes.
|
||||||
#
|
#
|
||||||
do_test mutex1-1.0 {
|
do_test mutex1-1.0 {
|
||||||
@ -102,12 +102,16 @@ ifcapable threadsafe&&shared_cache {
|
|||||||
foreach {mode mutexes} {
|
foreach {mode mutexes} {
|
||||||
singlethread {}
|
singlethread {}
|
||||||
multithread {
|
multithread {
|
||||||
fast static_lru static_master static_mem static_open static_prng
|
fast static_app1 static_app2 static_app3
|
||||||
static_pmem
|
static_lru static_master static_mem static_open
|
||||||
|
static_prng static_pmem static_vfs1 static_vfs2
|
||||||
|
static_vfs3
|
||||||
}
|
}
|
||||||
serialized {
|
serialized {
|
||||||
fast recursive static_lru static_master static_mem static_open
|
fast recursive static_app1 static_app2
|
||||||
static_prng static_pmem
|
static_app3 static_lru static_master static_mem
|
||||||
|
static_open static_prng static_pmem static_vfs1
|
||||||
|
static_vfs2 static_vfs3
|
||||||
}
|
}
|
||||||
} {
|
} {
|
||||||
|
|
||||||
@ -129,9 +133,28 @@ ifcapable threadsafe&&shared_cache {
|
|||||||
ifcapable !memorymanage {
|
ifcapable !memorymanage {
|
||||||
regsub { static_lru} $mutexes {} mutexes
|
regsub { static_lru} $mutexes {} mutexes
|
||||||
}
|
}
|
||||||
do_test mutex1.2.$mode.3 {
|
if {$mode ne "singlethread"} {
|
||||||
|
do_test mutex1.2.$mode.3 {
|
||||||
|
#
|
||||||
|
# NOTE: Make sure all the app and vfs mutexes get used.
|
||||||
|
#
|
||||||
|
enter_static_mutex static_app1
|
||||||
|
leave_static_mutex static_app1
|
||||||
|
enter_static_mutex static_app2
|
||||||
|
leave_static_mutex static_app2
|
||||||
|
enter_static_mutex static_app3
|
||||||
|
leave_static_mutex static_app3
|
||||||
|
enter_static_mutex static_vfs1
|
||||||
|
leave_static_mutex static_vfs1
|
||||||
|
enter_static_mutex static_vfs2
|
||||||
|
leave_static_mutex static_vfs2
|
||||||
|
enter_static_mutex static_vfs3
|
||||||
|
leave_static_mutex static_vfs3
|
||||||
|
} {}
|
||||||
|
}
|
||||||
|
do_test mutex1.2.$mode.4 {
|
||||||
mutex_counters counters
|
mutex_counters counters
|
||||||
|
|
||||||
set res [list]
|
set res [list]
|
||||||
foreach {key value} [array get counters] {
|
foreach {key value} [array get counters] {
|
||||||
if {$key ne "total" && $value > 0} {
|
if {$key ne "total" && $value > 0} {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user