/ Check-in [065e5a5e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Modify the implementation of the test code in test_vfs.c so that test VFS objects may be invoked recursively.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 065e5a5ea4f82f0d3fbb2e80d3a977af96c95683
User & Date: dan 2011-06-22 10:37:19
References
2011-08-26
17:17
Cherrypick the recursion fix to test_vfs.c from [065e5a5ea4f82]. Also fix the nan.test module to handle upper/lower case changes in TCL. check-in: 41b5f869 user: drh tags: branch-3.7.2
Context
2011-06-22
10:56
Change a test case in types3.test slightly so that it works with the latest versions of Tcl. check-in: 6e1f4df5 user: dan tags: trunk
10:37
Modify the implementation of the test code in test_vfs.c so that test VFS objects may be invoked recursively. check-in: 065e5a5e user: dan tags: trunk
2011-06-21
19:39
Fix typo in previous tester.tcl commit. check-in: c2e5faca user: shaneh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_vfs.c.

    75     75   */
    76     76   struct Testvfs {
    77     77     char *zName;                    /* Name of this VFS */
    78     78     sqlite3_vfs *pParent;           /* The VFS to use for file IO */
    79     79     sqlite3_vfs *pVfs;              /* The testvfs registered with SQLite */
    80     80     Tcl_Interp *interp;             /* Interpreter to run script in */
    81     81     Tcl_Obj *pScript;               /* Script to execute */
    82         -  int nScript;                    /* Number of elements in array apScript */
    83         -  Tcl_Obj **apScript;             /* Array version of pScript */
    84     82     TestvfsBuffer *pBuffer;         /* List of shared buffers */
    85     83     int isNoshm;
    86     84   
    87     85     int mask;                       /* Mask controlling [script] and [ioerr] */
    88     86   
    89     87     TestFaultInject ioerr_err;
    90     88     TestFaultInject full_err;
................................................................................
   263    261     Testvfs *p, 
   264    262     const char *zMethod,
   265    263     Tcl_Obj *arg1,
   266    264     Tcl_Obj *arg2,
   267    265     Tcl_Obj *arg3
   268    266   ){
   269    267     int rc;                         /* Return code from Tcl_EvalObj() */
   270         -  int nArg;                       /* Elements in eval'd list */
   271         -  int nScript;
   272         -  Tcl_Obj ** ap;
   273         -
          268  +  Tcl_Obj *pEval;
   274    269     assert( p->pScript );
   275    270   
   276         -  if( !p->apScript ){
   277         -    int nByte;
   278         -    int i;
   279         -    if( TCL_OK!=Tcl_ListObjGetElements(p->interp, p->pScript, &nScript, &ap) ){
   280         -      Tcl_BackgroundError(p->interp);
   281         -      Tcl_ResetResult(p->interp);
   282         -      return;
   283         -    }
   284         -    p->nScript = nScript;
   285         -    nByte = (nScript+TESTVFS_MAX_ARGS)*sizeof(Tcl_Obj *);
   286         -    p->apScript = (Tcl_Obj **)ckalloc(nByte);
   287         -    memset(p->apScript, 0, nByte);
   288         -    for(i=0; i<nScript; i++){
   289         -      p->apScript[i] = ap[i];
   290         -    }
   291         -  }
          271  +  assert( zMethod );
          272  +  assert( p );
          273  +  assert( arg2==0 || arg1!=0 );
          274  +  assert( arg3==0 || arg2!=0 );
   292    275   
   293         -  p->apScript[p->nScript] = Tcl_NewStringObj(zMethod, -1);
   294         -  p->apScript[p->nScript+1] = arg1;
   295         -  p->apScript[p->nScript+2] = arg2;
   296         -  p->apScript[p->nScript+3] = arg3;
          276  +  pEval = Tcl_DuplicateObj(p->pScript);
          277  +  Tcl_IncrRefCount(p->pScript);
          278  +  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zMethod, -1));
          279  +  if( arg1 ) Tcl_ListObjAppendElement(p->interp, pEval, arg1);
          280  +  if( arg2 ) Tcl_ListObjAppendElement(p->interp, pEval, arg2);
          281  +  if( arg3 ) Tcl_ListObjAppendElement(p->interp, pEval, arg3);
   297    282   
   298         -  for(nArg=p->nScript; p->apScript[nArg]; nArg++){
   299         -    Tcl_IncrRefCount(p->apScript[nArg]);
   300         -  }
   301         -
   302         -  rc = Tcl_EvalObjv(p->interp, nArg, p->apScript, TCL_EVAL_GLOBAL);
          283  +  rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);
   303    284     if( rc!=TCL_OK ){
   304    285       Tcl_BackgroundError(p->interp);
   305    286       Tcl_ResetResult(p->interp);
   306    287     }
   307         -
   308         -  for(nArg=p->nScript; p->apScript[nArg]; nArg++){
   309         -    Tcl_DecrRefCount(p->apScript[nArg]);
   310         -    p->apScript[nArg] = 0;
   311         -  }
   312    288   }
   313    289   
   314    290   
   315    291   /*
   316    292   ** Close an tvfs-file.
   317    293   */
   318    294   static int tvfsClose(sqlite3_file *pFile){
................................................................................
  1090   1066         break;
  1091   1067       }
  1092   1068   
  1093   1069       case CMD_SCRIPT: {
  1094   1070         if( objc==3 ){
  1095   1071           int nByte;
  1096   1072           if( p->pScript ){
         1073  +          int i;
  1097   1074             Tcl_DecrRefCount(p->pScript);
  1098         -          ckfree((char *)p->apScript);
  1099         -          p->apScript = 0;
  1100         -          p->nScript = 0;
  1101   1075             p->pScript = 0;
  1102   1076           }
  1103   1077           Tcl_GetStringFromObj(objv[2], &nByte);
  1104   1078           if( nByte>0 ){
  1105   1079             p->pScript = Tcl_DuplicateObj(objv[2]);
  1106   1080             Tcl_IncrRefCount(p->pScript);
  1107   1081           }
................................................................................
  1245   1219     }
  1246   1220   
  1247   1221     return TCL_OK;
  1248   1222   }
  1249   1223   
  1250   1224   static void testvfs_obj_del(ClientData cd){
  1251   1225     Testvfs *p = (Testvfs *)cd;
         1226  +  int i;
  1252   1227     if( p->pScript ) Tcl_DecrRefCount(p->pScript);
  1253   1228     sqlite3_vfs_unregister(p->pVfs);
  1254         -  ckfree((char *)p->apScript);
  1255   1229     ckfree((char *)p->pVfs);
  1256   1230     ckfree((char *)p);
  1257   1231   }
  1258   1232   
  1259   1233   /*
  1260   1234   ** Usage:  testvfs VFSNAME ?SWITCHES?
  1261   1235   **