Modify the implementation of the test code in test_vfs.c so that test VFS objects may be invoked recursively.

FossilOrigin-Name: 065e5a5ea4f82f0d3fbb2e80d3a977af96c95683
This commit is contained in:
dan 2011-06-22 10:37:19 +00:00
parent 285a18fa45
commit 328876c0ac
3 changed files with 22 additions and 48 deletions

View File

@ -1,5 +1,5 @@
C Fix\stypo\sin\sprevious\stester.tcl\scommit.
D 2011-06-21T19:39:59.899
C Modify\sthe\simplementation\sof\sthe\stest\scode\sin\stest_vfs.c\sso\sthat\stest\sVFS\sobjects\smay\sbe\sinvoked\srecursively.
D 2011-06-22T10:37:19.411
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -228,7 +228,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
F src/test_syscall.c 162c4ec0137a549c009bb9ecab550527743cfc5d
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
F src/test_thread.c fe9a7803fc1d69cccb60f016f28c1cedf2d9fcfa
F src/test_vfs.c e7855568dfa1e0ba73668d273b65605d9f8b77e8
F src/test_vfs.c 1d82aee93e644188179da2165f4fe3ad6b62782c
F src/test_vfstrace.c 0b884e06094a746da729119a2cabdc7aa790063d
F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00
F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d
P 30dd4f887989354b5d01cc80bd9c4bd3528d3ae1
R 084de3a15eae3d4856b5e83a7233fad0
U shaneh
Z cacbdaf793f85a27b495ae7addf7022f
P c2e5faca144d2c25aada2a77b4ddefa5ca6ea925
R a4cd5b97b8672366dadaf62699ff3d86
U dan
Z 076f8a98bd958dd0f5e07208d97aac36

View File

@ -1 +1 @@
c2e5faca144d2c25aada2a77b4ddefa5ca6ea925
065e5a5ea4f82f0d3fbb2e80d3a977af96c95683

View File

@ -79,8 +79,6 @@ struct Testvfs {
sqlite3_vfs *pVfs; /* The testvfs registered with SQLite */
Tcl_Interp *interp; /* Interpreter to run script in */
Tcl_Obj *pScript; /* Script to execute */
int nScript; /* Number of elements in array apScript */
Tcl_Obj **apScript; /* Array version of pScript */
TestvfsBuffer *pBuffer; /* List of shared buffers */
int isNoshm;
@ -267,48 +265,26 @@ static void tvfsExecTcl(
Tcl_Obj *arg3
){
int rc; /* Return code from Tcl_EvalObj() */
int nArg; /* Elements in eval'd list */
int nScript;
Tcl_Obj ** ap;
Tcl_Obj *pEval;
assert( p->pScript );
if( !p->apScript ){
int nByte;
int i;
if( TCL_OK!=Tcl_ListObjGetElements(p->interp, p->pScript, &nScript, &ap) ){
Tcl_BackgroundError(p->interp);
Tcl_ResetResult(p->interp);
return;
}
p->nScript = nScript;
nByte = (nScript+TESTVFS_MAX_ARGS)*sizeof(Tcl_Obj *);
p->apScript = (Tcl_Obj **)ckalloc(nByte);
memset(p->apScript, 0, nByte);
for(i=0; i<nScript; i++){
p->apScript[i] = ap[i];
}
}
assert( zMethod );
assert( p );
assert( arg2==0 || arg1!=0 );
assert( arg3==0 || arg2!=0 );
p->apScript[p->nScript] = Tcl_NewStringObj(zMethod, -1);
p->apScript[p->nScript+1] = arg1;
p->apScript[p->nScript+2] = arg2;
p->apScript[p->nScript+3] = arg3;
pEval = Tcl_DuplicateObj(p->pScript);
Tcl_IncrRefCount(p->pScript);
Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zMethod, -1));
if( arg1 ) Tcl_ListObjAppendElement(p->interp, pEval, arg1);
if( arg2 ) Tcl_ListObjAppendElement(p->interp, pEval, arg2);
if( arg3 ) Tcl_ListObjAppendElement(p->interp, pEval, arg3);
for(nArg=p->nScript; p->apScript[nArg]; nArg++){
Tcl_IncrRefCount(p->apScript[nArg]);
}
rc = Tcl_EvalObjv(p->interp, nArg, p->apScript, TCL_EVAL_GLOBAL);
rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);
if( rc!=TCL_OK ){
Tcl_BackgroundError(p->interp);
Tcl_ResetResult(p->interp);
}
for(nArg=p->nScript; p->apScript[nArg]; nArg++){
Tcl_DecrRefCount(p->apScript[nArg]);
p->apScript[nArg] = 0;
}
}
@ -1094,10 +1070,8 @@ static int testvfs_obj_cmd(
if( objc==3 ){
int nByte;
if( p->pScript ){
int i;
Tcl_DecrRefCount(p->pScript);
ckfree((char *)p->apScript);
p->apScript = 0;
p->nScript = 0;
p->pScript = 0;
}
Tcl_GetStringFromObj(objv[2], &nByte);
@ -1249,9 +1223,9 @@ static int testvfs_obj_cmd(
static void testvfs_obj_del(ClientData cd){
Testvfs *p = (Testvfs *)cd;
int i;
if( p->pScript ) Tcl_DecrRefCount(p->pScript);
sqlite3_vfs_unregister(p->pVfs);
ckfree((char *)p->apScript);
ckfree((char *)p->pVfs);
ckfree((char *)p);
}