/ Changes On Branch winopen-retry-logic
Login

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

Changes In Branch winopen-retry-logic Excluding Merge-Ins

This is equivalent to a diff from 861a5b62 to 4cb17881

2011-08-03
22:06
Merge the winopen-retry-logic branch into trunk. The biggest change here is to test scripts, which should now use such as copy_file and delete_file from tester.tcl rather than the raw file commands of TCL. (check-in: b90c28be user: drh tags: trunk)
2011-08-02
23:45
Add explanatory comment to the win32lock-2.2 test case. (Closed-Leaf check-in: 4cb17881 user: mistachkin tags: winopen-retry-logic)
23:34
Correct subtle timing issues in the win32lock test cases and in the lock_win32_file Tcl command. Also, eliminate superfluous MSVC compiler warnings. (check-in: 7baf0294 user: mistachkin tags: winopen-retry-logic)
20:14
Exclude the 8_3_names.test script from the inmemory_journal permutation. (check-in: 78fc94c8 user: drh tags: trunk)
20:01
Merge in the permutation changes from trunk. (check-in: b30a5e30 user: drh tags: winopen-retry-logic)
19:59
Also exclude backcompat.test from inmemory_journal since inmemory_journal is not compatible with WAL mode. (check-in: 861a5b62 user: drh tags: trunk)
19:30
Omit backcompat.test from the journaltest permutation because it uses WAL mode which is incompatible with journaltest. (check-in: 2bbf3150 user: drh tags: trunk)

Changes to Makefile.msc.

    39     39   
    40     40   # Define -DNDEBUG to compile without debugging (i.e., for production usage)
    41     41   # Omitting the define will cause extra debugging code to be inserted and
    42     42   # includes extra comments when "EXPLAIN stmt" is used.
    43     43   #
    44     44   TCC = $(TCC) -DNDEBUG
    45     45   
           46  +#
           47  +# Prevent warnings about "insecure" runtime library functions being used.
           48  +#
           49  +TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
           50  +
    46     51   # The locations of the Tcl header and library files.  Also, the library that
    47     52   # non-stubs enabled programs using Tcl must link against.  These variables
    48     53   # (TCLINCDIR, TCLLIBDIR, and LIBTCL) may be overridden via the environment
    49     54   # prior to running nmake in order to match the actual installed location and
    50     55   # version on this machine.
    51     56   #
    52     57   !if "$(TCLINCDIR)" == ""

Changes to src/os_win.c.

  2187   2187     DWORD dwFlagsAndAttributes = 0;
  2188   2188   #if SQLITE_OS_WINCE
  2189   2189     int isTemp = 0;
  2190   2190   #endif
  2191   2191     winFile *pFile = (winFile*)id;
  2192   2192     void *zConverted;              /* Filename in OS encoding */
  2193   2193     const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */
         2194  +  int cnt = 0;
  2194   2195   
  2195   2196     /* If argument zPath is a NULL pointer, this function is required to open
  2196   2197     ** a temporary file. Use this buffer to store the file name in.
  2197   2198     */
  2198   2199     char zTmpname[MAX_PATH+1];     /* Buffer used to create temp filename */
  2199   2200   
  2200   2201     int rc = SQLITE_OK;            /* Function Return Code */
................................................................................
  2306   2307     /* Reports from the internet are that performance is always
  2307   2308     ** better if FILE_FLAG_RANDOM_ACCESS is used.  Ticket #2699. */
  2308   2309   #if SQLITE_OS_WINCE
  2309   2310     dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
  2310   2311   #endif
  2311   2312   
  2312   2313     if( isNT() ){
  2313         -    h = CreateFileW((WCHAR*)zConverted,
  2314         -       dwDesiredAccess,
  2315         -       dwShareMode,
  2316         -       NULL,
  2317         -       dwCreationDisposition,
  2318         -       dwFlagsAndAttributes,
  2319         -       NULL
  2320         -    );
         2314  +    while( (h = CreateFileW((WCHAR*)zConverted,
         2315  +                            dwDesiredAccess,
         2316  +                            dwShareMode, NULL,
         2317  +                            dwCreationDisposition,
         2318  +                            dwFlagsAndAttributes,
         2319  +                            NULL))==INVALID_HANDLE_VALUE &&
         2320  +                            retryIoerr(&cnt) ){}
  2321   2321   /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
  2322   2322   ** Since the ASCII version of these Windows API do not exist for WINCE,
  2323   2323   ** it's important to not reference them for WINCE builds.
  2324   2324   */
  2325   2325   #if SQLITE_OS_WINCE==0
  2326   2326     }else{
  2327         -    h = CreateFileA((char*)zConverted,
  2328         -       dwDesiredAccess,
  2329         -       dwShareMode,
  2330         -       NULL,
  2331         -       dwCreationDisposition,
  2332         -       dwFlagsAndAttributes,
  2333         -       NULL
  2334         -    );
         2327  +    while( (h = CreateFileA((char*)zConverted,
         2328  +                            dwDesiredAccess,
         2329  +                            dwShareMode, NULL,
         2330  +                            dwCreationDisposition,
         2331  +                            dwFlagsAndAttributes,
         2332  +                            NULL))==INVALID_HANDLE_VALUE &&
         2333  +                            retryIoerr(&cnt) ){}
  2335   2334   #endif
  2336   2335     }
         2336  +
         2337  +  logIoerr(cnt);
  2337   2338   
  2338   2339     OSTRACE(("OPEN %d %s 0x%lx %s\n", 
  2339   2340              h, zName, dwDesiredAccess, 
  2340   2341              h==INVALID_HANDLE_VALUE ? "failed" : "ok"));
  2341   2342   
  2342   2343     if( h==INVALID_HANDLE_VALUE ){
  2343   2344       pFile->lastErrno = GetLastError();

Changes to src/test1.c.

  5641   5641   
  5642   5642   #if SQLITE_OS_WIN
  5643   5643   /*
  5644   5644   ** Information passed from the main thread into the windows file locker
  5645   5645   ** background thread.
  5646   5646   */
  5647   5647   struct win32FileLocker {
         5648  +  char *evName;       /* Name of event to signal thread startup */
  5648   5649     HANDLE h;           /* Handle of the file to be locked */
  5649   5650     int delay1;         /* Delay before locking */
  5650   5651     int delay2;         /* Delay before unlocking */
  5651   5652     int ok;             /* Finished ok */
  5652   5653     int err;            /* True if an error occurs */
  5653   5654   };
  5654   5655   #endif
................................................................................
  5656   5657   
  5657   5658   #if SQLITE_OS_WIN
  5658   5659   /*
  5659   5660   ** The background thread that does file locking.
  5660   5661   */
  5661   5662   static void win32_file_locker(void *pAppData){
  5662   5663     struct win32FileLocker *p = (struct win32FileLocker*)pAppData;
         5664  +  if( p->evName ){
         5665  +    HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName);
         5666  +    if ( ev ){
         5667  +      SetEvent(ev);
         5668  +      CloseHandle(ev);
         5669  +    }
         5670  +  }
  5663   5671     if( p->delay1 ) Sleep(p->delay1);
  5664   5672     if( LockFile(p->h, 0, 0, 100000000, 0) ){
  5665   5673       Sleep(p->delay2);
  5666   5674       UnlockFile(p->h, 0, 0, 100000000, 0);
  5667   5675       p->ok = 1;
  5668   5676     }else{
  5669   5677       p->err = 1;
................................................................................
  5684   5692   */
  5685   5693   static int win32_file_lock(
  5686   5694     void * clientData,
  5687   5695     Tcl_Interp *interp,
  5688   5696     int objc,
  5689   5697     Tcl_Obj *CONST objv[]
  5690   5698   ){
  5691         -  static struct win32FileLocker x = { 0, 0, 0 };
         5699  +  static struct win32FileLocker x = { "win32_file_lock", 0, 0, 0, 0, 0 };
  5692   5700     const char *zFilename;
         5701  +  char zBuf[200];
  5693   5702     int retry = 0;
         5703  +  HANDLE ev;
         5704  +  DWORD wResult;
  5694   5705     
  5695   5706     if( objc!=4 && objc!=1 ){
  5696   5707       Tcl_WrongNumArgs(interp, 1, objv, "FILENAME DELAY1 DELAY2");
  5697   5708       return TCL_ERROR;
  5698   5709     }
  5699   5710     if( objc==1 ){
  5700         -    char zBuf[200];
  5701   5711       sqlite3_snprintf(sizeof(zBuf), zBuf, "%d %d %d %d %d",
  5702   5712                        x.ok, x.err, x.delay1, x.delay2, x.h);
  5703   5713       Tcl_AppendResult(interp, zBuf, (char*)0);
  5704   5714       return TCL_OK;
  5705   5715     }
  5706   5716     while( x.h && retry<30 ){
  5707   5717       retry++;
................................................................................
  5716   5726     zFilename = Tcl_GetString(objv[1]);
  5717   5727     x.h = CreateFile(zFilename, GENERIC_READ|GENERIC_WRITE,
  5718   5728                 FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_ALWAYS,
  5719   5729                 FILE_ATTRIBUTE_NORMAL, 0);
  5720   5730     if( !x.h ){
  5721   5731       Tcl_AppendResult(interp, "cannot open file: ", zFilename, (char*)0);
  5722   5732       return TCL_ERROR;
         5733  +  }
         5734  +  ev = CreateEvent(NULL, TRUE, FALSE, x.evName);
         5735  +  if ( !ev ){
         5736  +    Tcl_AppendResult(interp, "cannot create event: ", x.evName, (char*)0);
         5737  +    return TCL_ERROR;
  5723   5738     }
  5724   5739     _beginthread(win32_file_locker, 0, (void*)&x);
  5725   5740     Sleep(0);
         5741  +  if ( (wResult = WaitForSingleObject(ev, 10000))!=WAIT_OBJECT_0 ){
         5742  +    sqlite3_snprintf(sizeof(zBuf), zBuf, "0x%x", wResult);
         5743  +    Tcl_AppendResult(interp, "wait failed: ", zBuf, (char*)0);
         5744  +    CloseHandle(ev);
         5745  +    return TCL_ERROR;
         5746  +  }
         5747  +  CloseHandle(ev);
  5726   5748     return TCL_OK;
  5727   5749   }
  5728   5750   #endif
  5729   5751   
  5730   5752   
  5731   5753   /*
  5732   5754   **      optimization_control DB OPT BOOLEAN

Changes to test/8_3_names.test.

    63     63     }
    64     64     file exists test.db-journal
    65     65   } 0
    66     66   do_test 8_3_names-2.1 {
    67     67     file exists test.nal
    68     68   } 1
    69     69   forcedelete test2.db test2.nal test2.db-journal
    70         -file copy test.db test2.db
    71         -file copy test.nal test2.nal
           70  +copy_file test.db test2.db
           71  +copy_file test.nal test2.nal
    72     72   do_test 8_3_names-2.2 {
    73     73     db eval {
    74     74       COMMIT;
    75     75       SELECT length(x) FROM t1
    76     76     }
    77     77   } 15000
    78     78   do_test 8_3_names-2.3 {
................................................................................
    97     97     }
    98     98     file exists test.db-journal
    99     99   } 1
   100    100   do_test 8_3_names-3.1 {
   101    101     file exists test.nal
   102    102   } 0
   103    103   forcedelete test2.db test2.nal test2.db-journal
   104         -file copy test.db test2.db
   105         -file copy test.db-journal test2.db-journal
          104  +copy_file test.db test2.db
          105  +copy_file test.db-journal test2.db-journal
   106    106   do_test 8_3_names-3.2 {
   107    107     db eval {
   108    108       COMMIT;
   109    109       SELECT length(x) FROM t1
   110    110     }
   111    111   } 15000
   112    112   do_test 8_3_names-3.3 {

Changes to test/alter.test.

   217    217        index {sqlite_autoindex_<t2>_2}    <t2>          \
   218    218     ]
   219    219   
   220    220   # Check that ALTER TABLE works on attached databases.
   221    221   #
   222    222   ifcapable attach {
   223    223     do_test alter-1.8.1 {
   224         -    file delete -force test2.db
   225         -    file delete -force test2.db-journal
          224  +    forcedelete test2.db
          225  +    forcedelete test2.db-journal
   226    226       execsql {
   227    227         ATTACH 'test2.db' AS aux;
   228    228       }
   229    229     } {}
   230    230     do_test alter-1.8.2 {
   231    231       execsql {
   232    232         CREATE TABLE t4(a PRIMARY KEY, b, c);
................................................................................
   408    408       INSERT INTO t9 VALUES(4, 5, 6);
   409    409     }
   410    410     set ::TRIGGER
   411    411   } {trig3 4 5 6}
   412    412   
   413    413   # Make sure "ON" cannot be used as a database, table or column name without
   414    414   # quoting. Otherwise the sqlite_alter_trigger() function might not work.
   415         -file delete -force test3.db
   416         -file delete -force test3.db-journal
          415  +forcedelete test3.db
          416  +forcedelete test3.db-journal
   417    417   ifcapable attach {
   418    418     do_test alter-3.2.1 {
   419    419       catchsql {
   420    420         ATTACH 'test3.db' AS ON;
   421    421       }
   422    422     } {1 {near "ON": syntax error}}
   423    423     do_test alter-3.2.2 {

Changes to test/alter2.test.

   311    311     db close
   312    312     set_file_format 2
   313    313     sqlite3 db test.db
   314    314     get_file_format
   315    315   } {2}
   316    316   ifcapable attach {
   317    317     do_test alter2-6.2 {
   318         -    file delete -force test2.db-journal
   319         -    file delete -force test2.db
          318  +    forcedelete test2.db-journal
          319  +    forcedelete test2.db
   320    320       execsql {
   321    321         ATTACH 'test2.db' AS aux;
   322    322         CREATE TABLE aux.t1(a, b);
   323    323       }
   324    324       get_file_format test2.db
   325    325     } $default_file_format
   326    326   }

Changes to test/alter3.test.

   192    192         PRAGMA schema_version;
   193    193       }
   194    194     } {11}
   195    195   }
   196    196   
   197    197   do_test alter3-4.1 {
   198    198     db close
   199         -  file delete -force test.db
          199  +  forcedelete test.db
   200    200     set ::DB [sqlite3 db test.db]
   201    201     execsql {
   202    202       PRAGMA legacy_file_format=ON;
   203    203       CREATE TABLE t1(a, b);
   204    204       INSERT INTO t1 VALUES(1, 100);
   205    205       INSERT INTO t1 VALUES(2, 300);
   206    206       SELECT * FROM t1;
................................................................................
   233    233     execsql {
   234    234       DROP TABLE t1;
   235    235     }
   236    236   } {}
   237    237   
   238    238   ifcapable attach {
   239    239     do_test alter3-5.1 {
   240         -    file delete -force test2.db
   241         -    file delete -force test2.db-journal
          240  +    forcedelete test2.db
          241  +    forcedelete test2.db-journal
   242    242       execsql {
   243    243         CREATE TABLE t1(a, b);
   244    244         INSERT INTO t1 VALUES(1, 'one');
   245    245         INSERT INTO t1 VALUES(2, 'two');
   246    246         ATTACH 'test2.db' AS aux;
   247    247         CREATE TABLE aux.t1 AS SELECT * FROM t1;
   248    248         PRAGMA aux.schema_version = 30;

Changes to test/alter4.test.

   174    174         PRAGMA schema_version;
   175    175       }
   176    176     } {10}
   177    177   }
   178    178   
   179    179   do_test alter4-4.1 {
   180    180     db close
   181         -  file delete -force test.db
          181  +  forcedelete test.db
   182    182     set ::DB [sqlite3 db test.db]
   183    183     execsql {
   184    184       CREATE TEMP TABLE t1(a, b);
   185    185       INSERT INTO t1 VALUES(1, 100);
   186    186       INSERT INTO t1 VALUES(2, 300);
   187    187       SELECT * FROM t1;
   188    188     }
................................................................................
   209    209     execsql {
   210    210       DROP TABLE t1;
   211    211     }
   212    212   } {}
   213    213   
   214    214   ifcapable attach {
   215    215     do_test alter4-5.1 {
   216         -    file delete -force test2.db
   217         -    file delete -force test2.db-journal
          216  +    forcedelete test2.db
          217  +    forcedelete test2.db-journal
   218    218       execsql {
   219    219         CREATE TEMP TABLE t1(a, b);
   220    220         INSERT INTO t1 VALUES(1, 'one');
   221    221         INSERT INTO t1 VALUES(2, 'two');
   222    222         ATTACH 'test2.db' AS aux;
   223    223         CREATE TABLE aux.t1 AS SELECT * FROM t1;
   224    224         PRAGMA aux.schema_version = 30;

Changes to test/async.test.

    64     64   foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
    65     65     set tail [file tail $testfile]
    66     66     if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
    67     67     source $testfile
    68     68   
    69     69     # Make sure everything is flushed through. This is because [source]ing 
    70     70     # the next test file will delete the database file on disk (using
    71         -  # [file delete]). If the asynchronous backend still has the file
           71  +  # [delete_file]). If the asynchronous backend still has the file
    72     72     # open, it will become confused.
    73     73     #
    74     74     flush_async_queue
    75     75   }
    76     76   
    77     77   # Flush the write-queue and disable asynchronous IO. This should ensure
    78     78   # all allocated memory is cleaned up.

Changes to test/async2.test.

    47     47   db close
    48     48   
    49     49   foreach err [list ioerr malloc-transient malloc-persistent] {
    50     50     set ::go 10
    51     51     for {set n 1} {$::go} {incr n} {
    52     52       set ::sqlite_io_error_pending 0
    53     53       sqlite3_memdebug_fail -1
    54         -    file delete -force test.db test.db-journal
           54  +    forcedelete test.db test.db-journal
    55     55       sqlite3 db test.db
    56     56       execsql $::setup_script
    57     57       db close
    58     58     
    59     59       sqlite3async_initialize "" 1
    60     60       sqlite3 db test.db
    61     61       sqlite3_db_config_lookaside db 0 0 0

Changes to test/async3.test.

    37     37     chocolate/banana/./vanilla/file.db
    38     38     chocolate/banana/../banana/vanilla/file.db
    39     39     chocolate/banana/./vanilla/extra_bit/../file.db
    40     40   }
    41     41   
    42     42   do_test async3-1.0 {
    43     43     file mkdir [file join chocolate banana vanilla]
    44         -  file delete -force chocolate/banana/vanilla/file.db
    45         -  file delete -force chocolate/banana/vanilla/file.db-journal
           44  +  forcedelete chocolate/banana/vanilla/file.db
           45  +  forcedelete chocolate/banana/vanilla/file.db-journal
    46     46   } {}
    47     47   
    48     48   do_test async3-1.1 {
    49     49     sqlite3 db chocolate/banana/vanilla/file.db
    50     50     execsql {
    51     51       CREATE TABLE abc(a, b, c);
    52     52       BEGIN;

Changes to test/async5.test.

    16     16   if {[info commands sqlite3async_initialize] eq ""} {
    17     17     # The async logic is not built into this system
    18     18     finish_test
    19     19     return
    20     20   }
    21     21   
    22     22   db close
    23         -file delete -force test2.db
           23  +forcedelete test2.db
    24     24   sqlite3async_initialize "" 1
    25     25   sqlite3async_control halt never
    26     26   sqlite3 db test.db
    27     27   
    28     28   do_test async5-1.1 {
    29     29     execsql {
    30     30       ATTACH 'test2.db' AS next;

Changes to test/attach.test.

    20     20   
    21     21   ifcapable !attach {
    22     22     finish_test
    23     23     return
    24     24   }
    25     25   
    26     26   for {set i 2} {$i<=15} {incr i} {
    27         -  file delete -force test$i.db
    28         -  file delete -force test$i.db-journal
           27  +  forcedelete test$i.db
           28  +  forcedelete test$i.db-journal
    29     29   }
    30     30   
    31     31   do_test attach-1.1 {
    32     32     execsql {
    33     33       CREATE TABLE t1(a,b);
    34     34       INSERT INTO t1 VALUES(1,2);
    35     35       INSERT INTO t1 VALUES(3,4);
................................................................................
   624    624   # Tests for the sqliteFix...() routines in attach.c
   625    625   #
   626    626   ifcapable {trigger} {
   627    627   do_test attach-5.1 {
   628    628     db close
   629    629     sqlite3 db test.db
   630    630     db2 close
   631         -  file delete -force test2.db
          631  +  forcedelete test2.db
   632    632     sqlite3 db2 test2.db
   633    633     catchsql {
   634    634       ATTACH DATABASE 'test.db' AS orig;
   635    635       CREATE TRIGGER r1 AFTER INSERT ON orig.t1 BEGIN
   636    636         SELECT 'no-op';
   637    637       END;
   638    638     } db2
................................................................................
   721    721     do_test attach-6.2 {
   722    722       sqlite3 dbx cannot-read
   723    723       dbx eval {CREATE TABLE t1(a,b,c)}
   724    724       dbx close
   725    725       file attributes cannot-read -permission 0000
   726    726       if {[file writable cannot-read]} {
   727    727         puts "\n**** Tests do not work when run as root ****"
   728         -      file delete -force cannot-read
          728  +      forcedelete cannot-read
   729    729         exit 1
   730    730       }
   731    731       catchsql {
   732    732         ATTACH DATABASE 'cannot-read' AS noread;
   733    733       }
   734    734     } {1 {unable to open database: cannot-read}}
   735    735     do_test attach-6.2.2 {
   736    736       db errorcode
   737    737     } {14}
   738         -  file delete -force cannot-read
          738  +  forcedelete cannot-read
   739    739   }
   740    740   
   741    741   # Check the error message if we try to access a database that has
   742    742   # not been attached.
   743    743   do_test attach-6.3 {
   744    744     catchsql {
   745    745       CREATE TABLE no_such_db.t1(a, b, c);
   746    746     }
   747    747   } {1 {unknown database no_such_db}}
   748    748   for {set i 2} {$i<=15} {incr i} {
   749    749     catch {db$i close}
   750    750   }
   751    751   db close
   752         -file delete -force test2.db
   753         -file delete -force no-such-file
          752  +forcedelete test2.db
          753  +forcedelete no-such-file
   754    754   
   755    755   ifcapable subquery {
   756    756     do_test attach-7.1 {
   757         -    file delete -force test.db test.db-journal
          757  +    forcedelete test.db test.db-journal
   758    758       sqlite3 db test.db
   759    759       catchsql {
   760    760         DETACH RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY 
   761    761         REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL )
   762    762       }
   763    763     } {1 {no such table: AAAAAA}}
   764    764   }
................................................................................
   773    773     catchsql {
   774    774       ATTACH 'test2.db' AS t2;
   775    775     }
   776    776   } {1 {file is encrypted or is not a database}}
   777    777   do_test attach-8.2 {
   778    778     db errorcode
   779    779   } {26}
   780         -file delete -force test2.db
          780  +forcedelete test2.db
   781    781   do_test attach-8.3 {
   782    782     sqlite3 db2 test2.db
   783    783     db2 eval {CREATE TABLE t1(x); BEGIN EXCLUSIVE}
   784    784     catchsql {
   785    785       ATTACH 'test2.db' AS t2;
   786    786     }
   787    787   } {1 {database is locked}}
   788    788   do_test attach-8.4 {
   789    789     db errorcode
   790    790   } {5}
   791    791   db2 close
   792         -file delete -force test2.db
          792  +forcedelete test2.db
   793    793   
   794    794   # Test that it is possible to attach the same database more than
   795    795   # once when not in shared-cache mode. That this is not possible in
   796    796   # shared-cache mode is tested in shared7.test.
   797    797   do_test attach-9.1 {
   798         -  file delete -force test4.db
          798  +  forcedelete test4.db
   799    799     execsql {
   800    800       ATTACH 'test4.db' AS aux1;
   801    801       CREATE TABLE aux1.t1(a, b);
   802    802       INSERT INTO aux1.t1 VALUES(1, 2);
   803    803       ATTACH 'test4.db' AS aux2;
   804    804       SELECT * FROM aux2.t1;
   805    805     }

Changes to test/attach2.test.

    29     29   # sure we can attach test2.db from test.db.
    30     30   #
    31     31   do_test attach2-1.1 {
    32     32     db eval {
    33     33       CREATE TABLE t1(a,b);
    34     34       CREATE INDEX x1 ON t1(a);
    35     35     }
    36         -  file delete -force test2.db
    37         -  file delete -force test2.db-journal
           36  +  forcedelete test2.db
           37  +  forcedelete test2.db-journal
    38     38     sqlite3 db2 test2.db
    39     39     db2 eval {
    40     40       CREATE TABLE t1(a,b);
    41     41       CREATE INDEX x1 ON t1(a);
    42     42     }
    43     43     catchsql {
    44     44       ATTACH 'test2.db' AS t2;
................................................................................
   323    323   } {}
   324    324   do_test attach2-4.15 {
   325    325     execsql {SELECT * FROM t1} db2
   326    326   } {1 2 1 2}
   327    327   
   328    328   db close
   329    329   db2 close
   330         -file delete -force test2.db
          330  +forcedelete test2.db
   331    331   sqlite3_soft_heap_limit $soft_limit
   332    332   
   333    333   # These tests - attach2-5.* - check that the master journal file is deleted
   334    334   # correctly when a multi-file transaction is committed or rolled back.
   335    335   #
   336    336   # Update: It's not actually created if a rollback occurs, so that test
   337    337   # doesn't really prove too much.
   338         -foreach f [glob test.db*] {file delete -force $f}
          338  +foreach f [glob test.db*] {forcedelete $f}
   339    339   do_test attach2-5.1 {
   340    340     sqlite3 db test.db
   341    341     execsql {
   342    342       ATTACH 'test.db2' AS aux;
   343    343     }
   344    344   } {}
   345    345   do_test attach2-5.2 {

Changes to test/attach3.test.

    31     31   # Create tables t1 and t2 in the main database
    32     32   execsql {
    33     33     CREATE TABLE t1(a, b);
    34     34     CREATE TABLE t2(c, d);
    35     35   }
    36     36   
    37     37   # Create tables t1 and t2 in database file test2.db
    38         -file delete -force test2.db
    39         -file delete -force test2.db-journal
           38  +forcedelete test2.db
           39  +forcedelete test2.db-journal
    40     40   sqlite3 db2 test2.db
    41     41   execsql {
    42     42     CREATE TABLE t1(a, b);
    43     43     CREATE TABLE t2(c, d);
    44     44   } db2
    45     45   db2 close
    46     46   

Changes to test/attachmalloc.test.

    25     25   
    26     26   source $testdir/malloc_common.tcl
    27     27   
    28     28   do_malloc_test attachmalloc-1 -tclprep {
    29     29     catch { db close }
    30     30     for {set i 2} {$i<=4} {incr i} {
    31     31       catch { db$i close }
    32         -    file delete -force test$i.db
    33         -    file delete -force test$i.db-journal
           32  +    forcedelete test$i.db
           33  +    forcedelete test$i.db-journal
    34     34     }
    35     35   } -tclbody {
    36     36     if {[catch {sqlite3 db test.db}]} {
    37     37       error "out of memory"
    38     38     }
    39     39     sqlite3_db_config_lookaside db 0 0 0
    40     40     sqlite3_extended_result_codes db 1
................................................................................
    44     44     ATTACH 'test3.db' AS three;
    45     45     CREATE TABLE three.t1(x);
    46     46     ATTACH 'test4.db' AS four;
    47     47     CREATE TABLE four.t1(x);
    48     48   }
    49     49   
    50     50   do_malloc_test attachmalloc-2 -tclprep {
    51         -  file delete -force test2.db
    52         -  file delete -force test2.db-journal
           51  +  forcedelete test2.db
           52  +  forcedelete test2.db-journal
    53     53     sqlite3 db2 test2.db
    54     54     db2 eval {
    55     55       CREATE TABLE t1(a, b, c);
    56     56       CREATE INDEX i1 ON t1(a, b);
    57     57     }
    58     58     db2 close
    59     59   } -sqlbody {

Changes to test/autoinc.test.

   423    423     } {}
   424    424   }
   425    425   
   426    426   # Make sure AUTOINCREMENT works on ATTACH-ed tables.
   427    427   #
   428    428   ifcapable tempdb&&attach {
   429    429     do_test autoinc-5.1 {
   430         -    file delete -force test2.db
   431         -    file delete -force test2.db-journal
          430  +    forcedelete test2.db
          431  +    forcedelete test2.db-journal
   432    432       sqlite3 db2 test2.db
   433    433       execsql {
   434    434         CREATE TABLE t4(m INTEGER PRIMARY KEY AUTOINCREMENT, n);
   435    435         CREATE TABLE t5(o, p INTEGER PRIMARY KEY AUTOINCREMENT);
   436    436       } db2;
   437    437       execsql {
   438    438         ATTACH 'test2.db' as aux;
................................................................................
   516    516   
   517    517   # Ticket #1283.  Make sure that preparing but never running a statement
   518    518   # that creates the sqlite_sequence table does not mess up the database.
   519    519   #
   520    520   do_test autoinc-8.1 {
   521    521     catch {db2 close}
   522    522     catch {db close}
   523         -  file delete -force test.db
          523  +  forcedelete test.db
   524    524     sqlite3 db test.db
   525    525     set DB [sqlite3_connection_pointer db]
   526    526     set STMT [sqlite3_prepare $DB {
   527    527        CREATE TABLE t1(
   528    528          x INTEGER PRIMARY KEY AUTOINCREMENT
   529    529        )
   530    530     } -1 TAIL]

Changes to test/autovacuum.test.

   463    463       PRAGMA auto_vacuum = 0;
   464    464       PRAGMA auto_vacuum;
   465    465     }
   466    466   } {1}
   467    467   
   468    468   do_test autovacuum-3.4 {
   469    469     db close
   470         -  file delete -force test.db
          470  +  forcedelete test.db
   471    471     sqlite3 db test.db
   472    472     execsql {
   473    473       PRAGMA auto_vacuum;
   474    474     }
   475    475   } $AUTOVACUUM
   476    476   do_test autovacuum-3.5 {
   477    477     execsql {
................................................................................
   498    498   # rolled back no corruption occurs.
   499    499   #
   500    500   do_test autovacuum-4.0 {
   501    501     # The last round of tests may have left the db in non-autovacuum mode.
   502    502     # Reset everything just in case.
   503    503     #
   504    504     db close
   505         -  file delete -force test.db test.db-journal
          505  +  forcedelete test.db test.db-journal
   506    506     sqlite3 db test.db
   507    507     execsql {
   508    508       PRAGMA auto_vacuum = 1;
   509    509       PRAGMA auto_vacuum;
   510    510     }
   511    511   } {1}
   512    512   do_test autovacuum-4.1 {
................................................................................
   595    595   #---------------------------------------------------------------------
   596    596   # Test cases autovacuum-7.X test the case where a page must be moved
   597    597   # and the destination location collides with at least one other
   598    598   # entry in the page hash-table (internal to the pager.c module. 
   599    599   #
   600    600   do_test autovacuum-7.1 {
   601    601     db close
   602         -  file delete -force test.db
   603         -  file delete -force test.db-journal
          602  +  forcedelete test.db
          603  +  forcedelete test.db-journal
   604    604     sqlite3 db test.db
   605    605   
   606    606     execsql {
   607    607       PRAGMA auto_vacuum=1;
   608    608       CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
   609    609       INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400));
   610    610       INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2

Changes to test/autovacuum_ioerr2.test.

    71     71     BEGIN;
    72     72     INSERT INTO abc2 VALUES(10);
    73     73     DROP TABLE abc;
    74     74     COMMIT;
    75     75     DROP TABLE abc2;
    76     76   }
    77     77   
    78         -file delete -force backup.db
           78  +forcedelete backup.db
    79     79   ifcapable subquery {
    80     80     do_ioerr_test autovacuum-ioerr2-4 -tclprep {
    81     81       if {![file exists backup.db]} {
    82     82         sqlite3 dbb backup.db 
    83     83         execsql {
    84     84           PRAGMA auto_vacuum = 1;
    85     85           BEGIN;
................................................................................
    95     95         execsql {
    96     96           COMMIT;
    97     97           PRAGMA cache_size = 10;
    98     98         } dbb
    99     99         dbb close
   100    100       }
   101    101       db close
   102         -    file delete -force test.db
   103         -    file delete -force test.db-journal
   104         -    copy_file backup.db test.db
          102  +    forcedelete test.db
          103  +    forcedelete test.db-journal
          104  +    forcecopy backup.db test.db
   105    105       set ::DB [sqlite3 db test.db]
   106    106       execsql {
   107    107         PRAGMA cache_size = 10;
   108    108       }
   109    109     } -sqlbody {
   110    110       BEGIN;
   111    111       DELETE FROM abc WHERE oid < 3;

Changes to test/backcompat.test.

    57     57     puts -nonewline "Testing against $bin - "
    58     58     flush stdout
    59     59     puts "version [get_version $bin]"
    60     60   }
    61     61   
    62     62   proc do_backcompat_test {rv bin1 bin2 script} {
    63     63   
    64         -  file delete -force test.db
           64  +  forcedelete test.db
    65     65   
    66     66     if {$bin1 != ""} { set ::bc_chan1 [launch_testfixture $bin1] }
    67     67     set ::bc_chan2 [launch_testfixture $bin2]
    68     68   
    69     69     if { $rv } {
    70     70       proc code2 {tcl} { uplevel #0 $tcl }
    71     71       if {$bin1 != ""} { proc code2 {tcl} { testfixture $::bc_chan1 $tcl } }
................................................................................
   148    148     set ret [list]
   149    149     foreach f {test.db test.db-journal test.db-wal} { lappend ret [read_file $f] }
   150    150     set ret
   151    151   }
   152    152   proc write_file_system {data} {
   153    153     foreach f {test.db test.db-journal test.db-wal} d $data { 
   154    154       if {[string length $d] == 0} {
   155         -      file delete -force $f
          155  +      forcedelete $f
   156    156       } else {
   157    157         write_file $f $d
   158    158       }
   159    159     }
   160    160   }
   161    161   
   162    162   #-------------------------------------------------------------------------

Changes to test/backup.test.

    69     69   # Sanity check to verify that the [test_contents] proc works.
    70     70   #
    71     71   test_contents backup-1.2 db main db main
    72     72   
    73     73   # Check that it is possible to create and finish backup operations.
    74     74   #
    75     75   do_test backup-1.3.1 {
    76         -  file delete test2.db
           76  +  delete_file test2.db
    77     77     sqlite3 db2 test2.db
    78     78     sqlite3_backup B db2 main db main
    79     79   } {B}
    80     80   do_test backup-1.3.2 {
    81     81     B finish
    82     82   } {SQLITE_OK}
    83     83   do_test backup-1.3.3 {
................................................................................
   164    164     set file_dest temp
   165    165   }] {
   166    166   foreach rows_dest {0 3 10} {
   167    167   foreach pgsz_dest {512 1024 2048} {
   168    168   foreach nPagePerStep {1 200} {
   169    169   
   170    170     # Open the databases.
   171         -  catch { file delete test.db }
   172         -  catch { file delete test2.db }
          171  +  catch { delete_file test.db }
          172  +  catch { delete_file test2.db }
   173    173     eval $zOpenScript
   174    174   
   175    175     # Set to true if copying to an in-memory destination. Copying to an 
   176    176     # in-memory destination is only possible if the initial destination
   177    177     # page size is the same as the source page size (in this case 1024 bytes).
   178    178     #
   179    179     set isMemDest [expr {
................................................................................
   275    275   #   * Target database page-size is smaller than the source.
   276    276   #
   277    277   set iTest 1
   278    278   foreach nSrcPg {10 64 65 66 100} {
   279    279   foreach nDestRow {10 100} {
   280    280   foreach nDestPgsz {512 1024 2048 4096} {
   281    281   
   282         -  catch { file delete test.db }
   283         -  catch { file delete test2.db }
          282  +  catch { delete_file test.db }
          283  +  catch { delete_file test2.db }
   284    284     sqlite3 db test.db
   285    285     sqlite3 db2 test2.db
   286    286   
   287    287     # Set up the content of the two databases.
   288    288     #
   289    289     execsql { PRAGMA page_size = 1024 }
   290    290     execsql "PRAGMA page_size = $nDestPgsz" db2
................................................................................
   323    323     incr iTest
   324    324   }
   325    325   }
   326    326   }
   327    327   
   328    328   #--------------------------------------------------------------------
   329    329   do_test backup-3.$iTest.1 {
   330         -  catch { file delete -force test.db }
   331         -  catch { file delete -force test2.db }
          330  +  catch { forcedelete test.db }
          331  +  catch { forcedelete test2.db }
   332    332     sqlite3 db test.db
   333    333     set iTab 1
   334    334   
   335    335     db eval { PRAGMA page_size = 512 }
   336    336     while {[file size test.db] <= $::sqlite_pending_byte} {
   337    337       db eval "CREATE TABLE t${iTab}(a, b, c)"
   338    338       incr iTab
................................................................................
   388    388     catch { sqlite3_backup B db main db2 aux }
   389    389   } {1}
   390    390   do_test backup-4.1.4 {
   391    391     sqlite3_errmsg db
   392    392   } {unknown database aux}
   393    393   
   394    394   do_test backup-4.2.1 {
   395         -  catch { file delete -force test3.db }
   396         -  catch { file delete -force test4.db }
          395  +  catch { forcedelete test3.db }
          396  +  catch { forcedelete test4.db }
   397    397     execsql { 
   398    398       ATTACH 'test3.db' AS aux1;
   399    399       CREATE TABLE aux1.t1(a, b);
   400    400     }
   401    401     execsql { 
   402    402       ATTACH 'test4.db' AS aux2;
   403    403       CREATE TABLE aux2.t2(a, b);
................................................................................
   435    435     set rc [catch {sqlite3_backup B db main db aux1}]
   436    436     list $rc [sqlite3_errcode db] [sqlite3_errmsg db]
   437    437   } {1 SQLITE_ERROR {source and destination must be distinct}}
   438    438   db close
   439    439   db2 close
   440    440   
   441    441   do_test backup-4.5.1 {
   442         -  catch { file delete -force test.db }
          442  +  catch { forcedelete test.db }
   443    443     sqlite3 db test.db
   444    444     sqlite3 db2 :memory:
   445    445     execsql {
   446    446       CREATE TABLE t1(a, b);
   447    447       INSERT INTO t1 VALUES(1, 2);
   448    448     }
   449    449     execsql {
................................................................................
   487    487   #
   488    488   #   1) Backing up file-to-file. The writer writes via an external pager.
   489    489   #   2) Backing up file-to-file. The writer writes via the same pager as
   490    490   #      is used by the backup operation.
   491    491   #   3) Backing up memory-to-file. 
   492    492   #
   493    493   set iTest 0
   494         -file delete -force bak.db-wal
          494  +forcedelete bak.db-wal
   495    495   foreach {writer file} {db test.db db3 test.db db :memory:} {
   496    496     incr iTest
   497         -  catch { file delete bak.db }
          497  +  catch { delete_file bak.db }
   498    498     sqlite3 db2 bak.db
   499         -  catch { file delete $file }
          499  +  catch { delete_file $file }
   500    500     sqlite3 db $file
   501    501     sqlite3 db3 $file
   502    502   
   503    503     do_test backup-5.$iTest.1.1 {
   504    504       execsql {
   505    505         BEGIN;
   506    506         CREATE TABLE t1(a, b);
................................................................................
   593    593     } {SQLITE_OK} 
   594    594     integrity_check backup-5.$iTest.4.5 db2
   595    595     test_contents backup-5.$iTest.4.6 db main db2 main
   596    596   
   597    597     catch {db close}
   598    598     catch {db2 close}
   599    599     catch {db3 close}
   600         -  catch { file delete bak.db }
          600  +  catch { delete_file bak.db }
   601    601     sqlite3 db2 bak.db
   602         -  catch { file delete $file }
          602  +  catch { delete_file $file }
   603    603     sqlite3 db $file
   604    604     sqlite3 db3 $file
   605    605     do_test backup-5.$iTest.5.1 {
   606    606       execsql {
   607    607         PRAGMA auto_vacuum = incremental;
   608    608         BEGIN;
   609    609         CREATE TABLE t1(a, b);
................................................................................
   640    640   # End of backup-5.* tests.
   641    641   #---------------------------------------------------------------------
   642    642   
   643    643   #---------------------------------------------------------------------
   644    644   # Test the sqlite3_backup_remaining() and backup_pagecount() APIs.
   645    645   #
   646    646   do_test backup-6.1 {
   647         -  catch { file delete -force test.db }
   648         -  catch { file delete -force test2.db }
          647  +  catch { forcedelete test.db }
          648  +  catch { forcedelete test2.db }
   649    649     sqlite3 db test.db
   650    650     sqlite3 db2 test2.db
   651    651     execsql {
   652    652       BEGIN;
   653    653       CREATE TABLE t1(a, b);
   654    654       CREATE INDEX i1 ON t1(a, b);
   655    655       INSERT INTO t1 VALUES(1, randstr(1000,1000));
................................................................................
   697    697   # backup-7.2.*: Attempt to step the backup process while a 
   698    698   #               write-transaction is underway on the source pager (return
   699    699   #               SQLITE_LOCKED).
   700    700   #
   701    701   # backup-7.3.*: Destination database is externally locked (return SQLITE_BUSY).
   702    702   #
   703    703   do_test backup-7.0 {
   704         -  catch { file delete -force test.db }
   705         -  catch { file delete -force test2.db }
          704  +  catch { forcedelete test.db }
          705  +  catch { forcedelete test2.db }
   706    706     sqlite3 db2 test2.db
   707    707     sqlite3 db test.db
   708    708     execsql {
   709    709       CREATE TABLE t1(a, b);
   710    710       CREATE INDEX i1 ON t1(a, b);
   711    711       INSERT INTO t1 VALUES(1, randstr(1000,1000));
   712    712       INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;
................................................................................
   750    750   } {SQLITE_OK}
   751    751   test_contents backup-7.2.5 db main db2 main
   752    752   integrity_check backup-7.3.6 db2
   753    753   
   754    754   do_test backup-7.3.1 {
   755    755     db2 close
   756    756     db3 close
   757         -  file delete -force test2.db
          757  +  forcedelete test2.db
   758    758     sqlite3 db2 test2.db
   759    759     sqlite3 db3 test2.db
   760    760   
   761    761     sqlite3_backup B db2 main db main
   762    762     execsql { BEGIN ; CREATE TABLE t2(a, b); } db3
   763    763   
   764    764     B step 5
................................................................................
   779    779   # The following tests, backup-8.*, test attaching multiple backup
   780    780   # processes to the same source database. Also, reading from the source
   781    781   # database while a read transaction is active.
   782    782   #
   783    783   # These tests reuse the database "test.db" left over from backup-7.*.
   784    784   #
   785    785   do_test backup-8.1 {
   786         -  catch { file delete -force test2.db }
   787         -  catch { file delete -force test3.db }
          786  +  catch { forcedelete test2.db }
          787  +  catch { forcedelete test3.db }
   788    788     sqlite3 db2 test2.db
   789    789     sqlite3 db3 test3.db
   790    790   
   791    791     sqlite3_backup B2 db2 main db main
   792    792     sqlite3_backup B3 db3 main db main
   793    793     list [B2 finish] [B3 finish]
   794    794   } {SQLITE_OK SQLITE_OK}
................................................................................
   861    861   do_test backup-9.2.3 {
   862    862     B finish
   863    863   } {SQLITE_OK}
   864    864   catch {db2 close}
   865    865   
   866    866   ifcapable memorymanage {
   867    867     db close
   868         -  file delete -force test.db
   869         -  file delete -force bak.db
          868  +  forcedelete test.db
          869  +  forcedelete bak.db
   870    870   
   871    871     sqlite3 db test.db
   872    872     sqlite3 db2 test.db
   873    873     sqlite3 db3 bak.db
   874    874   
   875    875     do_test backup-10.1.1 {
   876    876       execsql {
................................................................................
   914    914   # Test that if the database is written to via the same database handle being
   915    915   # used as the source by a backup operation:
   916    916   #
   917    917   #   10.1.*: If the db is in-memory, the backup is restarted.
   918    918   #   10.2.*: If the db is a file, the backup is not restarted.
   919    919   #
   920    920   db close
   921         -file delete -force test.db test.db-journal
          921  +forcedelete test.db test.db-journal
   922    922   foreach {tn file rc} {
   923    923     1 test.db  SQLITE_DONE
   924    924     2 :memory: SQLITE_OK
   925    925   } {
   926    926     do_test backup-10.$tn.1 {
   927    927       sqlite3 db $file
   928    928       execsql { 
................................................................................
   944    944   
   945    945     do_test backup-10.$tn.2 {
   946    946       set pgs [execsql {pragma page_count}]
   947    947       expr {$pgs > 50 && $pgs < 75}
   948    948     } {1}
   949    949   
   950    950     do_test backup-10.$tn.3 {
   951         -    file delete -force bak.db bak.db-journal
          951  +    forcedelete bak.db bak.db-journal
   952    952       sqlite3 db2 bak.db
   953    953       sqlite3_backup B db2 main db main
   954    954       B step 50
   955    955     } {SQLITE_OK}
   956    956   
   957    957     do_test backup-10.$tn.4 {
   958    958       execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) }

Changes to test/backup2.test.

    57     57   unset -nocomplain cksum
    58     58   set cksum [dbcksum db main]
    59     59   
    60     60   # Make a backup of the test data.  Verify that the backup copy
    61     61   # is identical to the original.
    62     62   #
    63     63   do_test backup2-2 {
    64         -  file delete -force bu1.db
           64  +  forcedelete bu1.db
    65     65     db backup bu1.db
    66     66     sqlite3 db2 bu1.db
    67     67     dbcksum db2 main
    68     68   } $cksum
    69     69   
    70     70   # Delete the original.  Restore from backup.  Verify the content is
    71     71   # unchanged.
    72     72   #
    73     73   do_test backup2-3.1 {
    74     74     db close
    75         -  file delete -force test.db test.db-journal
           75  +  forcedelete test.db test.db-journal
    76     76     sqlite3 db test.db
    77     77     db2 eval {BEGIN EXCLUSIVE}
    78     78     set rc [catch {db restore bu1.db} res]
    79     79     lappend rc $res
    80     80     db2 eval {ROLLBACK}
    81     81     set rc
    82     82   } {1 {restore failed: source database busy}}
    83     83   do_test backup2-3.2 {
    84     84     db close
    85         -  file delete -force test.db test.db-journal
           85  +  forcedelete test.db test.db-journal
    86     86     sqlite3 db test.db
    87     87     db restore bu1.db
    88     88     dbcksum db main
    89     89   } $cksum
    90     90   
    91     91   # Use alternative databases - other than "main".
    92     92   #
    93     93   do_test backup2-4 {
    94     94     db restore temp bu1.db
    95     95     dbcksum db temp
    96     96   } $cksum
    97     97   do_test backup2-5 {
    98     98     db2 close
    99         -  file delete -force bu1.db bu2.db
           99  +  forcedelete bu1.db bu2.db
   100    100     db backup temp bu2.db
   101    101     sqlite3 db2 bu2.db
   102    102     dbcksum db2 main
   103    103   } $cksum
   104    104   
   105    105   # Try to backup to a readonly file.
   106    106   #
................................................................................
   123    123     set rc [catch {db backup temp bu2.db} res]
   124    124     lappend rc $res
   125    125   } {1 {backup failed: file is encrypted or is not a database}}
   126    126   
   127    127   # Try to backup database that does not exist
   128    128   #
   129    129   do_test backup2-8 {
   130         -  file delete -force bu1.db
          130  +  forcedelete bu1.db
   131    131     set rc [catch {db backup aux1 bu1.db} res]
   132    132     lappend rc $res
   133    133   } {1 {backup failed: unknown database aux1}}
   134    134   
   135    135   # Invalid syntax on the backup method
   136    136   #
   137    137   do_test backup2-9 {
................................................................................
   139    139     lappend rc $res
   140    140   } {1 {wrong # args: should be "db backup ?DATABASE? FILENAME"}}
   141    141   
   142    142   # Try to restore from an unreadable file.
   143    143   #
   144    144   if {$tcl_platform(platform)=="windows"} {
   145    145     do_test backup2-10 {
   146         -    file delete -force bu3.db
          146  +    forcedelete bu3.db
   147    147       file mkdir bu3.db
   148    148       set rc [catch {db restore temp bu3.db} res]
   149    149       lappend rc $res
   150    150     } {1 {cannot open source database: unable to open database file}}
   151    151   }
   152    152   if {$tcl_platform(platform)!="windows"} {
   153    153     do_test backup2-10 {
   154         -    file delete -force bu3.db
          154  +    forcedelete bu3.db
   155    155       file mkdir bu3.db
   156    156       set rc [catch {db restore temp bu3.db} res]
   157    157       lappend rc $res
   158    158     } {1 {cannot open source database: disk I/O error}}
   159    159   }
   160    160   
   161    161   # Try to restore from something that is not a database file.
................................................................................
   168    168   # Try to restore a database that does not exist
   169    169   #
   170    170   do_test backup2-12 {
   171    171     set rc [catch {db restore aux1 bu2.db} res]
   172    172     lappend rc $res
   173    173   } {1 {restore failed: unknown database aux1}}
   174    174   do_test backup2-13 {
   175         -  file delete -force bu4.db
          175  +  forcedelete bu4.db
   176    176     set rc [catch {db restore bu4.db} res]
   177    177     lappend rc $res
   178    178   } {1 {cannot open source database: unable to open database file}}
   179    179   
   180    180   # Invalid syntax on the restore method
   181    181   #
   182    182   do_test backup2-14 {
   183    183     set rc [catch {db restore} res]
   184    184     lappend rc $res
   185    185   } {1 {wrong # args: should be "db restore ?DATABASE? FILENAME"}}
   186    186    
   187         -file delete -force bu1.db bu2.db bu3.db bu4.db
          187  +forcedelete bu1.db bu2.db bu3.db bu4.db
   188    188   
   189    189   finish_test

Changes to test/backup_ioerr.test.

    56     56     expr {$nPage>130 && $nPage<160}
    57     57   } {1}
    58     58   do_test backup_ioerr-1.2 {
    59     59     expr {[file size test.db] > $sqlite_pending_byte}
    60     60   } {1}
    61     61   do_test backup_ioerr-1.3 {
    62     62     db close
    63         -  file delete -force test.db
           63  +  forcedelete test.db
    64     64   } {}
    65     65   
    66     66   # Turn off IO error simulation.
    67     67   #
    68     68   proc clear_ioerr_simulation {} {
    69     69     set ::sqlite_io_error_hit 0
    70     70     set ::sqlite_io_error_hardhit 0
................................................................................
   151    151     set bStop 0
   152    152   for {set iError 1} {$bStop == 0} {incr iError} {
   153    153     # Disable IO error simulation.
   154    154     clear_ioerr_simulation
   155    155   
   156    156     catch { ddb close }
   157    157     catch { sdb close }
   158         -  catch { file delete -force test.db }
   159         -  catch { file delete -force bak.db }
          158  +  catch { forcedelete test.db }
          159  +  catch { forcedelete bak.db }
   160    160   
   161    161     # Open the source and destination databases.
   162    162     sqlite3 sdb test.db
   163    163     sqlite3 ddb bak.db
   164    164   
   165    165     # Step 1: Populate the source and destination databases.
   166    166     populate_database sdb

Changes to test/capi3.test.

   693    693     db close
   694    694   }
   695    695   
   696    696   if {![sqlite3 -has-codec]} {
   697    697     # Now test that the library correctly handles bogus entries in the
   698    698     # sqlite_master table (schema corruption).
   699    699     do_test capi3-8.1 {
   700         -    file delete -force test.db test.db-journal
          700  +    forcedelete test.db test.db-journal
   701    701       sqlite3 db test.db
   702    702       execsql {
   703    703         CREATE TABLE t1(a);
   704    704       }
   705    705       db close
   706    706     } {}
   707    707     do_test capi3-8.2 {
................................................................................
   718    718         SELECT * FROM sqlite_master;
   719    719       }
   720    720     } {1 {malformed database schema (?)}}
   721    721     do_test capi3-8.4 {
   722    722       # Build a 5-field row record. The first field is a string 'table', and
   723    723       # subsequent fields are all NULL.
   724    724       db close
   725         -    file delete -force test.db test.db-journal
          725  +    forcedelete test.db test.db-journal
   726    726       sqlite3 db test.db
   727    727       execsql {
   728    728         CREATE TABLE t1(a);
   729    729         PRAGMA writable_schema=ON;
   730    730         INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);
   731    731       }
   732    732       db close
................................................................................
   735    735       catch { sqlite3 db test.db }
   736    736       catchsql {
   737    737         SELECT * FROM sqlite_master;
   738    738       }
   739    739     } {1 {malformed database schema (?)}}
   740    740     db close
   741    741   }
   742         -file delete -force test.db
   743         -file delete -force test.db-journal
          742  +forcedelete test.db
          743  +forcedelete test.db-journal
   744    744   
   745    745   
   746    746   # Test the english language string equivalents for sqlite error codes
   747    747   set code2english [list \
   748    748   SQLITE_OK         {not an error} \
   749    749   SQLITE_ERROR      {SQL logic error or missing database} \
   750    750   SQLITE_PERM       {access permission denied} \

Changes to test/capi3c.test.

   666    666     db close
   667    667   }
   668    668   
   669    669   if {![sqlite3 -has-codec]} {
   670    670     # Now test that the library correctly handles bogus entries in the
   671    671     # sqlite_master table (schema corruption).
   672    672     do_test capi3c-8.1 {
   673         -    file delete -force test.db test.db-journal
          673  +    forcedelete test.db test.db-journal
   674    674       sqlite3 db test.db
   675    675       execsql {
   676    676         CREATE TABLE t1(a);
   677    677       }
   678    678       db close
   679    679     } {}
   680    680     do_test capi3c-8.2 {
................................................................................
   691    691         SELECT * FROM sqlite_master;
   692    692       }
   693    693     } {1 {malformed database schema (?)}}
   694    694     do_test capi3c-8.4 {
   695    695       # Build a 5-field row record. The first field is a string 'table', and
   696    696       # subsequent fields are all NULL.
   697    697       db close
   698         -    file delete -force test.db test.db-journal
          698  +    forcedelete test.db test.db-journal
   699    699       sqlite3 db test.db
   700    700       execsql {
   701    701         CREATE TABLE t1(a);
   702    702         PRAGMA writable_schema=ON;
   703    703         INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);
   704    704       }
   705    705       db close
................................................................................
   708    708       catch { sqlite3 db test.db }
   709    709       catchsql {
   710    710         SELECT * FROM sqlite_master;
   711    711       }
   712    712     } {1 {malformed database schema (?)}}
   713    713     db close
   714    714   }
   715         -file delete -force test.db
   716         -file delete -force test.db-journal
          715  +forcedelete test.db
          716  +forcedelete test.db-journal
   717    717   
   718    718   
   719    719   # Test the english language string equivalents for sqlite error codes
   720    720   set code2english [list \
   721    721   SQLITE_OK         {not an error} \
   722    722   SQLITE_ERROR      {SQL logic error or missing database} \
   723    723   SQLITE_PERM       {access permission denied} \

Changes to test/collate7.test.

    40     40   do_test collate7-1.4 {
    41     41     sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
    42     42     db close
    43     43     set ::caseless_del
    44     44   } {2}
    45     45   
    46     46   do_test collate7-2.1 {
    47         -  file delete -force test.db test.db-journal
           47  +  forcedelete test.db test.db-journal
    48     48     sqlite3 db test.db
    49     49     sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
    50     50     execsql {
    51     51       PRAGMA encoding='utf-16';
    52     52       CREATE TABLE abc16(a COLLATE CASELESS, b, c);
    53     53     } db
    54     54     set ::caseless_del

Changes to test/corrupt.test.

    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests to make sure SQLite does not crash or
    14     14   # segfault if it sees a corrupt database file.
    15     15   #
    16     16   # $Id: corrupt.test,v 1.12 2009/07/13 09:41:45 danielk1977 Exp $
    17     17   
    18         -catch {file delete -force test.db test.db-journal test.bu}
           18  +catch {forcedelete test.db test.db-journal test.bu}
    19     19   
    20     20   set testdir [file dirname $argv0]
    21     21   source $testdir/tester.tcl
    22     22   
    23     23   # Do not use a codec for tests in this file, as the database file is
    24     24   # manipulated directly using tcl scripts (using the [hexio_write] command).
    25     25   #
................................................................................
    47     47       CREATE TABLE t2 AS SELECT * FROM t1;
    48     48       DELETE FROM t2 WHERE rowid%5!=0;
    49     49       COMMIT;
    50     50     }
    51     51   } {}
    52     52   integrity_check corrupt-1.2
    53     53   
    54         -# Copy file $from into $to
    55         -#
    56         -proc copy_file {from to} {
    57         -  set f [open $from]
    58         -  fconfigure $f -translation binary
    59         -  set t [open $to w]
    60         -  fconfigure $t -translation binary
    61         -  puts -nonewline $t [read $f [file size $from]]
    62         -  close $t
    63         -  close $f
    64         -}
    65         -
    66     54   # Setup for the tests.  Make a backup copy of the good database in test.bu.
    67     55   # Create a string of garbage data that is 256 bytes long.
    68     56   #
    69         -copy_file test.db test.bu
           57  +forcecopy test.db test.bu
    70     58   set fsize [file size test.db]
    71     59   set junk "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    72     60   while {[string length $junk]<256} {append junk $junk}
    73     61   set junk [string range $junk 0 255]
    74     62   
    75     63   # Go through the database and write garbage data into each 256 segment
    76     64   # of the file.  Then do various operations on the file to make sure that
    77     65   # the database engine can recover gracefully from the corruption.
    78     66   #
    79     67   for {set i [expr {1*256}]} {$i<$fsize-256} {incr i 256} {
    80     68     set tn [expr {$i/256}]
    81     69     db close
    82         -  copy_file test.bu test.db
           70  +  forcecopy test.bu test.db
    83     71     set fd [open test.db r+]
    84     72     fconfigure $fd -translation binary
    85     73     seek $fd $i
    86     74     puts -nonewline $fd $junk
    87     75     close $fd
    88     76     do_test corrupt-2.$tn.1 {
    89     77       sqlite3 db test.db
................................................................................
   128    116   #------------------------------------------------------------------------
   129    117   # For these tests, swap the rootpage entries of t1 (a table) and t1i1 (an
   130    118   # index on t1) in sqlite_master. Then perform a few different queries
   131    119   # and make sure this is detected as corruption.
   132    120   #
   133    121   do_test corrupt-3.1 {
   134    122     db close
   135         -  copy_file test.bu test.db
          123  +  forcecopy test.bu test.db
   136    124     sqlite3 db test.db
   137    125     list
   138    126   } {}
   139    127   do_test corrupt-3.2 {
   140    128     set t1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1i1'}]
   141    129     set t1i1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1'}]
   142    130     set cookie [expr [execsql {PRAGMA schema_version}] + 1]
................................................................................
   177    165     catchsql {
   178    166       SELECT * FROM t1 WHERE x = 'abcde';
   179    167     }
   180    168   } {1 {database disk image is malformed}}
   181    169   
   182    170   do_test corrupt-4.1 {
   183    171     db close
   184         -  file delete -force test.db test.db-journal
          172  +  forcedelete test.db test.db-journal
   185    173     sqlite3 db test.db
   186    174     execsql {
   187    175       PRAGMA page_size = 1024;
   188    176       CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
   189    177     }
   190    178     for {set i 0} {$i < 10} {incr i} {
   191    179       set text [string repeat $i 220]
................................................................................
   209    197     # index b-tree as expected. At one point this was causing an assert()
   210    198     # to fail.
   211    199     catchsql { DELETE FROM t1 WHERE rowid = 3 }
   212    200   } {1 {database disk image is malformed}}
   213    201   
   214    202   do_test corrupt-5.1 {
   215    203     db close
   216         -  file delete -force test.db test.db-journal
          204  +  forcedelete test.db test.db-journal
   217    205     sqlite3 db test.db
   218    206   
   219    207     execsql { PRAGMA page_size = 1024 }
   220    208     set ct "CREATE TABLE t1(c0 "
   221    209     set i 0
   222    210     while {[string length $ct] < 950} { append ct ", c[incr i]" }
   223    211     append ct ")"
................................................................................
   232    220   } {1 {database disk image is malformed}}
   233    221   
   234    222   # At one point, the specific corruption caused by this test case was
   235    223   # causing a buffer overwrite. Although a crash was never demonstrated,
   236    224   # running this testcase under valgrind revealed the problem.
   237    225   do_test corrupt-6.1 {
   238    226     db close
   239         -  file delete -force test.db test.db-journal
          227  +  forcedelete test.db test.db-journal
   240    228     sqlite3 db test.db
   241    229     execsql { 
   242    230       PRAGMA page_size = 1024; CREATE TABLE t1(x);
   243    231     }
   244    232   
   245    233     # The root page of t1 is 1024 bytes in size. The header is 8 bytes, and
   246    234     # each of the cells inserted by the following INSERT statements consume
................................................................................
   260    248     sqlite3 db test.db 
   261    249   
   262    250     catchsql { INSERT INTO t1 VALUES( randomblob(10) ) }
   263    251   } {1 {database disk image is malformed}}
   264    252   
   265    253   ifcapable oversize_cell_check {
   266    254     db close
   267         -  file delete -force test.db test.db-journal
          255  +  forcedelete test.db test.db-journal
   268    256     sqlite3 db test.db
   269    257     execsql { 
   270    258       PRAGMA page_size = 1024; CREATE TABLE t1(x);
   271    259     }
   272    260   
   273    261     do_test corrupt-7.1 {
   274    262       for {set i 0} {$i < 39} {incr i} {
................................................................................
   313    301       catchsql {
   314    302         INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A');
   315    303       }
   316    304     } {1 {database disk image is malformed}}
   317    305   }
   318    306   
   319    307   db close
   320         -file delete -force test.db test.db-journal
          308  +forcedelete test.db test.db-journal
   321    309   do_test corrupt-8.1 {
   322    310     sqlite3 db test.db
   323    311     execsql {
   324    312       PRAGMA page_size = 1024;
   325    313       PRAGMA secure_delete = on;
   326    314       PRAGMA auto_vacuum = 0;
   327    315       CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
................................................................................
   331    319     hexio_write test.db 2044 [hexio_render_int32 2]
   332    320     hexio_write test.db 24   [hexio_render_int32 45]
   333    321   
   334    322     catchsql { INSERT OR REPLACE INTO t1 VALUES(5, randomblob(1900)) }
   335    323   } {1 {database disk image is malformed}}
   336    324   
   337    325   db close
   338         -file delete -force test.db test.db-journal
          326  +forcedelete test.db test.db-journal
   339    327   do_test corrupt-8.2 {
   340    328     sqlite3 db test.db
   341    329     execsql {
   342    330       PRAGMA page_size = 1024;
   343    331       PRAGMA secure_delete = on;
   344    332       PRAGMA auto_vacuum = 0;
   345    333       CREATE TABLE t1(x INTEGER PRIMARY KEY, y);

Changes to test/corrupt2.test.

    37     37       CREATE TABLE abc(a, b, c);
    38     38     }
    39     39   } {}
    40     40   
    41     41   do_test corrupt2-1.2 {
    42     42   
    43     43     # Corrupt the 16 byte magic string at the start of the file
    44         -  file delete -force corrupt.db
    45         -  file delete -force corrupt.db-journal
    46         -  copy_file test.db corrupt.db
           44  +  forcedelete corrupt.db
           45  +  forcedelete corrupt.db-journal
           46  +  forcecopy test.db corrupt.db
    47     47     set f [open corrupt.db RDWR]
    48     48     seek $f 8 start
    49     49     puts $f blah
    50     50     close $f
    51     51   
    52     52     sqlite3 db2 corrupt.db
    53     53     catchsql "
................................................................................
    56     56     " db2
    57     57   } {1 {file is encrypted or is not a database}}
    58     58   
    59     59   do_test corrupt2-1.3 {
    60     60     db2 close
    61     61   
    62     62     # Corrupt the page-size (bytes 16 and 17 of page 1).
    63         -  file delete -force corrupt.db
    64         -  file delete -force corrupt.db-journal
    65         -  copy_file test.db corrupt.db
           63  +  forcedelete corrupt.db
           64  +  forcedelete corrupt.db-journal
           65  +  forcecopy test.db corrupt.db
    66     66     set f [open corrupt.db RDWR]
    67     67     fconfigure $f -encoding binary
    68     68     seek $f 16 start
    69     69     puts -nonewline $f "\x00\xFF"
    70     70     close $f
    71     71   
    72     72     sqlite3 db2 corrupt.db
................................................................................
    76     76     " db2
    77     77   } {1 {file is encrypted or is not a database}}
    78     78   
    79     79   do_test corrupt2-1.4 {
    80     80     db2 close
    81     81   
    82     82     # Corrupt the free-block list on page 1.
    83         -  file delete -force corrupt.db
    84         -  file delete -force corrupt.db-journal
    85         -  copy_file test.db corrupt.db
           83  +  forcedelete corrupt.db
           84  +  forcedelete corrupt.db-journal
           85  +  forcecopy test.db corrupt.db
    86     86     set f [open corrupt.db RDWR]
    87     87     fconfigure $f -encoding binary
    88     88     seek $f 101 start
    89     89     puts -nonewline $f "\xFF\xFF"
    90     90     close $f
    91     91   
    92     92     sqlite3 db2 corrupt.db
................................................................................
    96     96     " db2
    97     97   } {1 {database disk image is malformed}}
    98     98   
    99     99   do_test corrupt2-1.5 {
   100    100     db2 close
   101    101   
   102    102     # Corrupt the free-block list on page 1.
   103         -  file delete -force corrupt.db
   104         -  file delete -force corrupt.db-journal
   105         -  copy_file test.db corrupt.db
          103  +  forcedelete corrupt.db
          104  +  forcedelete corrupt.db-journal
          105  +  forcecopy test.db corrupt.db
   106    106     set f [open corrupt.db RDWR]
   107    107     fconfigure $f -encoding binary
   108    108     seek $f 101 start
   109    109     puts -nonewline $f "\x00\xC8"
   110    110     seek $f 200 start
   111    111     puts -nonewline $f "\x00\x00"
   112    112     puts -nonewline $f "\x10\x00"
................................................................................
   119    119     " db2
   120    120   } {1 {database disk image is malformed}}
   121    121   db2 close
   122    122   
   123    123   # Corrupt a database by having 2 indices of the same name:
   124    124   do_test corrupt2-2.1 {
   125    125   
   126         -  file delete -force corrupt.db
   127         -  file delete -force corrupt.db-journal
   128         -  copy_file test.db corrupt.db
          126  +  forcedelete corrupt.db
          127  +  forcedelete corrupt.db-journal
          128  +  forcecopy test.db corrupt.db
   129    129   
   130    130     sqlite3 db2 corrupt.db 
   131    131     execsql "
   132    132       $::presql
   133    133       CREATE INDEX a1 ON abc(a);
   134    134       CREATE INDEX a2 ON abc(b);
   135    135       PRAGMA writable_schema = 1;
................................................................................
   146    146       SELECT * FROM sqlite_master;
   147    147     " db2
   148    148   } {1 {malformed database schema (a3) - index a3 already exists}}
   149    149   
   150    150   db2 close
   151    151   
   152    152   do_test corrupt2-3.1 {
   153         -  file delete -force corrupt.db
   154         -  file delete -force corrupt.db-journal
          153  +  forcedelete corrupt.db
          154  +  forcedelete corrupt.db-journal
   155    155     sqlite3 db2 corrupt.db 
   156    156   
   157    157     execsql "
   158    158       $::presql
   159    159       PRAGMA auto_vacuum = 1;
   160    160       PRAGMA page_size = 1024;
   161    161       CREATE TABLE t1(a, b, c);
................................................................................
   196    196     } db2
   197    197   } {1 {database disk image is malformed}}
   198    198   
   199    199   db2 close
   200    200   
   201    201   unset -nocomplain result
   202    202   do_test corrupt2-5.1 {
   203         -  file delete -force corrupt.db
   204         -  file delete -force corrupt.db-journal
          203  +  forcedelete corrupt.db
          204  +  forcedelete corrupt.db-journal
   205    205     sqlite3 db2 corrupt.db 
   206    206   
   207    207     execsql "
   208    208       $::presql
   209    209       PRAGMA auto_vacuum = 0;
   210    210       PRAGMA page_size = 1024;
   211    211       CREATE TABLE t1(a, b, c);
................................................................................
   253    253   proc corruption_test {args} {
   254    254     set A(-corrupt) {}
   255    255     set A(-sqlprep) {}
   256    256     set A(-tclprep) {}
   257    257     array set A $args
   258    258   
   259    259     catch {db close}
   260         -  file delete -force corrupt.db
   261         -  file delete -force corrupt.db-journal
          260  +  forcedelete corrupt.db
          261  +  forcedelete corrupt.db-journal
   262    262   
   263    263     sqlite3 db corrupt.db 
   264    264     db eval $::presql
   265    265     eval $A(-tclprep)
   266    266     db eval $A(-sqlprep)
   267    267     db close
   268    268   

Changes to test/corrupt9.test.

    82     82   } {1}
    83     83   integrity_check corrupt9-1.2
    84     84   
    85     85   # Corrupt the freelist by adding duplicate entries to the freelist.
    86     86   # Make sure the corruption is detected.
    87     87   #
    88     88   db close
    89         -file copy -force test.db test.db-template
           89  +forcecopy test.db test.db-template
    90     90   
    91     91   corrupt_freelist test.db 1
    92     92   sqlite3 db test.db
    93     93   do_test corrupt9-2.1 {
    94     94     set x [db eval {PRAGMA integrity_check}]
    95     95     expr {$x!="ok"}
    96     96   } {1}
................................................................................
    99     99       CREATE INDEX i2 ON t2(b,a);
   100    100       REINDEX;
   101    101     }
   102    102   } {1 {database disk image is malformed}}
   103    103   
   104    104   
   105    105   db close
   106         -file copy -force test.db-template test.db
          106  +forcecopy test.db-template test.db
   107    107   corrupt_freelist test.db 2
   108    108   sqlite3 db test.db
   109    109   do_test corrupt9-3.1 {
   110    110     set x [db eval {PRAGMA integrity_check}]
   111    111     expr {$x!="ok"}
   112    112   } {1}
   113    113   do_test corrupt9-3.2 {
................................................................................
   114    114     catchsql {
   115    115       CREATE INDEX i2 ON t2(b,a);
   116    116       REINDEX;
   117    117     }
   118    118   } {1 {database disk image is malformed}}
   119    119   
   120    120   db close
   121         -file copy -force test.db-template test.db
          121  +forcecopy test.db-template test.db
   122    122   corrupt_freelist test.db 3
   123    123   sqlite3 db test.db
   124    124   do_test corrupt9-4.1 {
   125    125     set x [db eval {PRAGMA integrity_check}]
   126    126     expr {$x!="ok"}
   127    127   } {1}
   128    128   do_test corrupt9-4.2 {

Changes to test/corruptA.test.

    36     36   } {1}
    37     37   integrity_check corruptA-1.2
    38     38   
    39     39   # Corrupt the file header in various ways and make sure the corruption
    40     40   # is detected when opening the database file.
    41     41   #
    42     42   db close
    43         -file copy -force test.db test.db-template
           43  +forcecopy test.db test.db-template
    44     44   
    45     45   set unreadable_version 02
    46     46   ifcapable wal { set unreadable_version 03 }
    47     47   do_test corruptA-2.1 {
    48         -  file copy -force test.db-template test.db
           48  +  forcecopy test.db-template test.db
    49     49     hexio_write test.db 19 $unreadable_version   ;# the read format number
    50     50     sqlite3 db test.db
    51     51     catchsql {SELECT * FROM t1}  
    52     52   } {1 {file is encrypted or is not a database}}
    53     53    
    54     54   do_test corruptA-2.2 {
    55     55     db close
    56         -  file copy -force test.db-template test.db
           56  +  forcecopy test.db-template test.db
    57     57     hexio_write test.db 21 41   ;# max embedded payload fraction
    58     58     sqlite3 db test.db
    59     59     catchsql {SELECT * FROM t1}  
    60     60   } {1 {file is encrypted or is not a database}}
    61     61    
    62     62   do_test corruptA-2.3 {
    63     63     db close
    64         -  file copy -force test.db-template test.db
           64  +  forcecopy test.db-template test.db
    65     65     hexio_write test.db 22 1f   ;# min embedded payload fraction
    66     66     sqlite3 db test.db
    67     67     catchsql {SELECT * FROM t1}  
    68     68   } {1 {file is encrypted or is not a database}}
    69     69    
    70     70   do_test corruptA-2.4 {
    71     71     db close
    72         -  file copy -force test.db-template test.db
           72  +  forcecopy test.db-template test.db
    73     73     hexio_write test.db 23 21   ;# min leaf payload fraction
    74     74     sqlite3 db test.db
    75     75     catchsql {SELECT * FROM t1}  
    76     76   } {1 {file is encrypted or is not a database}}
    77     77    
    78     78   
    79     79   finish_test

Changes to test/corruptB.test.

    42     42       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    43     43       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    44     44     }
    45     45     expr {[file size test.db] > (1024*9)}
    46     46   } {1}
    47     47   integrity_check corruptB-1.2
    48     48   
    49         -file copy -force test.db bak.db
           49  +forcecopy test.db bak.db
    50     50   
    51     51   # Set the right-child of a B-Tree rootpage to refer to the root-page itself.
    52     52   #
    53     53   do_test corruptB-1.3.1 {
    54     54     set ::root [execsql {SELECT rootpage FROM sqlite_master}]
    55     55     set ::offset [expr {($::root-1)*1024}]
    56     56     hexio_write test.db [expr $offset+8] [hexio_render_int32 $::root]
................................................................................
    61     61   } {1 {database disk image is malformed}}
    62     62   
    63     63   # Set the left-child of a cell in a B-Tree rootpage to refer to the 
    64     64   # root-page itself.
    65     65   #
    66     66   do_test corruptB-1.4.1 {
    67     67     db close
    68         -  file copy -force bak.db test.db
           68  +  forcecopy bak.db test.db
    69     69     set cell_offset [hexio_get_int [hexio_read test.db [expr $offset+12] 2]]
    70     70     hexio_write test.db [expr $offset+$cell_offset] [hexio_render_int32 $::root]
    71     71   } {4}
    72     72   do_test corruptB-1.4.2 {
    73     73     sqlite3 db test.db
    74     74     catchsql { SELECT * FROM t1 }
    75     75   } {1 {database disk image is malformed}}
    76     76   
    77     77   # Now grow the table B-Tree so that it is more than 2 levels high.
    78     78   #
    79     79   do_test corruptB-1.5.1 {
    80     80     db close
    81         -  file copy -force bak.db test.db
           81  +  forcecopy bak.db test.db
    82     82     sqlite3 db test.db
    83     83     execsql {
    84     84       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    85     85       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    86     86       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    87     87       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    88     88       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    89     89       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    90     90       INSERT INTO t1 SELECT randomblob(200) FROM t1;
    91     91     }
    92     92   } {}
    93     93   
    94         -file copy -force test.db bak.db
           94  +forcecopy test.db bak.db
    95     95   
    96     96   # Set the right-child pointer of the right-child of the root page to point
    97     97   # back to the root page.
    98     98   #
    99     99   do_test corruptB-1.6.1 {
   100    100     db close
   101    101     set iRightChild [hexio_get_int [hexio_read test.db [expr $offset+8] 4]]
................................................................................
   108    108   } {1 {database disk image is malformed}}
   109    109   
   110    110   # Set the left-child pointer of a cell of the right-child of the root page to
   111    111   # point back to the root page.
   112    112   #
   113    113   do_test corruptB-1.7.1 {
   114    114     db close
   115         -  file copy -force bak.db test.db
          115  +  forcecopy bak.db test.db
   116    116     set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]]
   117    117     hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root]
   118    118   } {4}
   119    119   do_test corruptB-1.7.2 {
   120    120     sqlite3 db test.db
   121    121     catchsql { SELECT * FROM t1 }
   122    122   } {1 {database disk image is malformed}}
................................................................................
   136    136   } {1 {database disk image is malformed}}
   137    137   
   138    138   # Set the left-child pointer of a cell of the right-child of the root page to
   139    139   # point back to the root page.
   140    140   #
   141    141   do_test corruptB-1.9.1 {
   142    142     db close
   143         -  file copy -force bak.db test.db
          143  +  forcecopy bak.db test.db
   144    144     set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]]
   145    145     hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root]
   146    146   } {4}
   147    147   do_test corruptB-1.9.2 {
   148    148     sqlite3 db test.db
   149    149     catchsql { SELECT * FROM t1 }
   150    150   } {1 {database disk image is malformed}}
   151    151   
   152    152   #---------------------------------------------------------------------------
   153    153   
   154    154   do_test corruptB-2.1.1 {
   155    155     db close
   156         -  file copy -force bak.db test.db
          156  +  forcecopy bak.db test.db
   157    157     hexio_write test.db [expr $offset+8] [hexio_render_int32 0x6FFFFFFF]
   158    158   } {4}
   159    159   do_test corruptB-2.1.2 {
   160    160     sqlite3 db test.db
   161    161     catchsql { SELECT * FROM t1 }
   162    162   } {1 {database disk image is malformed}}
   163    163   
   164    164   #---------------------------------------------------------------------------
   165    165   
   166    166   # Corrupt the header-size field of a database record.
   167    167   #
   168    168   do_test corruptB-3.1.1 {
   169    169     db close
   170         -  file copy -force bak.db test.db
          170  +  forcecopy bak.db test.db
   171    171     sqlite3 db test.db
   172    172     set v [string repeat abcdefghij 200]
   173    173     execsql {
   174    174       CREATE TABLE t2(a);
   175    175       INSERT INTO t2 VALUES($v);
   176    176     }
   177    177     set t2_root [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't2'}]

Changes to test/corruptC.test.

    13     13   # This file implements tests to make sure SQLite does not crash or
    14     14   # segfault if it sees a corrupt database file.  It creates a base
    15     15   # data base file, then tests that single byte corruptions in 
    16     16   # increasingly larger quantities are handled gracefully.
    17     17   #
    18     18   # $Id: corruptC.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $
    19     19   
    20         -catch {file delete -force test.db test.db-journal test.bu}
           20  +catch {forcedelete test.db test.db-journal test.bu}
    21     21   
    22     22   set testdir [file dirname $argv0]
    23     23   source $testdir/tester.tcl
    24     24   
    25     25   # Do not use a codec for tests in this file, as the database file is
    26     26   # manipulated directly using tcl scripts (using the [hexio_write] command).
    27     27   #
................................................................................
    54     54   
    55     55   # Generate random integer
    56     56   #
    57     57   proc random {range} {
    58     58     return [expr {round(rand()*$range)}]
    59     59   }
    60     60   
    61         -# Copy file $from into $to
    62         -#
    63         -proc copy_file {from to} {
    64         -  file copy -force $from $to
    65         -}
    66         -
    67     61   # Setup for the tests.  Make a backup copy of the good database in test.bu.
    68     62   #
    69     63   db close
    70         -copy_file test.db test.bu
           64  +forcecopy test.db test.bu
    71     65   sqlite3 db test.db
    72     66   set fsize [file size test.db]
    73     67   
    74     68   # Set a quasi-random random seed. 
    75     69   if {[info exists ::G(issoak)]} {
    76     70     # If we are doing SOAK tests, we want a different
    77     71     # random seed for each run.  Ideally we would like 
................................................................................
    88     82   # First test some specific corruption tests found from earlier runs
    89     83   # with specific seeds.
    90     84   #
    91     85   
    92     86   # test that a corrupt content offset size is handled (seed 5577)
    93     87   do_test corruptC-2.1 {
    94     88     db close
    95         -  copy_file test.bu test.db
           89  +  forcecopy test.bu test.db
    96     90   
    97     91     # insert corrupt byte(s)
    98     92     hexio_write test.db 2053 [format %02x 0x04]
    99     93   
   100     94     sqlite3 db test.db
   101     95     catchsql {PRAGMA integrity_check}
   102     96   } {1 {database disk image is malformed}}
   103     97   
   104     98   # test that a corrupt content offset size is handled (seed 5649)
   105     99   do_test corruptC-2.2 {
   106    100     db close
   107         -  copy_file test.bu test.db
          101  +  forcecopy test.bu test.db
   108    102   
   109    103     # insert corrupt byte(s)
   110    104     hexio_write test.db 27   [format %02x 0x08]
   111    105     hexio_write test.db 233  [format %02x 0x6a]
   112    106     hexio_write test.db 328  [format %02x 0x67]
   113    107     hexio_write test.db 750  [format %02x 0x1f]
   114    108     hexio_write test.db 1132 [format %02x 0x52]
................................................................................
   121    115     sqlite3 db test.db
   122    116     catchsql {UPDATE t1 SET y=1}
   123    117   } {1 {database disk image is malformed}}
   124    118   
   125    119   # test that a corrupt free cell size is handled (seed 13329)
   126    120   do_test corruptC-2.3 {
   127    121     db close
   128         -  copy_file test.bu test.db
          122  +  forcecopy test.bu test.db
   129    123   
   130    124     # insert corrupt byte(s)
   131    125     hexio_write test.db 1094 [format %02x 0x76]
   132    126   
   133    127     sqlite3 db test.db
   134    128     catchsql {UPDATE t1 SET y=1}
   135    129   } {1 {database disk image is malformed}}
   136    130   
   137    131   # test that a corrupt free cell size is handled (seed 169571)
   138    132   do_test corruptC-2.4 {
   139    133     db close
   140         -  copy_file test.bu test.db
          134  +  forcecopy test.bu test.db
   141    135   
   142    136     # insert corrupt byte(s)
   143    137     hexio_write test.db 3119 [format %02x 0xdf]
   144    138   
   145    139     sqlite3 db test.db
   146    140     catchsql {UPDATE t2 SET y='abcdef-uvwxyz'}
   147    141   } {1 {database disk image is malformed}}
   148    142   
   149    143   # test that a corrupt free cell size is handled (seed 169571)
   150    144   do_test corruptC-2.5 {
   151    145     db close
   152         -  copy_file test.bu test.db
          146  +  forcecopy test.bu test.db
   153    147   
   154    148     # insert corrupt byte(s)
   155    149     hexio_write test.db 3119 [format %02x 0xdf]
   156    150     hexio_write test.db 4073 [format %02x 0xbf]
   157    151   
   158    152     sqlite3 db test.db
   159    153     catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
................................................................................
   165    159   # Corruption detected in cell 710 on page 4
   166    160   # Multiple uses for byte 661 of page 4
   167    161   # Fragmented space is 249 byte reported as 21 on page 4}}}
   168    162   
   169    163   # test that a corrupt free cell size is handled (seed 169595)
   170    164   do_test corruptC-2.6 {
   171    165     db close
   172         -  copy_file test.bu test.db
          166  +  forcecopy test.bu test.db
   173    167   
   174    168     # insert corrupt byte(s)
   175    169     hexio_write test.db 619 [format %02x 0xe2]
   176    170     hexio_write test.db 3150 [format %02x 0xa8]
   177    171   
   178    172     sqlite3 db test.db
   179    173     catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
   180    174   } {1 {database disk image is malformed}}
   181    175   
   182    176   # corruption (seed 178692)
   183    177   do_test corruptC-2.7 {
   184    178     db close
   185         -  copy_file test.bu test.db
          179  +  forcecopy test.bu test.db
   186    180   
   187    181     # insert corrupt byte(s)
   188    182     hexio_write test.db 3074 [format %02x 0xa0]
   189    183   
   190    184     sqlite3 db test.db
   191    185     catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
   192    186   } {1 {database disk image is malformed}}
   193    187   
   194    188   # corruption (seed 179069)
   195    189   do_test corruptC-2.8 {
   196    190     db close
   197         -  copy_file test.bu test.db
          191  +  forcecopy test.bu test.db
   198    192   
   199    193     # insert corrupt byte(s)
   200    194     hexio_write test.db 1393 [format %02x 0x7d]
   201    195     hexio_write test.db 84 [format %02x 0x19]
   202    196     hexio_write test.db 3287 [format %02x 0x3b]
   203    197     hexio_write test.db 2564 [format %02x 0xed]
   204    198     hexio_write test.db 2139 [format %02x 0x55]
................................................................................
   206    200     sqlite3 db test.db
   207    201     catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}
   208    202   } {1 {database disk image is malformed}}
   209    203   
   210    204   # corruption (seed 170434)
   211    205   do_test corruptC-2.9 {
   212    206     db close
   213         -  copy_file test.bu test.db
          207  +  forcecopy test.bu test.db
   214    208   
   215    209     # insert corrupt byte(s)
   216    210     hexio_write test.db 2095 [format %02x 0xd6]
   217    211   
   218    212     sqlite3 db test.db
   219    213     catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}
   220    214   } {1 {database disk image is malformed}}
   221    215   
   222    216   # corruption (seed 186504)
   223    217   do_test corruptC-2.10 {
   224    218     db close
   225         -  copy_file test.bu test.db
          219  +  forcecopy test.bu test.db
   226    220   
   227    221     # insert corrupt byte(s)
   228    222     hexio_write test.db 3130 [format %02x 0x02]
   229    223     
   230    224     sqlite3 db test.db
   231    225     catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
   232    226   } {1 {database disk image is malformed}}
   233    227   
   234    228   # corruption (seed 1589)
   235    229   do_test corruptC-2.11 {
   236    230     db close
   237         -  copy_file test.bu test.db
          231  +  forcecopy test.bu test.db
   238    232   
   239    233     # insert corrupt byte(s)
   240    234     hexio_write test.db 55 [format %02x 0xa7]
   241    235     
   242    236     sqlite3 db test.db
   243    237     catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}
   244    238   } {1 {database disk image is malformed}}
   245    239   
   246    240   # corruption (seed 14166)
   247    241   do_test corruptC-2.12 {
   248    242     db close
   249         -  copy_file test.bu test.db
          243  +  forcecopy test.bu test.db
   250    244   
   251    245     # insert corrupt byte(s)
   252    246     hexio_write test.db 974 [format %02x 0x2e]
   253    247     
   254    248     sqlite3 db test.db
   255    249     catchsql {SELECT count(*) FROM sqlite_master;}
   256    250   } {1 {malformed database schema (t1i1) - corrupt database}}
   257    251   
   258    252   # corruption (seed 218803)
   259    253   do_test corruptC-2.13 {
   260    254     db close
   261         -  copy_file test.bu test.db
          255  +  forcecopy test.bu test.db
   262    256   
   263    257     # insert corrupt byte(s)
   264    258     hexio_write test.db 102 [format %02x 0x12]
   265    259     
   266    260     sqlite3 db test.db
   267    261     catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}
   268    262   } {1 {database disk image is malformed}}
   269    263   
   270    264   do_test corruptC-2.14 {
   271    265     db close
   272         -  copy_file test.bu test.db
          266  +  forcecopy test.bu test.db
   273    267   
   274    268     sqlite3 db test.db
   275    269     set blob [string repeat abcdefghij 10000]
   276    270     execsql { INSERT INTO t1 VALUES (1, $blob) }
   277    271   
   278    272     sqlite3 db test.db
   279    273     set filesize [file size test.db]
................................................................................
   282    276   } {1 {database disk image is malformed}}
   283    277   
   284    278   # At one point this particular corrupt database was causing a buffer
   285    279   # overread. Which caused a crash in a run of all.test once.
   286    280   #
   287    281   do_test corruptC-2.15 {
   288    282     db close
   289         -  copy_file test.bu test.db
          283  +  forcecopy test.bu test.db
   290    284     hexio_write test.db 986 b9
   291    285     sqlite3 db test.db
   292    286     catchsql {SELECT count(*) FROM sqlite_master;}
   293    287   } {1 {malformed database schema (t1i1) - no such table: main.t1}}
   294    288   
   295    289   #
   296    290   # Now test for a series of quasi-random seeds.
   297    291   # We loop over the entire file size and touch
   298    292   # each byte at least once.
   299    293   for {set tn 0} {$tn<$fsize} {incr tn 1} {
   300    294   
   301    295     # setup for test
   302    296     db close
   303         -  copy_file test.bu test.db
          297  +  forcecopy test.bu test.db
   304    298     sqlite3 db test.db
   305    299   
   306    300     # Seek to a random location in the file, and write a random single byte
   307    301     # value.  Then do various operations on the file to make sure that
   308    302     # the database engine can handle the corruption gracefully.
   309    303     #
   310    304     set last 0

Changes to test/corruptD.test.

    81     81     }
    82     82     execsql {
    83     83       DELETE FROM t1 WHERE a = 10;
    84     84       DELETE FROM t1 WHERE a = 20;
    85     85       DELETE FROM t1 WHERE a = 30;
    86     86       DELETE FROM t1 WHERE a = 40;
    87     87     }
    88         -  copy_file test.db test.bu
           88  +  forcecopy test.db test.bu
    89     89   } {}
    90     90   
    91     91   proc incr_change_counter {} {
    92     92     hexio_write test.db 24 [
    93     93       hexio_render_int32 [expr [hexio_get_int [hexio_read test.db 24 4]] + 1]
    94     94     ]
    95     95   }
    96     96   
    97     97   proc restore_file {} {
    98     98     db close
    99         -  copy_file test.bu test.db
           99  +  forcecopy test.bu test.db
   100    100     sqlite3 db test.db
   101    101   }
   102    102   
   103    103   #-------------------------------------------------------------------------
   104    104   # The following tests, corruptD-1.1.*, focus on the page header field
   105    105   # containing the offset of the first free block in a page. 
   106    106   #

Changes to test/corruptE.test.

    12     12   #
    13     13   # This file implements tests to make sure SQLite does not crash or
    14     14   # segfault if it sees a corrupt database file.  It specifcally
    15     15   # focuses on rowid order corruption.
    16     16   #
    17     17   # $Id: corruptE.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $
    18     18   
    19         -catch {file delete -force test.db test.db-journal test.bu}
           19  +catch {forcedelete test.db test.db-journal test.bu}
    20     20   
    21     21   set testdir [file dirname $argv0]
    22     22   source $testdir/tester.tcl
    23     23   
    24     24   # Do not use a codec for tests in this file, as the database file is
    25     25   # manipulated directly using tcl scripts (using the [hexio_write] command).
    26     26   #
................................................................................
    56     56     }
    57     57   } {}
    58     58   
    59     59   ifcapable {integrityck} {
    60     60     integrity_check corruptE-1.2
    61     61   }
    62     62   
    63         -# Copy file $from into $to
    64         -#
    65         -proc copy_file {from to} {
    66         -  file copy -force $from $to
    67         -}
    68         -
    69     63   # Setup for the tests.  Make a backup copy of the good database in test.bu.
    70     64   #
    71     65   db close
    72         -copy_file test.db test.bu
           66  +forcecopy test.db test.bu
    73     67   sqlite3 db test.db
    74     68   set fsize [file size test.db]
    75     69   
    76     70   
    77     71   do_test corruptE-2.1 {
    78     72     db close
    79         -  copy_file test.bu test.db
           73  +  forcecopy test.bu test.db
    80     74   
    81     75     # insert corrupt byte(s)
    82     76     hexio_write test.db 2041 [format %02x 0x2e]
    83     77   
    84     78     sqlite3 db test.db
    85     79   
    86     80     set res [ catchsql {PRAGMA integrity_check} ]
................................................................................
    88     82   
    89     83     list [regexp {out of order.*previous was} $ans] \
    90     84          [regexp {out of order.*max larger than parent max} $ans]
    91     85   } {1 1}
    92     86   
    93     87   do_test corruptE-2.2 {
    94     88     db close
    95         -  copy_file test.bu test.db
           89  +  forcecopy test.bu test.db
    96     90   
    97     91     # insert corrupt byte(s)
    98     92     hexio_write test.db 2047 [format %02x 0x84]
    99     93   
   100     94     sqlite3 db test.db
   101     95   
   102     96     set res [ catchsql {PRAGMA integrity_check} ]
................................................................................
   104     98   
   105     99     list [regexp {out of order.*previous was} $ans] \
   106    100          [regexp {out of order.*min less than parent min} $ans]
   107    101   } {1 1}
   108    102   
   109    103   do_test corruptE-2.3 {
   110    104     db close
   111         -  copy_file test.bu test.db
          105  +  forcecopy test.bu test.db
   112    106   
   113    107     # insert corrupt byte(s)
   114    108     hexio_write test.db 7420 [format %02x 0xa8]
   115    109     hexio_write test.db 10459 [format %02x 0x8d]
   116    110   
   117    111     sqlite3 db test.db
   118    112   
................................................................................
   120    114     set ans [lindex $res 1]
   121    115   
   122    116     list [regexp {out of order.*max larger than parent min} $ans]
   123    117   } {1}
   124    118   
   125    119   do_test corruptE-2.4 {
   126    120     db close
   127         -  copy_file test.bu test.db
          121  +  forcecopy test.bu test.db
   128    122   
   129    123     # insert corrupt byte(s)
   130    124     hexio_write test.db 10233 [format %02x 0xd0]
   131    125   
   132    126     sqlite3 db test.db
   133    127   
   134    128     set res [ catchsql {PRAGMA integrity_check} ]
................................................................................
   161    155                   {12297 0xd7} \
   162    156                   {13303 0x53} ]
   163    157   
   164    158   set tc 1
   165    159   foreach test $tests {
   166    160     do_test corruptE-3.$tc {
   167    161       db close
   168         -    copy_file test.bu test.db
          162  +    forcecopy test.bu test.db
   169    163   
   170    164       # insert corrupt byte(s)
   171    165       hexio_write test.db [lindex $test 0] [format %02x [lindex $test 1]]
   172    166   
   173    167       sqlite3 db test.db
   174    168   
   175    169       set res [ catchsql {PRAGMA integrity_check} ]

Changes to test/crash.test.

   211    211   # crash-4.2.*: Test recovery when crash occurs during sync() of an 
   212    212   #              attached database journal file.
   213    213   # crash-4.3.*: Test recovery when crash occurs during sync() of the master
   214    214   #              journal file. 
   215    215   #
   216    216   ifcapable attach {
   217    217     do_test crash-4.0 {
   218         -    file delete -force test2.db
   219         -    file delete -force test2.db-journal
          218  +    forcedelete test2.db
          219  +    forcedelete test2.db-journal
   220    220       execsql {
   221    221         ATTACH 'test2.db' AS aux;
   222    222         PRAGMA aux.default_cache_size = 10;
   223    223         CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc;
   224    224       }
   225    225       expr ([file size test2.db] / 1024) > 450
   226    226     } {1}
................................................................................
   314    314   #--------------------------------------------------------------------------
   315    315   # The following test cases - crash-5.* - exposes a bug that existed in the
   316    316   # sqlite3pager_movepage() API used by auto-vacuum databases.
   317    317   # database when a crash occurs during a multi-file transaction. See comments
   318    318   # in test crash-5.3 for details.
   319    319   #
   320    320   db close
   321         -file delete -force test.db
          321  +forcedelete test.db
   322    322   sqlite3 db test.db
   323    323   do_test crash-5.1 {
   324    324     execsql {
   325    325       CREATE TABLE abc(a, b, c);                          -- Root page 3
   326    326       INSERT INTO abc VALUES(randstr(1500,1500), 0, 0);   -- Overflow page 4
   327    327       INSERT INTO abc SELECT * FROM abc;
   328    328       INSERT INTO abc SELECT * FROM abc;

Changes to test/crash3.test.

    69     69     {UPDATE abc SET a = 2}                               {2 2 3}       \
    70     70     {INSERT INTO abc VALUES(4, 5, randstr(1000,1000))}   {n/a} \
    71     71     {CREATE TABLE def(d, e, f)}                          {n/a} \
    72     72   ] {
    73     73     for {set ii 0} {$ii < 10} {incr ii} {
    74     74   
    75     75       db close
    76         -    file delete -force test.db test.db-journal
           76  +    forcedelete test.db test.db-journal
    77     77       sqlite3 db test.db
    78     78       do_test crash3-1.$tn.1 {
    79     79         execsql {
    80     80           PRAGMA page_size = 1024;
    81     81           BEGIN;
    82     82           CREATE TABLE abc(a, b, c);
    83     83           INSERT INTO abc VALUES(1, 2, 3);
................................................................................
   102    102       incr tn
   103    103     }
   104    104   }
   105    105   
   106    106   # This block tests both the IOCAP_SEQUENTIAL and IOCAP_SAFE_APPEND flags.
   107    107   #
   108    108   db close
   109         -file delete -force test.db test.db-journal
          109  +forcedelete test.db test.db-journal
   110    110   sqlite3 db test.db
   111    111   do_test crash3-2.0 {
   112    112     execsql {
   113    113       BEGIN;
   114    114       CREATE TABLE abc(a PRIMARY KEY, b, c);
   115    115       CREATE TABLE def(d PRIMARY KEY, e, f);
   116    116       PRAGMA default_cache_size = 10;
................................................................................
   173    173   # IOCAP_SEQUENTIAL. At one point, if both flags were set, small
   174    174   # journal files that contained only a single page, but were required 
   175    175   # for some other reason (i.e. nTrunk) were not being written to
   176    176   # disk.
   177    177   #
   178    178   for {set ii 0} {$ii < 10} {incr ii} {
   179    179     db close
   180         -  file delete -force test.db test.db-journal
          180  +  forcedelete test.db test.db-journal
   181    181     crashsql -file test.db -char {sequential atomic} {
   182    182       CREATE TABLE abc(a, b, c);
   183    183     }
   184    184     sqlite3 db test.db
   185    185     do_test crash3-3.$ii {
   186    186       execsql {PRAGMA integrity_check}
   187    187     } {ok}
   188    188   }
   189    189   
   190    190   finish_test

Changes to test/crash4.test.

    59     59   #
    60     60   # Slowly increase the delay before the crash, repeating the test
    61     61   # over and over.  Stop testing when the entire sequence of SQL
    62     62   # statements runs to completing without hitting the crash.
    63     63   #
    64     64   for {set cnt 1; set fin 0} {!$fin} {incr cnt} {
    65     65     db close
    66         -  file delete -force test.db test.db-journal
           66  +  forcedelete test.db test.db-journal
    67     67     do_test crash4-1.$cnt.1 {
    68     68       set seed [expr {int(abs(rand()*10000))}]
    69     69       set delay [expr {int($cnt/50)+1}]
    70     70       set file [expr {($cnt&1)?"test.db":"test.db-journal"}]
    71     71       set c [crashsql -delay $delay -file $file -seed $seed -tclbody {
    72     72         db eval {CREATE TABLE a(id INTEGER, name CHAR(50))}
    73     73         db eval {INSERT INTO a(id,name) VALUES(1,'one')}

Changes to test/crash5.test.

    30     30   
    31     31   for {set ii 0} {$ii < 10} {incr ii} {
    32     32     for {set jj 50} {$jj < 100} {incr jj} {
    33     33   
    34     34       # Set up the database so that it is an auto-vacuum database 
    35     35       # containing a single table (root page 3) with a single row. 
    36     36       # The row has an overflow page (page 4).
    37         -    file delete -force test.db test.db-journal
           37  +    forcedelete test.db test.db-journal
    38     38       sqlite3 db test.db
    39     39       set c [string repeat 3 1500]
    40     40       db eval {
    41     41         pragma auto_vacuum = 1;
    42     42         CREATE TABLE t1(a, b, c);
    43     43         INSERT INTO t1 VALUES('1111111111', '2222222222', $c);
    44     44       }

Changes to test/crash6.test.

    19     19   ifcapable !crashtest {
    20     20     finish_test
    21     21     return
    22     22   }
    23     23   
    24     24   for {set ii 0} {$ii < 10} {incr ii} {
    25     25     catch {db close}
    26         -  file delete -force test.db test.db-journal
           26  +  forcedelete test.db test.db-journal
    27     27     crashsql -delay 2 -file test.db {
    28     28       PRAGMA auto_vacuum=OFF;
    29     29       PRAGMA page_size=4096;
    30     30       BEGIN;
    31     31       CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
    32     32       COMMIT;
    33     33       BEGIN;
................................................................................
    36     36     }
    37     37     sqlite3 db test.db
    38     38     integrity_check crash6-1.$ii
    39     39   }
    40     40   
    41     41   for {set ii 0} {$ii < 10} {incr ii} {
    42     42     catch {db close}
    43         -  file delete -force test.db test.db-journal
           43  +  forcedelete test.db test.db-journal
    44     44     sqlite3 db test.db
    45     45     execsql {
    46     46       PRAGMA auto_vacuum=OFF;
    47     47       PRAGMA page_size=2048;
    48     48       BEGIN;
    49     49       CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
    50     50       COMMIT;
................................................................................
    62     62   }
    63     63   
    64     64   # Test case for crashing during database sync with page-size values 
    65     65   # from 1024 to 8192.
    66     66   #
    67     67   for {set ii 0} {$ii < 30} {incr ii} {
    68     68     db close
    69         -  file delete -force test.db
           69  +  forcedelete test.db
    70     70     sqlite3 db test.db
    71     71   
    72     72     set pagesize [expr 1024 << ($ii % 4)]
    73     73     if {$pagesize>$::SQLITE_MAX_PAGE_SIZE} {
    74     74       set pagesize $::SQLITE_MAX_PAGE_SIZE
    75     75     }
    76     76     do_test crash6-3.$ii.0 {

Changes to test/crash7.test.

    22     22   proc signature {} {
    23     23     return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
    24     24   }
    25     25   
    26     26   foreach f [list test.db test.db-journal] {
    27     27     for {set ii 1} {$ii < 64} {incr ii} {
    28     28       db close
    29         -    file delete test.db
           29  +    delete_file test.db
    30     30       sqlite3 db test.db
    31     31     
    32     32       set from_size [expr 1024 << ($ii&3)]
    33     33       set to_size   [expr 1024 << (($ii>>2)&3)]
    34     34     
    35     35       execsql "
    36     36         PRAGMA page_size = $from_size;

Changes to test/crash8.test.

   239    239   #
   240    240   # This block of tests test that SQLite correctly truncates such
   241    241   # journal files, and that the results behave correctly if a hot-journal
   242    242   # rollback occurs.
   243    243   #
   244    244   ifcapable pragma {
   245    245     reset_db
   246         -  file delete -force test2.db
          246  +  forcedelete test2.db
   247    247   
   248    248     do_test crash8-4.1 {
   249    249       execsql {
   250    250         PRAGMA journal_mode = persist;
   251    251         CREATE TABLE ab(a, b);
   252    252         INSERT INTO ab VALUES(0, 'abc');
   253    253         INSERT INTO ab VALUES(1, NULL);
................................................................................
   332    332     } {1}
   333    333   
   334    334     do_test crash8-4.9 {
   335    335       execsql { SELECT b FROM aux.ab WHERE a = 0 }
   336    336     } {def}
   337    337   
   338    338     do_test crash8-4.10 {
   339         -    file delete $zMasterJournal
          339  +    delete_file $zMasterJournal
   340    340       execsql { SELECT b FROM main.ab WHERE a = 0 }
   341    341     } {jkl}
   342    342   }
   343    343   
   344    344   for {set i 1} {$i < 10} {incr i} {
   345    345     catch { db close }
   346         -  file delete -force test.db test.db-journal
          346  +  forcedelete test.db test.db-journal
   347    347     sqlite3 db test.db
   348    348     do_test crash8-5.$i.1 {
   349    349       execsql {
   350    350         CREATE TABLE t1(x PRIMARY KEY);
   351    351         INSERT INTO t1 VALUES(randomblob(900));
   352    352         INSERT INTO t1 SELECT randomblob(900) FROM t1;
   353    353         INSERT INTO t1 SELECT randomblob(900) FROM t1;
................................................................................
   363    363         ROLLBACK;
   364    364         INSERT INTO t1 VALUES(randomblob(900));
   365    365       }
   366    366       execsql { PRAGMA integrity_check }
   367    367     } {ok}
   368    368     
   369    369     catch { db close }
   370         -  file delete -force test.db test.db-journal
          370  +  forcedelete test.db test.db-journal
   371    371     sqlite3 db test.db
   372    372     do_test crash8-5.$i.2 {
   373    373       execsql {
   374    374         PRAGMA cache_size = 10;
   375    375         CREATE TABLE t1(x PRIMARY KEY);
   376    376         INSERT INTO t1 VALUES(randomblob(900));
   377    377         INSERT INTO t1 SELECT randomblob(900) FROM t1;
................................................................................
   379    379         INSERT INTO t1 SELECT randomblob(900) FROM t1;
   380    380         INSERT INTO t1 SELECT randomblob(900) FROM t1;
   381    381         INSERT INTO t1 SELECT randomblob(900) FROM t1;
   382    382         INSERT INTO t1 SELECT randomblob(900) FROM t1;          /* 64 rows */
   383    383         BEGIN;
   384    384           UPDATE t1 SET x = randomblob(900);
   385    385       }
   386         -    file delete -force testX.db testX.db-journal testX.db-wal
   387         -    copy_file test.db testX.db
   388         -    copy_file test.db-journal testX.db-journal
          386  +    forcedelete testX.db testX.db-journal testX.db-wal
          387  +    forcecopy test.db testX.db
          388  +    forcecopy test.db-journal testX.db-journal
   389    389       db close
   390    390   
   391    391       crashsql -file test.db -delay [expr ($::i%2) + 1] {
   392    392         SELECT * FROM sqlite_master;
   393    393         INSERT INTO t1 VALUES(randomblob(900));
   394    394       }
   395    395   

Changes to test/createtab.test.

    23     23     set upperBound 0
    24     24   }
    25     25   
    26     26   # Run these tests for all possible values of autovacuum.
    27     27   #
    28     28   for {set av 0} {$av<=$upperBound} {incr av} {
    29     29     db close
    30         -  file delete -force test.db test.db-journal
           30  +  forcedelete test.db test.db-journal
    31     31     sqlite3 db test.db
    32     32   
    33     33     # Create a table that spans multiple pages.  It is important
    34     34     # that part of the database be in pages beyond the root page.
    35     35     #
    36     36     do_test createtab-$av.1 {
    37     37       execsql "PRAGMA auto_vacuum=$av"

Changes to test/dbstatus.test.

   151    151         CREATE VIRTUAL TABLE t2 USING echo(t1);
   152    152       }
   153    153     } {
   154    154       set tn "$::lookaside_buffer_size-$tn"
   155    155     
   156    156       # Step 1.
   157    157       db close
   158         -    file delete -force test.db
          158  +    forcedelete test.db
   159    159       sqlite3 db test.db
   160    160       sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500
   161    161       db cache size 0
   162    162   
   163    163       catch { register_echo_module db }
   164    164       ifcapable !vtab { if {[string match *x $tn]} continue }
   165    165     
................................................................................
   283    283         SELECT * FROM t2 WHERE b='abcdefg';
   284    284       }
   285    285     } {
   286    286       set tn "$::lookaside_buffer_size-$tn"
   287    287   
   288    288       # Step 1.
   289    289       db close
   290         -    file delete -force test.db
          290  +    forcedelete test.db
   291    291       sqlite3 db test.db
   292    292       sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500
   293    293       db cache size 1000
   294    294   
   295    295       catch { register_echo_module db }
   296    296       ifcapable !vtab { if {[string match *x $tn]} continue }
   297    297     

Changes to test/delete.test.

   271    271     execsql {
   272    272       PRAGMA count_changes=OFF;
   273    273       INSERT INTO t3 VALUES(123);
   274    274       SELECT * FROM t3;
   275    275     }
   276    276   } {123}
   277    277   db close
   278         -catch {file delete -force test.db-journal}
          278  +catch {forcedelete test.db-journal}
   279    279   catch {file attributes test.db -permissions 0444}
   280    280   catch {file attributes test.db -readonly 1}
   281    281   sqlite3 db test.db
   282    282   set ::DB [sqlite3_connection_pointer db]
   283    283   do_test delete-8.1 {
   284    284     catchsql {
   285    285       DELETE FROM t3;
................................................................................
   308    308   } {1 {attempt to write a readonly database}}
   309    309   do_test delete-8.6 {
   310    310     execsql {SELECT * FROM t3}
   311    311   } {123}
   312    312   integrity_check delete-8.7
   313    313   
   314    314   # Need to do the following for tcl 8.5 on mac. On that configuration, the
   315         -# -readonly flag is taken so seriously that a subsequent [file delete -force]
          315  +# -readonly flag is taken so seriously that a subsequent [forcedelete]
   316    316   # (required before the next test file can be executed) will fail.
   317    317   #
   318    318   catch {file attributes test.db -readonly 0}
   319    319   db close
   320         -file delete -force test.db test.db-journal
          320  +forcedelete test.db test.db-journal
   321    321   
   322    322   # The following tests verify that SQLite correctly handles the case
   323    323   # where an index B-Tree is being scanned, the rowid column being read
   324    324   # from each index entry and another statement deletes some rows from
   325    325   # the index B-Tree. At one point this (obscure) scenario was causing 
   326    326   # SQLite to return spurious SQLITE_CORRUPT errors and arguably incorrect
   327    327   # query results. 

Changes to test/descidx1.test.

   293    293   
   294    294   # Test the legacy_file_format pragma here because we have access to
   295    295   # the get_file_format command.
   296    296   #
   297    297   ifcapable legacyformat {
   298    298     do_test descidx1-6.1 {
   299    299       db close
   300         -    file delete -force test.db test.db-journal
          300  +    forcedelete test.db test.db-journal
   301    301       sqlite3 db test.db
   302    302       execsql {PRAGMA legacy_file_format}
   303    303     } {1}
   304    304   } else {
   305    305     do_test descidx1-6.1 {
   306    306       db close
   307         -    file delete -force test.db test.db-journal
          307  +    forcedelete test.db test.db-journal
   308    308       sqlite3 db test.db
   309    309       execsql {PRAGMA legacy_file_format}
   310    310     } {0}
   311    311   }
   312    312   do_test descidx1-6.2 {
   313    313     execsql {PRAGMA legacy_file_format=YES}
   314    314     execsql {PRAGMA legacy_file_format}
................................................................................
   324    324     do_test descidx1-6.3.1 {
   325    325       execsql {VACUUM}
   326    326       get_file_format
   327    327     } {1}
   328    328   }
   329    329   do_test descidx1-6.4 {
   330    330     db close
   331         -  file delete -force test.db test.db-journal
          331  +  forcedelete test.db test.db-journal
   332    332     sqlite3 db test.db
   333    333     execsql {PRAGMA legacy_file_format=NO}
   334    334     execsql {PRAGMA legacy_file_format}
   335    335   } {0}
   336    336   do_test descidx1-6.5 {
   337    337     execsql {
   338    338       CREATE TABLE t1(a,b,c);

Changes to test/diskfull.test.

    78     78       integrity_check ${prefix}.$::i.2
    79     79     }
    80     80   }
    81     81   
    82     82   do_diskfull_test diskfull-2 VACUUM
    83     83   
    84     84   # db close
    85         -# file delete -force test.db
    86         -# file delete -force test.db-journal
           85  +# forcedelete test.db
           86  +# forcedelete test.db-journal
    87     87   # sqlite3 db test.db
    88     88   # 
    89     89   # do_test diskfull-3.1 {
    90     90   #   execsql {
    91     91   #     PRAGMA default_cache_size = 10;
    92     92   #     CREATE TABLE t3(a, b, UNIQUE(a, b));
    93     93   #     INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );

Changes to test/e_expr.test.

   653    653   do_execsql_test e_expr-12.2.6 {SELECT CURRENT_TIME}      {00:00:01}
   654    654   do_execsql_test e_expr-12.2.7 {SELECT CURRENT_DATE}      {1970-01-01}
   655    655   do_execsql_test e_expr-12.2.8 {SELECT CURRENT_TIMESTAMP} {{1970-01-01 00:00:01}}
   656    656   set sqlite_current_time 0
   657    657   
   658    658   # EVIDENCE-OF: R-57598-59332 -- syntax diagram expr
   659    659   #
   660         -file delete -force test.db2
          660  +forcedelete test.db2
   661    661   execsql {
   662    662     ATTACH 'test.db2' AS dbname;
   663    663     CREATE TABLE dbname.tblname(cname);
   664    664   }
   665    665   
   666    666   proc glob {args} {return 1}
   667    667   db function glob glob
................................................................................
  1671   1671   db3 close
  1672   1672   }
  1673   1673   
  1674   1674   #-------------------------------------------------------------------------
  1675   1675   # Test statements related to the EXISTS and NOT EXISTS operators.
  1676   1676   #
  1677   1677   catch { db close }
  1678         -file delete -force test.db
         1678  +forcedelete test.db
  1679   1679   sqlite3 db test.db
  1680   1680   
  1681   1681   do_execsql_test e_expr-34.1 {
  1682   1682     CREATE TABLE t1(a, b);
  1683   1683     INSERT INTO t1 VALUES(1, 2);
  1684   1684     INSERT INTO t1 VALUES(NULL, 2);
  1685   1685     INSERT INTO t1 VALUES(1, NULL);
................................................................................
  1752   1752   }
  1753   1753   
  1754   1754   #-------------------------------------------------------------------------
  1755   1755   # Test statements related to scalar sub-queries.
  1756   1756   #
  1757   1757   
  1758   1758   catch { db close }
  1759         -file delete -force test.db
         1759  +forcedelete test.db
  1760   1760   sqlite3 db test.db
  1761   1761   do_test e_expr-35.0 {
  1762   1762     execsql {
  1763   1763       CREATE TABLE t2(a, b);
  1764   1764       INSERT INTO t2 VALUES('one', 'two');
  1765   1765       INSERT INTO t2 VALUES('three', NULL);
  1766   1766       INSERT INTO t2 VALUES(4, 5.0);

Changes to test/e_fts3.test.

    56     56   
    57     57   #if {$DO_MALLOC_TEST} break
    58     58   
    59     59   # Reset the database and database connection. If this iteration of the 
    60     60   # [foreach] loop is testing with OOM errors, disable the lookaside buffer.
    61     61   #
    62     62   db close
    63         -file delete -force test.db test.db-journal
           63  +forcedelete test.db test.db-journal
    64     64   sqlite3 db test.db
    65     65   if {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 }
    66     66   db eval "PRAGMA encoding = '$enc'"
    67     67   
    68     68   proc mit {blob} {
    69     69     set scan(littleEndian) i*
    70     70     set scan(bigEndian) I*
................................................................................
   633    633   
   634    634   #-------------------------------------------------------------------------
   635    635   # Test that FTS3 tables can be renamed using the ALTER RENAME command.
   636    636   # OOM errors are tested during ALTER RENAME commands also.
   637    637   #
   638    638   foreach DO_MALLOC_TEST {0 1 2} {
   639    639     db close
   640         -  file delete -force test.db test.db-journal
          640  +  forcedelete test.db test.db-journal
   641    641     sqlite3 db test.db
   642    642     if {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 }
   643    643   
   644    644     ddl_test   9.1.1             { CREATE VIRTUAL TABLE t10 USING fts3(x) }
   645    645     write_test 9.1.2 t10_content { INSERT INTO t10 VALUES('fts3 tables') }
   646    646     write_test 9.1.3 t10_content { INSERT INTO t10 VALUES('are renameable') }
   647    647   

Changes to test/enc2.test.

   138    138   
   139    139   # The three unicode encodings understood by SQLite.
   140    140   set encodings [list UTF-8 UTF-16le UTF-16be]
   141    141   
   142    142   set sqlite_os_trace 0
   143    143   set i 1
   144    144   foreach enc $encodings {
   145         -  file delete -force test.db
          145  +  forcedelete test.db
   146    146     sqlite3 db test.db
   147    147     db eval "PRAGMA encoding = \"$enc\""
   148    148     execsql $dbcontents
   149    149     do_test enc2-$i.0.1 {
   150    150       db eval {PRAGMA encoding}
   151    151     } $enc
   152    152     do_test enc2-$i.0.2 {
................................................................................
   168    168     incr i
   169    169   }
   170    170   
   171    171   # Test that it is an error to try to attach a database with a different
   172    172   # encoding to the main database.
   173    173   ifcapable attach {
   174    174     do_test enc2-4.1 {
   175         -    file delete -force test.db
          175  +    forcedelete test.db
   176    176       sqlite3 db test.db
   177    177       db eval "PRAGMA encoding = 'UTF-8'"
   178    178       db eval "CREATE TABLE abc(a, b, c);"
   179    179     } {}
   180    180     do_test enc2-4.2 {
   181         -    file delete -force test2.db
          181  +    forcedelete test2.db
   182    182       sqlite3 db2 test2.db
   183    183       db2 eval "PRAGMA encoding = 'UTF-16'"
   184    184       db2 eval "CREATE TABLE abc(a, b, c);"
   185    185     } {}
   186    186     do_test enc2-4.3 {
   187    187       catchsql {
   188    188         ATTACH 'test2.db' as aux;
................................................................................
   202    202     set l [lsearch -exact $::values $lhs]
   203    203     set r [lsearch -exact $::values $rhs]
   204    204     set res [expr $l - $r]
   205    205     # puts "enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res"
   206    206     return $res
   207    207   }
   208    208   
   209         -file delete -force test.db
          209  +forcedelete test.db
   210    210   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
   211    211   do_test enc2-5.0 {
   212    212     execsql {
   213    213       CREATE TABLE t5(a);
   214    214       INSERT INTO t5 VALUES('one');
   215    215       INSERT INTO t5 VALUES('two');
   216    216       INSERT INTO t5 VALUES('five');
................................................................................
   231    231   do_test enc2-5.3 {
   232    232     add_test_collate $DB 0 0 1
   233    233     set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
   234    234     lappend res $::test_collate_enc
   235    235   } {one two three four five UTF-16BE}
   236    236   
   237    237   db close
   238         -file delete -force test.db
          238  +forcedelete test.db
   239    239   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
   240    240   execsql {pragma encoding = 'UTF-16LE'}
   241    241   do_test enc2-5.4 {
   242    242     execsql {
   243    243       CREATE TABLE t5(a);
   244    244       INSERT INTO t5 VALUES('one');
   245    245       INSERT INTO t5 VALUES('two');
................................................................................
   261    261   do_test enc2-5.7 {
   262    262     add_test_collate $DB 1 0 0
   263    263     set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]
   264    264     lappend res $::test_collate_enc
   265    265   } {one two three four five UTF-8}
   266    266   
   267    267   db close
   268         -file delete -force test.db
          268  +forcedelete test.db
   269    269   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
   270    270   execsql {pragma encoding = 'UTF-16BE'}
   271    271   do_test enc2-5.8 {
   272    272     execsql {
   273    273       CREATE TABLE t5(a);
   274    274       INSERT INTO t5 VALUES('one');
   275    275       INSERT INTO t5 VALUES('two');
................................................................................
   307    307     lappend res $::test_collate_enc
   308    308   } {one two three four five UTF-16BE}
   309    309   do_test enc2-5.14 {
   310    310     set ::sqlite_last_needed_collation
   311    311   } test_collate
   312    312   
   313    313   db close
   314         -file delete -force test.db
          314  +forcedelete test.db
   315    315   
   316    316   do_test enc2-5.15 {
   317    317     sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]
   318    318     add_test_collate_needed $::DB
   319    319     set ::sqlite_last_needed_collation
   320    320   } {}
   321    321   do_test enc2-5.16 {
................................................................................
   329    329   # user function when more than one is available.
   330    330   
   331    331   proc test_function {enc arg} {
   332    332     return "$enc $arg"
   333    333   }
   334    334   
   335    335   db close
   336         -file delete -force test.db
          336  +forcedelete test.db
   337    337   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
   338    338   execsql {pragma encoding = 'UTF-8'}
   339    339   do_test enc2-6.0 {
   340    340     execsql {
   341    341       CREATE TABLE t5(a);
   342    342       INSERT INTO t5 VALUES('one');
   343    343     }
................................................................................
   362    362     add_test_function $DB 0 0 1
   363    363     execsql {
   364    364       SELECT test_function('sqlite')
   365    365     }
   366    366   } {{UTF-16BE sqlite}}
   367    367   
   368    368   db close
   369         -file delete -force test.db
          369  +forcedelete test.db
   370    370   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
   371    371   execsql {pragma encoding = 'UTF-16LE'}
   372    372   do_test enc2-6.3 {
   373    373     execsql {
   374    374       CREATE TABLE t5(a);
   375    375       INSERT INTO t5 VALUES('sqlite');
   376    376     }
................................................................................
   395    395     add_test_function $DB 0 0 1
   396    396     execsql {
   397    397       SELECT test_function('sqlite')
   398    398     }
   399    399   } {{UTF-16BE sqlite}}
   400    400   
   401    401   db close
   402         -file delete -force test.db
          402  +forcedelete test.db
   403    403   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
   404    404   execsql {pragma encoding = 'UTF-16BE'}
   405    405   do_test enc2-6.7 {
   406    406     execsql {
   407    407       CREATE TABLE t5(a);
   408    408       INSERT INTO t5 VALUES('sqlite');
   409    409     }
................................................................................
   429    429     execsql {
   430    430       SELECT test_function('sqlite')
   431    431     }
   432    432   } {{UTF-16BE sqlite}}
   433    433   
   434    434   
   435    435   db close
   436         -file delete -force test.db
          436  +forcedelete test.db
   437    437   
   438    438   # The following tests - enc2-7.* - function as follows:
   439    439   #
   440    440   # 1: Open an empty database file assuming UTF-16 encoding.
   441    441   # 2: Open the same database with a different handle assuming UTF-8. Create
   442    442   #    a table using this handle.
   443    443   # 3: Read the sqlite_master table from the first handle. 
................................................................................
   489    489     do_test enc2-8.2 {
   490    490       sqlite3_complete16 [utf16 "SELECT * FROM"]
   491    491     } {0}
   492    492   }
   493    493   
   494    494   # Test that the encoding of an empty database may still be set after the
   495    495   # (empty) schema has been initialized.
   496         -file delete -force test.db
          496  +forcedelete test.db
   497    497   do_test enc2-9.1 {
   498    498     sqlite3 db test.db
   499    499     execsql {
   500    500       PRAGMA encoding = 'UTF-8';
   501    501       PRAGMA encoding;
   502    502     }
   503    503   } {UTF-8}
................................................................................
   533    533   } {UTF-16le}
   534    534   
   535    535   # Ticket #1987.
   536    536   # Disallow encoding changes once the encoding has been set.
   537    537   #
   538    538   do_test enc2-10.1 {
   539    539     db close
   540         -  file delete -force test.db test.db-journal
          540  +  forcedelete test.db test.db-journal
   541    541     sqlite3 db test.db
   542    542     db eval {
   543    543       PRAGMA encoding=UTF16;
   544    544       CREATE TABLE t1(a);
   545    545       PRAGMA encoding=UTF8;
   546    546       CREATE TABLE t2(b);
   547    547     }

Changes to test/enc3.test.

    77     77     } {1}
    78     78   }
    79     79   
    80     80   # Try to attach a database with a different encoding.
    81     81   #
    82     82   ifcapable {utf16 && shared_cache} {
    83     83     db close
    84         -  file delete -force test8.db test8.db-journal
           84  +  forcedelete test8.db test8.db-journal
    85     85     set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
    86     86     sqlite3 dbaux test8.db
    87     87     sqlite3 db test.db
    88     88     db eval {SELECT 1 FROM sqlite_master LIMIT 1}
    89     89     do_test enc3-3.1 {
    90     90       dbaux eval {
    91     91         PRAGMA encoding='utf8';
................................................................................
    96     96     do_test enc3-3.2 {
    97     97       catchsql {
    98     98         ATTACH 'test.db' AS utf16;
    99     99         SELECT 1 FROM utf16.sqlite_master LIMIT 1;
   100    100       } dbaux
   101    101     } {1 {attached databases must use the same text encoding as main database}}
   102    102     dbaux close
   103         -  file delete -force test8.db test8.db-journal
          103  +  forcedelete test8.db test8.db-journal
   104    104     sqlite3_enable_shared_cache $::enable_shared_cache
   105    105   }
   106    106   
   107    107   finish_test

Changes to test/enc4.test.

    39     39   "100000000000000000000000000000000000000000000000000000000"\
    40     40   "1.0000000000000000000000000000000000000000000000000000000"\
    41     41   ]
    42     42   
    43     43   set i 1
    44     44   foreach enc $encodings {
    45     45   
    46         -  file delete -force test.db
           46  +  forcedelete test.db
    47     47     sqlite3 db test.db
    48     48     db eval "PRAGMA encoding = \"$enc\""
    49     49   
    50     50     do_test enc4-$i.1 {
    51     51       db eval {PRAGMA encoding}
    52     52     } $enc
    53     53   
................................................................................
    89     89       incr j
    90     90     }
    91     91   
    92     92     db close
    93     93     incr i
    94     94   }
    95     95   
    96         -file delete -force test.db
           96  +forcedelete test.db
    97     97   sqlite3 db test.db
    98     98   
    99     99   do_test enc4-4.1 {
   100    100     db eval "select 1+1."
   101    101   } {2.0}
   102    102   
   103    103   do_test enc4-4.2.1 {

Changes to test/exclusive.test.

    18     18   source $testdir/tester.tcl
    19     19   
    20     20   ifcapable {!pager_pragmas} {
    21     21     finish_test
    22     22     return
    23     23   }
    24     24   
    25         -file delete -force test2.db-journal
    26         -file delete -force test2.db
    27         -file delete -force test3.db-journal
    28         -file delete -force test3.db
    29         -file delete -force test4.db-journal
    30         -file delete -force test4.db
           25  +forcedelete test2.db-journal
           26  +forcedelete test2.db
           27  +forcedelete test3.db-journal
           28  +forcedelete test3.db
           29  +forcedelete test4.db-journal
           30  +forcedelete test4.db
    31     31   
    32     32   #----------------------------------------------------------------------
    33     33   # Test cases exclusive-1.X test the PRAGMA logic.
    34     34   #
    35     35   do_test exclusive-1.0 {
    36     36     execsql {
    37     37       pragma locking_mode;
................................................................................
   477    477     BEGIN;
   478    478       INSERT INTO t4 VALUES('Macmillan', 1957);
   479    479       INSERT INTO t4 VALUES('Douglas-Home', 1963);
   480    480       INSERT INTO t4 VALUES('Wilson', 1964);
   481    481   }
   482    482   do_test exclusive-6.2 {
   483    483     forcedelete test2.db test2.db-journal
   484         -  file copy test.db test2.db
   485         -  file copy test.db-journal test2.db-journal
          484  +  copy_file test.db test2.db
          485  +  copy_file test.db-journal test2.db-journal
   486    486     sqlite3 db test2.db
   487    487   } {}
   488    488   
   489    489   do_execsql_test exclusive-6.3 {
   490    490     PRAGMA locking_mode = EXCLUSIVE;
   491    491     SELECT * FROM t4;
   492    492   } {exclusive Eden 1955}

Changes to test/exclusive2.test.

   255    255   # is only incremented by the first change when in exclusive access
   256    256   # mode. In normal mode, the change-counter is incremented once
   257    257   # per write-transaction.
   258    258   #
   259    259   
   260    260   db close
   261    261   catch {close $::fd}
   262         -file delete -force test.db
   263         -file delete -force test.db-journal
          262  +forcedelete test.db
          263  +forcedelete test.db-journal
   264    264   
   265    265   do_test exclusive2-3.0 {
   266    266     sqlite3 db test.db
   267    267     execsql {
   268    268       BEGIN;
   269    269       CREATE TABLE t1(a UNIQUE);
   270    270       INSERT INTO t1 VALUES(randstr(200, 200));

Changes to test/fallocate.test.

    75     75   set skipwaltests [expr {
    76     76     [permutation]=="journaltest" || [permutation]=="inmemory_journal"
    77     77   }]
    78     78   ifcapable !wal { set skipwaltests 1 }
    79     79   
    80     80   if {!$skipwaltests} {
    81     81     db close
    82         -  file delete -force test.db
           82  +  forcedelete test.db
    83     83     sqlite3 db test.db
    84     84     file_control_chunksize_test db main [expr 32*1024]
    85     85     
    86     86     do_test fallocate-2.1 {
    87     87       execsql {
    88     88         PRAGMA page_size = 1024;
    89     89         PRAGMA journal_mode = WAL;

Changes to test/filectrl.test.

    33     33   } {}
    34     34   do_test filectrl-1.5 {
    35     35     db close
    36     36     sqlite3 db test_control_lockproxy.db
    37     37     file_control_lockproxy_test db [pwd]
    38     38   } {}
    39     39   db close
    40         -file delete -force .test_control_lockproxy.db-conch test.proxy
           40  +forcedelete .test_control_lockproxy.db-conch test.proxy
    41     41   finish_test

Changes to test/filefmt.test.

    19     19   
    20     20   # Do not use a codec for tests in this file, as the database file is
    21     21   # manipulated directly using tcl scripts (using the [hexio_write] command).
    22     22   #
    23     23   do_not_use_codec
    24     24   
    25     25   db close
    26         -file delete -force test.db test.db-journal
           26  +forcedelete test.db test.db-journal
    27     27   
    28     28   # Database begins with valid 16-byte header string.
    29     29   #
    30     30   do_test filefmt-1.1 {
    31     31     sqlite3 db test.db
    32     32     db eval {CREATE TABLE t1(x)}
    33     33     db close
................................................................................
    59     59   #
    60     60   ifcapable pager_pragmas {
    61     61     foreach pagesize {512 1024 2048 4096 8192 16384 32768} {
    62     62        if {[info exists SQLITE_MAX_PAGE_SIZE]
    63     63             && $pagesize>$SQLITE_MAX_PAGE_SIZE} continue
    64     64        do_test filefmt-1.5.$pagesize.1 {
    65     65          db close
    66         -       file delete -force test.db
           66  +       forcedelete test.db
    67     67          sqlite3 db test.db
    68     68          db eval "PRAGMA auto_vacuum=OFF"
    69     69          db eval "PRAGMA page_size=$pagesize"
    70     70          db eval {CREATE TABLE t1(x)}
    71     71          file size test.db
    72     72        } [expr $pagesize*2]
    73     73        do_test filefmt-1.5.$pagesize.2 {
................................................................................
   101    101   
   102    102   # Usable space per page (page-size minus unused space per page)
   103    103   # must be at least 480 bytes
   104    104   #
   105    105   ifcapable pager_pragmas {
   106    106     do_test filefmt-1.8 {
   107    107       db close
   108         -    file delete -force test.db
          108  +    forcedelete test.db
   109    109       sqlite3 db test.db
   110    110       db eval {PRAGMA page_size=512; CREATE TABLE t1(x)}
   111    111       db close
   112    112       hexio_write test.db 20 21
   113    113       sqlite3 db test.db
   114    114       catchsql {
   115    115          SELECT count(*) FROM sqlite_master
................................................................................
   121    121   # The following block of tests - filefmt-2.* - test that versions 3.7.0
   122    122   # and later can read and write databases that have been modified or created
   123    123   # by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores
   124    124   # the size of the database in the database file header, whereas 3.6.23.1
   125    125   # always derives this from the size of the file.
   126    126   #
   127    127   db close
   128         -file delete -force test.db
          128  +forcedelete test.db
   129    129   
   130    130   set a_string_counter 1
   131    131   proc a_string {n} {
   132    132     incr ::a_string_counter
   133    133     string range [string repeat "${::a_string_counter}." $n] 1 $n
   134    134   }
   135    135   sqlite3 db test.db
................................................................................
   153    153   } {}
   154    154   
   155    155   do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {}
   156    156   integrity_check filefmt-2.1.5
   157    157   do_test         filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010}
   158    158   
   159    159   db close
   160         -file delete -force test.db
          160  +forcedelete test.db
   161    161   sqlite3 db test.db
   162    162   db func a_string a_string
   163    163   
   164    164   do_execsql_test filefmt-2.2.1 {
   165    165     PRAGMA page_size = 1024;
   166    166     PRAGMA auto_vacuum = 0;
   167    167     CREATE TABLE t1(a);

Changes to test/fts1j.test.

    15     15   # If SQLITE_ENABLE_FTS1 is defined, omit this file.
    16     16   ifcapable !fts1 {
    17     17     finish_test
    18     18     return
    19     19   }
    20     20   
    21     21   # Clean up anything left over from a previous pass.
    22         -file delete -force test2.db
    23         -file delete -force test2.db-journal
           22  +forcedelete test2.db
           23  +forcedelete test2.db-journal
    24     24   sqlite3 db2 test2.db
    25     25   
    26     26   db eval {
    27     27     CREATE VIRTUAL TABLE t3 USING fts1(content);
    28     28     INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
    29     29   }
    30     30   
................................................................................
    80     80   
    81     81       DETACH DATABASE two;
    82     82     } db2
    83     83   } {2}
    84     84   catch {db eval {DETACH DATABASE two}}
    85     85   
    86     86   catch {db2 close}
    87         -file delete -force test2.db
           87  +forcedelete test2.db
    88     88   
    89     89   finish_test

Changes to test/fts1o.test.

    91     91     execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }
    92     92   } {{one three four} {one four} {one four two}}
    93     93   
    94     94   #---------------------------------------------------------------------
    95     95   # Test that it is possible to rename an fts1 table in an attached 
    96     96   # database.
    97     97   #
    98         -file delete -force test2.db test2.db-journal
           98  +forcedelete test2.db test2.db-journal
    99     99   
   100    100   do_test fts1o-4.1 {
   101    101     execsql {
   102    102       DROP TABLE t1_term;
   103    103       ALTER TABLE fts_t1 RENAME to t1;
   104    104       SELECT a, b, c FROM t1 WHERE c MATCH 'two';
   105    105     }

Changes to test/fts2j.test.

    15     15   # If SQLITE_ENABLE_FTS2 is defined, omit this file.
    16     16   ifcapable !fts2 {
    17     17     finish_test
    18     18     return
    19     19   }
    20     20   
    21     21   # Clean up anything left over from a previous pass.
    22         -file delete -force test2.db
    23         -file delete -force test2.db-journal
           22  +forcedelete test2.db
           23  +forcedelete test2.db-journal
    24     24   sqlite3 db2 test2.db
    25     25   
    26     26   db eval {
    27     27     CREATE VIRTUAL TABLE t3 USING fts2(content);
    28     28     INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
    29     29   }
    30     30   
................................................................................
    80     80   
    81     81       DETACH DATABASE two;
    82     82     } db2
    83     83   } {2}
    84     84   catch {db eval {DETACH DATABASE two}}
    85     85   
    86     86   catch {db2 close}
    87         -file delete -force test2.db
           87  +forcedelete test2.db
    88     88   
    89     89   finish_test

Changes to test/fts2o.test.

   105    105   } {{one three four} {one four} {one four two}}
   106    106   
   107    107   #-------------------------------------------------------------------
   108    108   # Close, delete and reopen the database. The following test should 
   109    109   # be run on an initially empty db.
   110    110   #
   111    111   db close
   112         -file delete -force test.db test.db-journal
          112  +forcedelete test.db test.db-journal
   113    113   sqlite3 db test.db
   114    114   
   115    115   do_test fts2o-3.1 {
   116    116     execsql {
   117    117       CREATE VIRTUAL TABLE t1 USING fts2(a, b, c);
   118    118       INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');
   119    119       SELECT a, b, c FROM t1 WHERE c MATCH 'two';
................................................................................
   130    130     }
   131    131   } {{one three four} {one four} {one two} {one three four} {one four} {one two}}
   132    132   
   133    133   #---------------------------------------------------------------------
   134    134   # Test that it is possible to rename an fts2 table in an attached 
   135    135   # database.
   136    136   #
   137         -file delete -force test2.db test2.db-journal
          137  +forcedelete test2.db test2.db-journal
   138    138   
   139    139   do_test fts2o-3.1 {
   140    140     execsql {
   141    141       ATTACH 'test2.db' AS aux;
   142    142       CREATE VIRTUAL TABLE aux.t1 USING fts2(a, b, c);
   143    143       INSERT INTO aux.t1(a, b, c) VALUES(
   144    144         'neung song sahm', 'neung see', 'neung see song'

Changes to test/fts3aj.test.

    15     15   # If SQLITE_ENABLE_FTS3 is defined, omit this file.
    16     16   ifcapable !fts3 {
    17     17     finish_test
    18     18     return
    19     19   }
    20     20   
    21     21   # Clean up anything left over from a previous pass.
    22         -file delete -force test2.db
    23         -file delete -force test2.db-journal
           22  +forcedelete test2.db
           23  +forcedelete test2.db-journal
    24     24   sqlite3 db2 test2.db
    25     25   
    26     26   db eval {
    27     27     CREATE VIRTUAL TABLE t3 USING fts3(content);
    28     28     INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
    29     29   }
    30     30   
................................................................................
    80     80   
    81     81       DETACH DATABASE two;
    82     82     } db2
    83     83   } {2}
    84     84   catch {db eval {DETACH DATABASE two}}
    85     85   
    86     86   catch {db2 close}
    87         -file delete -force test2.db
           87  +forcedelete test2.db
    88     88   
    89     89   finish_test

Changes to test/fts3ao.test.

   107    107   } {{one three four} {one four} {one four two}}
   108    108   
   109    109   #-------------------------------------------------------------------
   110    110   # Close, delete and reopen the database. The following test should 
   111    111   # be run on an initially empty db.
   112    112   #
   113    113   db close
   114         -file delete -force test.db test.db-journal
          114  +forcedelete test.db test.db-journal
   115    115   sqlite3 db test.db
   116    116   
   117    117   do_test fts3ao-3.1 {
   118    118     execsql {
   119    119       CREATE VIRTUAL TABLE t1 USING fts3(a, b, c);
   120    120       INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');
   121    121       SELECT a, b, c FROM t1 WHERE c MATCH 'two';
................................................................................
   132    132     }
   133    133   } {{one three four} {one four} {one two} {one three four} {one four} {one two}}
   134    134   
   135    135   #---------------------------------------------------------------------
   136    136   # Test that it is possible to rename an fts3 table in an attached 
   137    137   # database.
   138    138   #
   139         -file delete -force test2.db test2.db-journal
          139  +forcedelete test2.db test2.db-journal
   140    140   
   141    141   do_test fts3ao-3.1 {
   142    142     execsql {
   143    143       ATTACH 'test2.db' AS aux;
   144    144       CREATE VIRTUAL TABLE aux.t1 USING fts3(a, b, c);
   145    145       INSERT INTO aux.t1(a, b, c) VALUES(
   146    146         'neung song sahm', 'neung see', 'neung see song'

Changes to test/fts3snippet.test.

   127    127   foreach {DO_MALLOC_TEST enc} {
   128    128     0 utf8
   129    129     1 utf8
   130    130     1 utf16
   131    131   } {
   132    132   
   133    133     db close
   134         -  file delete -force test.db
          134  +  forcedelete test.db
   135    135     sqlite3 db test.db
   136    136     sqlite3_db_config_lookaside db 0 0 0
   137    137     db eval "PRAGMA encoding = \"$enc\""
   138    138   
   139    139     # Set variable $T to the test name prefix for this iteration of the loop.
   140    140     #
   141    141     set T "fts3snippet-$enc"

Changes to test/fts4aa.test.

  1682   1682     } $r
  1683   1683   }
  1684   1684   
  1685   1685   # Should get the same search results when the page size is very large
  1686   1686   #
  1687   1687   do_test fts4aa-3.0 {
  1688   1688     db close
  1689         -  file delete -force test.db
         1689  +  forcedelete test.db
  1690   1690     sqlite3 db test.db
  1691   1691     db eval {
  1692   1692       PRAGMA page_size=65536;
  1693   1693       CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
  1694   1694     }
  1695   1695     fts4aa_fill_table
  1696   1696   } {}

Changes to test/fuzz_malloc.test.

    43     43   proc do_fuzzy_malloc_test {testname args} {
    44     44     set ::fuzzyopts(-repeats) $::REPEATS
    45     45     set ::fuzzyopts(-sqlprep) {}
    46     46     array set ::fuzzyopts $args
    47     47   
    48     48     sqlite3_memdebug_fail -1
    49     49     db close
    50         -  file delete test.db test.db-journal
           50  +  delete_file test.db test.db-journal
    51     51     sqlite3 db test.db
    52     52     set ::prep $::fuzzyopts(-sqlprep)
    53     53     execsql $::prep
    54     54     set jj 0
    55     55     for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {
    56     56       expr srand($jj)
    57     57       incr jj

Changes to test/hook.test.

    91     91     }
    92     92     set ::commit_cnt
    93     93   } {}
    94     94   
    95     95   # Ticket #3564.
    96     96   #
    97     97   do_test hook-3.10 {
    98         -  file delete -force test2.db test2.db-journal
           98  +  forcedelete test2.db test2.db-journal
    99     99     sqlite3 db2 test2.db
   100    100     proc commit_hook {} {
   101    101       set y [db2 one {SELECT y FROM t3 WHERE y>10}]
   102    102       return [expr {$y>10}]
   103    103     }
   104    104     db2 eval {CREATE TABLE t3(x,y)}
   105    105     db2 commit_hook commit_hook
................................................................................
   213    213     }
   214    214   }
   215    215   
   216    216   # Update-hook + ATTACH
   217    217   set ::update_hook {}
   218    218   ifcapable attach {
   219    219     do_test hook-4.2.3 {
   220         -    file delete -force test2.db
          220  +    forcedelete test2.db
   221    221       execsql {
   222    222         ATTACH 'test2.db' AS aux;
   223    223         CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b);
   224    224         INSERT INTO aux.t3 SELECT * FROM t1;
   225    225         UPDATE t3 SET b = 'two or so' WHERE a = 2;
   226    226         DELETE FROM t3 WHERE 1; -- Avoid the truncate optimization (for now)
   227    227       }

Changes to test/incrblob.test.

   116    116     if {$AutoVacuumMode>0} {
   117    117       ifcapable !autovacuum {
   118    118         break
   119    119       }
   120    120     }
   121    121   
   122    122     db close
   123         -  file delete -force test.db test.db-journal
          123  +  forcedelete test.db test.db-journal
   124    124   
   125    125     sqlite3 db test.db
   126    126     execsql "PRAGMA auto_vacuum = $AutoVacuumMode"
   127    127   
   128    128     do_test incrblob-2.$AutoVacuumMode.1 {
   129    129       set ::str [string repeat abcdefghij 2900]
   130    130       execsql {
................................................................................
   375    375   #------------------------------------------------------------------------
   376    376   # incrblob-5.*: 
   377    377   #
   378    378   #     Test that opening a blob in an attached database works.
   379    379   #
   380    380   ifcapable attach {
   381    381     do_test incrblob-5.1 {
   382         -    file delete -force test2.db test2.db-journal
          382  +    forcedelete test2.db test2.db-journal
   383    383       set ::size [expr [file size [info script]]]
   384    384       execsql {
   385    385         ATTACH 'test2.db' AS aux;
   386    386         CREATE TABLE aux.files(name, text);
   387    387         INSERT INTO aux.files VALUES('this one', zeroblob($::size));
   388    388       }
   389    389       set fd  [db incrblob aux files text 1]
................................................................................
   580    580   
   581    581   set fd [open [info script]]
   582    582   fconfigure $fd -translation binary
   583    583   set ::data [read $fd 14000]
   584    584   close $fd
   585    585   
   586    586   db close
   587         -file delete -force test.db test.db-journal
          587  +forcedelete test.db test.db-journal
   588    588   sqlite3 db test.db
   589    589   
   590    590   do_test incrblob-7.2.1 {
   591    591     execsql {
   592    592       PRAGMA auto_vacuum = "incremental";
   593    593       CREATE TABLE t1(a INTEGER PRIMARY KEY, b);        -- root@page3
   594    594       INSERT INTO t1 VALUES(123, $::data);

Changes to test/incrvacuum.test.

   327    327       }] $control
   328    328     }
   329    329   }
   330    330   
   331    331   set ::str1 [string repeat abcdefghij 130]
   332    332   set ::str2 [string repeat 1234567890 105]
   333    333   
   334         -file delete -force test1.db test1.db-journal test2.db test2.db-journal
          334  +forcedelete test1.db test1.db-journal test2.db test2.db-journal
   335    335   sqlite3 db1 test1.db
   336    336   sqlite3 db2 test2.db
   337    337   execsql { PRAGMA auto_vacuum = 'none' } db1
   338    338   execsql { PRAGMA auto_vacuum = 'incremental' } db2
   339    339   
   340    340   set tn 1
   341    341   foreach sql $::TestScriptList {
................................................................................
   471    471   } {}
   472    472   
   473    473   #---------------------------------------------------------------------
   474    474   # At one point this test case was causing an assert() to fail.
   475    475   #
   476    476   do_test incrvacuum-9.1 {
   477    477     db close
   478         -  file delete -force test.db test.db-journal
          478  +  forcedelete test.db test.db-journal
   479    479     sqlite3 db test.db
   480    480   
   481    481     execsql {
   482    482       PRAGMA auto_vacuum = 'incremental';
   483    483       CREATE TABLE t1(a, b, c);
   484    484       CREATE TABLE t2(a, b, c);
   485    485       INSERT INTO t2 VALUES(randstr(500,500),randstr(500,500),randstr(500,500));
................................................................................
   589    589   
   590    590   #----------------------------------------------------------------
   591    591   # Test that if we set the auto_vacuum mode to 'incremental', then
   592    592   # create a database, thereafter that database defaults to incremental 
   593    593   # vacuum mode.
   594    594   #
   595    595   db close
   596         -file delete -force test.db test.db-journal
          596  +forcedelete test.db test.db-journal
   597    597   sqlite3 db test.db
   598    598   
   599    599   ifcapable default_autovacuum {
   600    600     do_test incrvacuum-11.1-av-dflt-on {
   601    601       execsql {
   602    602         PRAGMA auto_vacuum;
   603    603       }
................................................................................
   647    647   } {1}
   648    648   
   649    649   #----------------------------------------------------------------------
   650    650   # Special case: What happens if the database is locked when a "PRAGMA
   651    651   # auto_vacuum = XXX" statement is executed.
   652    652   #
   653    653   db close
   654         -file delete -force test.db test.db-journal
          654  +forcedelete test.db test.db-journal
   655    655   sqlite3 db test.db
   656    656   
   657    657   do_test incrvacuum-12.1 {
   658    658     execsql {
   659    659       PRAGMA auto_vacuum = 1;
   660    660     }
   661    661     expr {[file size test.db]>0}
................................................................................
   688    688   #----------------------------------------------------------------------
   689    689   # Special case #2: What if one process prepares a "PRAGMA auto_vacuum = XXX"
   690    690   # statement when the database is empty, but doesn't execute it until
   691    691   # after some other process has created the database.
   692    692   #
   693    693   db2 close
   694    694   db close
   695         -file delete -force test.db test.db-journal
          695  +forcedelete test.db test.db-journal
   696    696   sqlite3 db test.db  ;  set ::DB [sqlite3_connection_pointer db]
   697    697   sqlite3 db2 test.db
   698    698   
   699    699   do_test incrvacuum-13.1 {
   700    700     # File size is sometimes 1 instead of 0 due to the hack we put in
   701    701     # to work around ticket #3260.  Search for comments on #3260 in
   702    702     # os_unix.c.
................................................................................
   739    739     } {1 {file is encrypted or is not a database}}
   740    740     db3 close
   741    741   }
   742    742   
   743    743   do_test incrvacuum-15.1 {
   744    744     db close
   745    745     db2 close
   746         -  file delete -force test.db
          746  +  forcedelete test.db
   747    747     sqlite3 db test.db
   748    748   
   749    749     set str [string repeat "abcdefghij" 500]
   750    750   
   751    751     execsql {
   752    752       PRAGMA cache_size = 10;
   753    753       PRAGMA auto_vacuum = incremental;

Changes to test/incrvacuum2.test.

    66     66     file size test.db
    67     67   } {3072}
    68     68   
    69     69   # Make sure incremental vacuum works on attached databases.
    70     70   #
    71     71   ifcapable attach {
    72     72     do_test incrvacuum2-2.1 {
    73         -    file delete -force test2.db test2.db-journal
           73  +    forcedelete test2.db test2.db-journal
    74     74       execsql {
    75     75         ATTACH DATABASE 'test2.db' AS aux;
    76     76         PRAGMA aux.auto_vacuum=incremental;
    77     77         CREATE TABLE aux.t2(x);
    78     78         INSERT INTO t2 VALUES(zeroblob(30000));
    79     79         INSERT INTO t1 SELECT * FROM t2;
    80     80         DELETE FROM t2;

Changes to test/incrvacuum_ioerr.test.

   104    104     db close
   105    105   }
   106    106   
   107    107   
   108    108   ifcapable shared_cache {
   109    109   
   110    110     catch { db close }
   111         -  file delete -force test.db
          111  +  forcedelete test.db
   112    112     set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
   113    113     
   114    114     # Create two connections to a single shared-cache:
   115    115     #
   116    116     sqlite3 db1 test.db
   117    117     sqlite3 db2 test.db
   118    118     

Changes to test/insert5.test.

    30     30   proc uses_temp_table {sql} {
    31     31     return [expr {[lsearch [execsql "EXPLAIN $sql"] OpenEphemeral]>=0}]
    32     32   }
    33     33   
    34     34   # Construct the sample database.
    35     35   #
    36     36   do_test insert5-1.0 {
    37         -  file delete -force test2.db test2.db-journal
           37  +  forcedelete test2.db test2.db-journal
    38     38     execsql {
    39     39       CREATE TABLE MAIN(Id INTEGER, Id1 INTEGER); 
    40     40       CREATE TABLE B(Id INTEGER, Id1 INTEGER); 
    41     41       CREATE VIEW v1 AS SELECT * FROM B;
    42     42       CREATE VIEW v2 AS SELECT * FROM MAIN;
    43     43       INSERT INTO MAIN(Id,Id1) VALUES(2,3); 
    44     44       INSERT INTO B(Id,Id1) VALUES(2,3); 

Changes to test/io.test.

   221    221     file mkdir test.db-journal
   222    222     catchsql {
   223    223       INSERT INTO abc VALUES(9, randstr(1000,1000));
   224    224       COMMIT
   225    225     }
   226    226   } {1 {unable to open database file}}
   227    227   do_test io-2.6.3 {
   228         -  file delete -force test.db-journal
          228  +  forcedelete test.db-journal
   229    229     catchsql { COMMIT }
   230    230   } {0 {}}
   231    231   do_test io-2.6.4 {
   232    232     execsql { SELECT * FROM abc }
   233    233   } {1 2 3 4 5 6 7 8}
   234    234   
   235    235   # Test that if the database modification is part of multi-file commit,
   236    236   # the journal file is always created. In this case, the journal file
   237    237   # is created during execution of the COMMIT statement, so we have to
   238    238   # use the same technique to check that it is created as in the above 
   239    239   # block.
   240         -file delete -force test2.db test2.db-journal
          240  +forcedelete test2.db test2.db-journal
   241    241   ifcapable attach {
   242    242     do_test io-2.7.1 {
   243    243       execsql {
   244    244         ATTACH 'test2.db' AS aux;
   245    245         PRAGMA aux.page_size = 1024;
   246    246         CREATE TABLE aux.abc2(a, b);
   247    247         BEGIN;
................................................................................
   257    257       execsql { SELECT * FROM abc UNION ALL SELECT * FROM abc2 }
   258    258     } {1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10}
   259    259     do_test io-2.7.4 {
   260    260       file mkdir test2.db-journal
   261    261       catchsql { COMMIT }
   262    262     } {1 {unable to open database file}}
   263    263     do_test io-2.7.5 {
   264         -    file delete -force test2.db-journal
          264  +    forcedelete test2.db-journal
   265    265       catchsql { COMMIT }
   266    266     } {1 {cannot commit - no transaction is active}}
   267    267     do_test io-2.7.6 {
   268    268       execsql { SELECT * FROM abc UNION ALL SELECT * FROM abc2 }
   269    269     } {1 2 3 4 5 6 7 8}
   270    270   }
   271    271   
................................................................................
   300    300       INSERT INTO abc VALUES(9, 10);
   301    301     }
   302    302     file exists test.db-journal
   303    303   } {1}
   304    304   do_test io-2.9.2 {
   305    305     execsql { ROLLBACK; }
   306    306     db close
   307         -  file delete -force test.db test.db-journal
          307  +  forcedelete test.db test.db-journal
   308    308     sqlite3 db test.db -vfs devsym
   309    309     execsql {
   310    310       PRAGMA auto_vacuum = OFF;
   311    311       PRAGMA page_size = 2048;
   312    312       CREATE TABLE abc(a, b);
   313    313     }
   314    314     execsql {
................................................................................
   371    371   #----------------------------------------------------------------------
   372    372   # Test cases io-3.* test the IOCAP_SEQUENTIAL optimization.
   373    373   #
   374    374   sqlite3_simulate_device -char sequential -sectorsize 0
   375    375   ifcapable pager_pragmas {
   376    376     do_test io-3.1 {
   377    377       db close
   378         -    file delete -force test.db test.db-journal
          378  +    forcedelete test.db test.db-journal
   379    379       sqlite3 db test.db -vfs devsym
   380    380       db eval {
   381    381         PRAGMA auto_vacuum=OFF;
   382    382       }
   383    383       # File size might be 1 due to the hack to work around ticket #3260.
   384    384       # Search for #3260 in os_unix.c for additional information.
   385    385       expr {[file size test.db]>1}
................................................................................
   540    540            {atomic2K}            4096      4096
   541    541            {atomic2K atomic}      512      8192
   542    542            {atomic64K}            512      1024
   543    543   } {
   544    544     incr tn
   545    545     if {$pgsize>$::SQLITE_MAX_PAGE_SIZE} continue
   546    546     db close
   547         -  file delete -force test.db test.db-journal
          547  +  forcedelete test.db test.db-journal
   548    548     sqlite3_simulate_device -char $char -sectorsize $sectorsize
   549    549     sqlite3 db test.db -vfs devsym
   550    550     db eval {
   551    551       PRAGMA auto_vacuum=OFF;
   552    552     }
   553    553     ifcapable !atomicwrite {
   554    554       if {[regexp {^atomic} $char]} continue

Changes to test/ioerr.test.

   179    179       db2 eval {
   180    180         PRAGMA synchronous = 0;
   181    181         CREATE TABLE t1(a, b);
   182    182         INSERT INTO t1 VALUES(1, 2);
   183    183         BEGIN;
   184    184         INSERT INTO t1 VALUES(3, 4);
   185    185       }
   186         -    copy_file test2.db test.db
   187         -    copy_file test2.db-journal test.db-journal
          186  +    forcecopy test2.db test.db
          187  +    forcecopy test2.db-journal test.db-journal
   188    188       db2 close
   189    189     } -tclbody {
   190    190       sqlite3 db test.db
   191    191       db eval {
   192    192         SELECT * FROM t1;
   193    193       }
   194    194     } -exclude 1
................................................................................
   215    215     do_ioerr_test ioerr-9 -ckrefcount true -tclprep {
   216    216       execsql {
   217    217         CREATE TABLE t1(a,b,c);
   218    218         INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
   219    219         BEGIN;
   220    220         INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
   221    221       }
   222         -    copy_file test.db-journal test2.db-journal
          222  +    forcecopy test.db-journal test2.db-journal
   223    223       execsql {
   224    224         COMMIT;
   225    225       }
   226         -    copy_file test2.db-journal test.db-journal
          226  +    forcecopy test2.db-journal test.db-journal
   227    227       set f [open test.db-journal a]
   228    228       fconfigure $f -encoding binary
   229    229       puts -nonewline $f "hello"
   230    230       puts -nonewline $f "\x00\x00\x00\x05\x01\x02\x03\x04"
   231    231       puts -nonewline $f "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
   232    232       close $f
   233    233     } -sqlbody {

Changes to test/ioerr4.test.

    27     27   # Enable shared cache mode and incremental vacuum.
    28     28   #
    29     29   do_test ioerr4-1.1 {
    30     30     db close
    31     31     set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
    32     32   } {0}
    33     33   do_test ioerr4-1.2 {
    34         -  file delete -force test.db test.db-journal
           34  +  forcedelete test.db test.db-journal
    35     35     sqlite3 db test.db
    36     36     sqlite3 db2 test.db
    37     37     db eval {
    38     38       PRAGMA auto_vacuum=INCREMENTAL;
    39     39       CREATE TABLE a(i INTEGER, b BLOB);
    40     40     }
    41     41     db2 eval {
................................................................................
    75     75   } {64}
    76     76   
    77     77   # Set up for an I/O error on incremental vacuum
    78     78   # with two connections on shared cache.
    79     79   #
    80     80   db close
    81     81   db2 close
    82         -file copy -force test.db test.db-bu
           82  +forcecopy test.db test.db-bu
    83     83   do_ioerr_test ioerr4-2 -tclprep {
    84     84     catch {db2 close}
    85     85     db close
    86         -  file delete -force test.db test.db-journal
    87         -  file copy -force test.db-bu test.db
           86  +  forcedelete test.db test.db-journal
           87  +  forcecopy test.db-bu test.db
    88     88     sqlite3_enable_shared_cache 1
    89     89     set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
    90     90     db eval {PRAGMA auto_vacuum=INCREMENTAL}
    91     91     sqlite3 db2 test.db
    92     92   } -tclbody {
    93     93     db eval {PRAGMA incremental_vacuum(5)}
    94     94   }
    95     95   
    96     96   db2 close
    97         -file delete -force test.db-bu
           97  +forcedelete test.db-bu
    98     98   sqlite3_enable_shared_cache $::enable_shared_cache
    99     99   
   100    100   finish_test

Changes to test/journal1.test.

    16     16   # $Id: journal1.test,v 1.2 2005/03/20 22:54:56 drh Exp $
    17     17   
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # These tests will not work on windows because windows uses
    23         -# manditory file locking which breaks the file copy command.
           23  +# manditory file locking which breaks the copy_file command.
    24     24   #
    25     25   if {$tcl_platform(platform)=="windows"} {
    26     26     finish_test
    27     27     return
    28     28   }
    29     29   
    30     30   # Create a smaple database
................................................................................
    47     47   # database.
    48     48   #
    49     49   do_test journal1-1.2 {
    50     50     execsql {
    51     51       BEGIN;
    52     52       DELETE FROM t1;
    53     53     }
    54         -  file copy -force test.db-journal test.db-journal-bu
           54  +  forcecopy test.db-journal test.db-journal-bu
    55     55     execsql {
    56     56       ROLLBACK;
    57     57     }
    58     58     db close
    59         -  file delete test.db
    60         -  file copy test.db-journal-bu test.db-journal
           59  +  delete_file test.db
           60  +  copy_file test.db-journal-bu test.db-journal
    61     61     sqlite3 db test.db
    62     62     catchsql {
    63     63       SELECT * FROM sqlite_master
    64     64     }
    65     65   } {0 {}}
    66     66   
    67     67   finish_test

Changes to test/journal2.test.

   163    163   do_test journal2-1.13 {
   164    164     tvfs filter {xOpen xClose xDelete xWrite xTruncate}
   165    165     set ::tvfs_error_on_write 1
   166    166     catchsql { COMMIT } db2
   167    167   } {1 {disk I/O error}}
   168    168   db2 close
   169    169   unset ::tvfs_error_on_write
   170         -file copy -force test.db testX.db
          170  +forcecopy test.db testX.db
   171    171   
   172    172   do_test journal2-1.14 { file exists test.db-journal } 1
   173    173   do_test journal2-1.15 {
   174    174     execsql {
   175    175       SELECT count(*) FROM t2;
   176    176       PRAGMA integrity_check;
   177    177     }

Changes to test/journal3.test.

    31     31      2 00666
    32     32      3 00600
    33     33      4 00755
    34     34     } {
    35     35       db close
    36     36       set effective [format %.5o [expr $permissions & ~$umask]]
    37     37       do_test journal3-1.2.$tn.1 {
    38         -      catch { file delete -force test.db-journal }
           38  +      catch { forcedelete test.db-journal }
    39     39         file attributes test.db -permissions $permissions
    40     40         file attributes test.db -permissions
    41     41       } $permissions
    42     42       do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}
    43     43       do_test journal3-1.2.$tn.3 {
    44     44         sqlite3 db test.db
    45     45         execsql { 

Changes to test/jrnlmode.test.

   196    196         DETACH aux2;
   197    197         DETACH aux3;
   198    198       }
   199    199     } {}
   200    200   }
   201    201   
   202    202   ifcapable attach {
   203         -  file delete -force test2.db
          203  +  forcedelete test2.db
   204    204     do_test jrnlmode-2.1 {
   205    205       execsql {
   206    206         ATTACH 'test2.db' AS aux;
   207    207         PRAGMA main.journal_mode = persist;
   208    208         PRAGMA aux.journal_mode = persist;
   209    209         CREATE TABLE abc(a, b, c);
   210    210         CREATE TABLE aux.def(d, e, f);
................................................................................
   238    238       }
   239    239     } {4 5 6}
   240    240   
   241    241   #----------------------------------------------------------------------
   242    242   # Test caes jrnlmode-3.X verify that ticket #3127 has been fixed.
   243    243   #
   244    244     db close
   245         -  file delete -force test2.db
   246         -  file delete -force test.db
          245  +  forcedelete test2.db
          246  +  forcedelete test.db
   247    247     sqlite3 db test.db
   248    248   
   249    249     do_test jrnlmode-3.1 {
   250    250       execsql { 
   251    251         CREATE TABLE x(n INTEGER); 
   252    252         ATTACH 'test2.db' AS a; 
   253    253         create table a.x ( n integer ); 
................................................................................
   266    266         COMMIT;
   267    267       }
   268    268     } {}
   269    269   }
   270    270   
   271    271   ifcapable autovacuum&&pragma {
   272    272     db close
   273         -  file delete -force test.db
          273  +  forcedelete test.db
   274    274     sqlite3 db test.db
   275    275     do_test jrnlmode-4.1 {
   276    276       execsql {
   277    277         PRAGMA cache_size = 1;
   278    278         PRAGMA auto_vacuum = 1;
   279    279         CREATE TABLE abc(a, b, c);
   280    280       }
................................................................................
   299    299   }
   300    300   
   301    301   #------------------------------------------------------------------------
   302    302   # The following test caes, jrnlmode-5.*, test the journal_size_limit
   303    303   # pragma.
   304    304   ifcapable pragma {
   305    305     db close
   306         -  file delete -force test.db test2.db test3.db
          306  +  forcedelete test.db test2.db test3.db
   307    307     sqlite3 db test.db
   308    308   
   309    309     do_test jrnlmode-5.1 {
   310    310       execsql {pragma page_size=1024}
   311    311       execsql {pragma journal_mode=persist}
   312    312     } {persist}
   313    313   
................................................................................
   507    507       } {0}
   508    508     }
   509    509   }
   510    510   
   511    511   ifcapable pragma {
   512    512     catch { db close }
   513    513     do_test jrnlmode-7.1 {
   514         -    foreach f [glob -nocomplain test.db*] { file delete -force $f }
          514  +    foreach f [glob -nocomplain test.db*] { forcedelete $f }
   515    515       sqlite3 db test.db
   516    516       execsql {
   517    517         PRAGMA journal_mode = memory;
   518    518         PRAGMA auto_vacuum = 0;
   519    519         PRAGMA page_size = 1024;
   520    520         PRAGMA user_version = 5;
   521    521         PRAGMA user_version;

Changes to test/jrnlmode2.test.

   108    108   do_test jrnlmode2-2.4 {
   109    109     sqlite3 db2 test.db -readonly 1
   110    110     catchsql { SELECT * FROM t1 } db2
   111    111   } {0 {1 2 3 4 5 6}}
   112    112   
   113    113   do_test jrnlmode2-2.5 {
   114    114     db close
   115         -  file delete test.db-journal
          115  +  delete_file test.db-journal
   116    116   } {}
   117    117   do_test jrnlmode2-2.6 {
   118    118     sqlite3 db2 test.db -readonly 1
   119    119     catchsql { SELECT * FROM t1 } db2
   120    120   } {0 {1 2 3 4 5 6}}
   121    121   
   122    122   catch { db2 close }
   123    123   finish_test

Changes to test/jrnlmode3.test.

    44     44       INSERT INTO t1 VALUES(2);
    45     45       ROLLBACK;
    46     46       SELECT * FROM t1;
    47     47     }
    48     48   } {1}
    49     49   
    50     50   db close
    51         -file delete -force test.db test.db-journal
           51  +forcedelete test.db test.db-journal
    52     52   sqlite3 db test.db
    53     53   
    54     54   do_test jrnlmode3-2.1 {
    55     55     db eval {
    56     56       PRAGMA locking_mode=EXCLUSIVE;
    57     57       PRAGMA journal_mode=OFF;
    58     58       CREATE TABLE t1(x);
................................................................................
    81     81       # Skip the no-change cases
    82     82       if {$fromjmode==$tojmode} continue
    83     83       incr cnt
    84     84   
    85     85       # Start with a fresh database connection an empty database file.
    86     86       #
    87     87       db close
    88         -    file delete -force test.db test.db-journal
           88  +    forcedelete test.db test.db-journal
    89     89       sqlite3 db test.db
    90     90   
    91     91       # Initialize the journal mode.
    92     92       #
    93     93       do_test jrnlmode3-3.$cnt.1-($fromjmode-to-$tojmode) {
    94     94         db eval "PRAGMA journal_mode = $fromjmode;"
    95     95       } $fromjmode

Changes to test/loadext.test.

   130    130   db2 close
   131    131   sqlite3 db test.db
   132    132   sqlite3_enable_load_extension db 1
   133    133   
   134    134   # Try to load an extension for which the file does not exist.
   135    135   #
   136    136   do_test loadext-2.1 {
   137         -  file delete -force ${testextension}xx
          137  +  forcedelete ${testextension}xx
   138    138     set rc [catch {
   139    139       sqlite3_load_extension db "${testextension}xx"
   140    140     } msg]
   141    141     list $rc $msg
   142    142   } [list 1 [format $dlerror_nosuchfile ${testextension}xx]]
   143    143   
   144    144   # Try to load an extension for which the file is not a shared object

Changes to test/lock4.test.

    22     22   # Initialize the test.db database so that it is non-empty
    23     23   #
    24     24   do_test lock4-1.1 {
    25     25     db eval {
    26     26        PRAGMA auto_vacuum=OFF;
    27     27        CREATE TABLE t1(x);
    28     28     }
    29         -  file delete -force test2.db test2.db-journal
           29  +  forcedelete test2.db test2.db-journal
    30     30     sqlite3 db2 test2.db
    31     31     db2 eval {
    32     32        PRAGMA auto_vacuum=OFF;
    33     33        CREATE TABLE t2(x)
    34     34     }
    35     35     db2 close
    36     36     list [file size test.db] [file size test2.db]

Changes to test/lock5.test.

    20     20   # SQLITE_ENABLE_LOCKING_STYLE macro.
    21     21   db close
    22     22   if {[catch {sqlite3 db test.db -vfs unix-none} msg]} {
    23     23     finish_test
    24     24     return
    25     25   }
    26     26   db close
    27         -file delete -force test.db.lock
           27  +forcedelete test.db.lock
    28     28   
    29     29   ifcapable lock_proxy_pragmas {
    30     30     set ::using_proxy 0
    31     31     foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
    32     32       set ::using_proxy $value
    33     33     }
    34     34     # Disable the proxy locking for these tests
................................................................................
    96     96     execsql {BEGIN EXCLUSIVE}
    97     97     db close
    98     98     file exists test.db.lock
    99     99   } {0}
   100    100   
   101    101   #####################################################################
   102    102   
   103         -file delete -force test.db
          103  +forcedelete test.db
   104    104   if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} {
   105    105     finish_test
   106    106     return
   107    107   }
   108    108   
   109    109   do_test lock5-flock.1 {
   110    110     sqlite3 db test.db -vfs unix-flock

Changes to test/main.test.

   297    297   
   298    298   
   299    299   # Try to open a database with a corrupt database file.
   300    300   #
   301    301   if {[permutation] == ""} {
   302    302     do_test main-2.0 {
   303    303       catch {db close}
   304         -    file delete -force test.db
          304  +    forcedelete test.db
   305    305       set fd [open test.db w]
   306    306       puts $fd hi!
   307    307       close $fd
   308    308       set v [catch {sqlite3 db test.db} msg]
   309    309       if {$v} {lappend v $msg} {lappend v {}}
   310    310     } {0 {}}
   311    311   }
   312    312   
   313    313   # Here are some tests for tokenize.c.  
   314    314   #
   315    315   do_test main-3.1 {
   316    316     catch {db close}
   317         -  foreach f [glob -nocomplain testdb/*] {file delete -force $f}
   318         -  file delete -force testdb
          317  +  foreach f [glob -nocomplain testdb/*] {forcedelete $f}
          318  +  forcedelete testdb
   319    319     sqlite3 db testdb
   320    320     set v [catch {execsql {SELECT * from T1 where x!!5}} msg]
   321    321     lappend v $msg
   322    322   } {1 {unrecognized token: "!!"}}
   323    323   do_test main-3.2 {
   324    324     catch {db close}
   325         -  foreach f [glob -nocomplain testdb/*] {file delete -force $f}
   326         -  file delete -force testdb
          325  +  foreach f [glob -nocomplain testdb/*] {forcedelete $f}
          326  +  forcedelete testdb
   327    327     sqlite3 db testdb
   328    328     set v [catch {execsql {SELECT * from T1 where ^x}} msg]
   329    329     lappend v $msg
   330    330   } {1 {unrecognized token: "^"}}
   331    331   do_test main-3.2.2 {
   332    332     catchsql {select 'abc}
   333    333   } {1 {unrecognized token: "'abc"}}
................................................................................
   438    438   do_test main-3.2.30 {
   439    439     catchsql {select 123--5}
   440    440   } {0 123}
   441    441   
   442    442   
   443    443   do_test main-3.3 {
   444    444     catch {db close}
   445         -  foreach f [glob -nocomplain testdb/*] {file delete -force $f}
   446         -  file delete -force testdb
          445  +  foreach f [glob -nocomplain testdb/*] {forcedelete $f}
          446  +  forcedelete testdb
   447    447     sqlite3 db testdb
   448    448     execsql {
   449    449       create table T1(X REAL);  /* C-style comments allowed */
   450    450       insert into T1 values(0.5);
   451    451       insert into T1 values(0.5e2);
   452    452       insert into T1 values(0.5e-002);
   453    453       insert into T1 values(5e-002);

Changes to test/malloc.test.

   266    266   }
   267    267   
   268    268   # This block tests malloc() failures that occur while opening a 
   269    269   # connection to a database.
   270    270   do_malloc_test 10 -tclprep {
   271    271     catch {db2 close}
   272    272     db close
   273         -  file delete -force test.db test.db-journal
          273  +  forcedelete test.db test.db-journal
   274    274     sqlite3 db test.db
   275    275     sqlite3_extended_result_codes db 1
   276    276     db eval {CREATE TABLE abc(a, b, c)}
   277    277   } -tclbody {
   278    278     db close
   279    279     sqlite3 db2 test.db
   280    280     sqlite3_extended_result_codes db2 1
................................................................................
   337    337         PRAGMA journal_mode = DELETE;    /* For inmemory_journal permutation */
   338    338         PRAGMA synchronous = 0;
   339    339         CREATE TABLE t1(a, b);
   340    340         INSERT INTO t1 VALUES(1, 2);
   341    341         BEGIN;
   342    342         INSERT INTO t1 VALUES(3, 4);
   343    343       }
   344         -    copy_file test2.db test.db
   345         -    copy_file test2.db-journal test.db-journal
          344  +    forcecopy test2.db test.db
          345  +    forcecopy test2.db-journal test.db-journal
   346    346       db2 close
   347    347     } -tclbody {
   348    348       sqlite3 db test.db
   349    349       sqlite3_extended_result_codes db 1
   350    350   
   351    351       # If an out-of-memory occurs within a call to a VFS layer function during
   352    352       # hot-journal rollback, sqlite will report SQLITE_CORRUPT. See commit
................................................................................
   495    495   
   496    496   # Make sure SQLITE_NOMEM is reported out on an ATTACH failure even
   497    497   # when the malloc failure occurs within the nested parse.
   498    498   #
   499    499   ifcapable attach {
   500    500     do_malloc_test 20 -tclprep {
   501    501       db close
   502         -    file delete -force test2.db test2.db-journal
          502  +    forcedelete test2.db test2.db-journal
   503    503       sqlite3 db test2.db
   504    504       sqlite3_extended_result_codes db 1
   505    505       db eval {CREATE TABLE t1(x);}
   506    506       db close
   507    507     } -tclbody {
   508    508       if {[catch {sqlite3 db test.db}]} {
   509    509         error "out of memory"

Changes to test/malloc3.test.

   459    459         SELECT * FROM v1 WHERE d = g;
   460    460       }
   461    461     } {a b c a b c 1 2 3 1 2 3}
   462    462   }
   463    463   
   464    464   # Test a simple multi-file transaction 
   465    465   #
   466         -file delete -force test2.db
          466  +forcedelete test2.db
   467    467   ifcapable attach {
   468    468     SQL {ATTACH 'test2.db' AS aux;}
   469    469     SQL {BEGIN}
   470    470     SQL {CREATE TABLE aux.tbl2(x, y, z)}
   471    471     SQL {INSERT INTO tbl2 VALUES(1, 2, 3)}
   472    472     SQL {INSERT INTO def VALUES(4, 5, 6)}
   473    473     TEST 30 {
................................................................................
   646    646   # run the tests with "persistent" malloc failures.
   647    647   sqlite3_extended_result_codes db 1
   648    648   db cache size 0
   649    649   run_test $::run_test_script 1
   650    650   
   651    651   # Close and reopen the db.
   652    652   db close
   653         -file delete -force test.db test.db-journal test2.db test2.db-journal
          653  +forcedelete test.db test.db-journal test2.db test2.db-journal
   654    654   sqlite3 db test.db
   655    655   sqlite3_extended_result_codes db 1
   656    656   set ::DB [sqlite3_connection_pointer db]
   657    657   
   658    658   # Turn off the Tcl interface's prepared statement caching facility in
   659    659   # the new connnection. Then run the tests with "transient" malloc failures.
   660    660   db cache size 0
   661    661   run_test $::run_test_script 0
   662    662   
   663    663   sqlite3_memdebug_fail -1
   664    664   finish_test

Changes to test/malloc5.test.

   271    271   #
   272    272   proc nPage {db} {
   273    273     set bt [btree_from_db $db]
   274    274     array set stats [btree_pager_stats $bt]
   275    275     set stats(page)
   276    276   }
   277    277   db close
   278         -file delete -force test.db test.db-journal test2.db test2.db-journal
          278  +forcedelete test.db test.db-journal test2.db test2.db-journal
   279    279   
   280    280   # This block of test-cases (malloc5-6.1.*) prepares two database files
   281    281   # for the subsequent tests.
   282    282   do_test malloc5-6.1.1 {
   283    283     sqlite3 db test.db
   284    284     execsql {
   285    285       PRAGMA page_size=1024;
................................................................................
   300    300           SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
   301    301       INSERT INTO abc 
   302    302           SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
   303    303       INSERT INTO abc 
   304    304           SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;
   305    305       COMMIT;
   306    306     } 
   307         -  copy_file test.db test2.db
          307  +  forcecopy test.db test2.db
   308    308     sqlite3 db2 test2.db
   309    309     list \
   310    310       [expr ([file size test.db]/1024)>20] [expr ([file size test2.db]/1024)>20]
   311    311   } {1 1}
   312    312   do_test malloc5-6.1.2 {
   313    313     list [execsql {PRAGMA cache_size}] [execsql {PRAGMA cache_size} db2]
   314    314   } {10 10}

Changes to test/mallocA.test.

    23     23      finish_test
    24     24      return
    25     25   }
    26     26   
    27     27   
    28     28   # Construct a test database
    29     29   #
    30         -file delete -force test.db.bu
           30  +forcedelete test.db.bu
    31     31   db eval {
    32     32     CREATE TABLE t1(a COLLATE NOCASE,b,c);
    33     33     INSERT INTO t1 VALUES(1,2,3);
    34     34     INSERT INTO t1 VALUES(1,2,4);
    35     35     INSERT INTO t1 VALUES(2,3,4);
    36     36     CREATE INDEX t1i1 ON t1(a);
    37     37     CREATE INDEX t1i2 ON t1(b,c);
    38     38     CREATE TABLE t2(x,y,z);
    39     39   }
    40     40   db close
    41         -file copy test.db test.db.bu
           41  +copy_file test.db test.db.bu
    42     42   
    43     43   
    44     44   do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody {
    45     45     ANALYZE
    46     46   }
    47     47   do_malloc_test mallocA-1.1 -testdb test.db.bu -sqlbody {
    48     48     ANALYZE t1
................................................................................
    70     70   
    71     71   # Ensure that no file descriptors were leaked.
    72     72   do_test malloc-99.X {
    73     73     catch {db close}
    74     74     set sqlite_open_file_count
    75     75   } {0}
    76     76   
    77         -file delete -force test.db.bu
           77  +forcedelete test.db.bu
    78     78   finish_test

Changes to test/malloc_common.tcl.

   404    404         # fails and then subsequent calls succeed. If $::iRepeat is 1, 
   405    405         # then the failure is persistent - once malloc() fails it keeps
   406    406         # failing.
   407    407         #
   408    408         set zRepeat "transient"
   409    409         if {$::iRepeat} {set zRepeat "persistent"}
   410    410         restore_prng_state
   411         -      foreach file [glob -nocomplain test.db-mj*] {file delete -force $file}
          411  +      foreach file [glob -nocomplain test.db-mj*] {forcedelete $file}
   412    412   
   413    413         do_test ${tn}.${zRepeat}.${::n} {
   414    414     
   415    415           # Remove all traces of database files test.db and test2.db 
   416    416           # from the file-system. Then open (empty database) "test.db" 
   417    417           # with the handle [db].
   418    418           # 
................................................................................
   421    421           forcedelete test.db
   422    422           forcedelete test.db-journal
   423    423           forcedelete test.db-wal
   424    424           forcedelete test2.db
   425    425           forcedelete test2.db-journal
   426    426           forcedelete test2.db-wal
   427    427           if {[info exists ::mallocopts(-testdb)]} {
   428         -          file copy $::mallocopts(-testdb) test.db
          428  +          copy_file $::mallocopts(-testdb) test.db
   429    429           }
   430    430           catch { sqlite3 db test.db }
   431    431           if {[info commands db] ne ""} {
   432    432             sqlite3_extended_result_codes db 1
   433    433           }
   434    434           sqlite3_db_config_lookaside db 0 0 0
   435    435     

Changes to test/manydb.test.

    40     40       lappend filehandles [open testfile.1 w]
    41     41     }
    42     42   }
    43     43   foreach fd $filehandles {
    44     44     close $fd
    45     45   }
    46     46   catch {
    47         -  file delete -force testfile.1
           47  +  forcedelete testfile.1
    48     48   }
    49     49   set N [expr $i / $num_fd_per_openwrite_db]
    50     50   
    51     51   # Create a bunch of random database names
    52     52   #
    53     53   unset -nocomplain dbname
    54     54   unset -nocomplain used
................................................................................
    88     88   
    89     89   
    90     90   # Close the databases and erase the files.
    91     91   #
    92     92   for {set i 0} {$i<$N} {incr i} {
    93     93     do_test manydb-3.$i {
    94     94       db$i close
    95         -    file delete -force $dbname($i)
           95  +    forcedelete $dbname($i)
    96     96     } {}
    97     97   }
    98     98   
    99     99   
   100    100   
   101    101   
   102    102   finish_test

Changes to test/memsubsys1.test.

    28     28   # This procedure constructs a new database in test.db.  It fills
    29     29   # this database with many small records (enough to force multiple
    30     30   # rebalance operations in the btree-layer and to require a large
    31     31   # page cache), verifies correct results, then returns.
    32     32   #
    33     33   proc build_test_db {testname pragmas} {
    34     34     catch {db close}
    35         -  file delete -force test.db test.db-journal
           35  +  forcedelete test.db test.db-journal
    36     36     sqlite3 db test.db
    37     37     sqlite3_db_config_lookaside db 0 0 0
    38     38     db eval $pragmas
    39     39     db eval {
    40     40       CREATE TABLE t1(x, y);
    41     41       CREATE TABLE t2(a, b);
    42     42       CREATE INDEX i1 ON t1(x,y);

Changes to test/memsubsys2.test.

    20     20   # This procedure constructs a new database in test.db.  It fills
    21     21   # this database with many small records (enough to force multiple
    22     22   # rebalance operations in the btree-layer and to require a large
    23     23   # page cache), verifies correct results, then returns.
    24     24   #
    25     25   proc build_test_db {testname pragmas} {
    26     26     catch {db close}
    27         -  file delete -force test.db test.db-journal
           27  +  forcedelete test.db test.db-journal
    28     28     sqlite3 db test.db
    29     29     db eval $pragmas
    30     30     db eval {
    31     31       CREATE TABLE t1(x, y);
    32     32       CREATE TABLE t2(a, b);
    33     33       CREATE INDEX i1 ON t1(x,y);
    34     34       INSERT INTO t1 VALUES(1, 100);

Changes to test/misc1.test.

   487    487   } {0}
   488    488   do_test misc1-14.2b {
   489    489     execsql {UPDATE t1 SET a=a||'y' WHERE 1}
   490    490     file exists ../test.db-journal
   491    491   } {1}
   492    492   do_test misc1-14.3 {
   493    493     cd ..
   494         -  file delete -force tempdir
          494  +  forcedelete tempdir
   495    495     execsql {COMMIT}
   496    496     file exists ./test.db-journal
   497    497   } {0}
   498    498   
   499    499   # A failed create table should not leave the table in the internal
   500    500   # data structures.  Ticket #238.
   501    501   #

Changes to test/misc2.test.

   161    161   #
   162    162   # 2006-08-16:  This has changed.  It is now permitted to update
   163    163   # the table being SELECTed from within the callback of the query.
   164    164   #
   165    165   ifcapable tclvar {
   166    166     do_test misc2-7.1 {
   167    167       db close
   168         -    file delete -force test.db
          168  +    forcedelete test.db
   169    169       sqlite3 db test.db
   170    170       execsql {
   171    171         CREATE TABLE t1(x);
   172    172         INSERT INTO t1 VALUES(1);
   173    173         INSERT INTO t1 VALUES(2);
   174    174         INSERT INTO t1 VALUES(3);
   175    175         SELECT * FROM t1;
................................................................................
   261    261     
   262    262     # Repeat the tests 7.1 through 7.8 about but this time do the SELECTs
   263    263     # in reverse order so that we exercise the sqlite3BtreePrev() routine
   264    264     # instead of sqlite3BtreeNext()
   265    265     #
   266    266     do_test misc2-7.11 {
   267    267       db close
   268         -    file delete -force test.db
          268  +    forcedelete test.db
   269    269       sqlite3 db test.db
   270    270       execsql {
   271    271         CREATE TABLE t1(x);
   272    272         INSERT INTO t1 VALUES(1);
   273    273         INSERT INTO t1 VALUES(2);
   274    274         INSERT INTO t1 VALUES(3);
   275    275         SELECT * FROM t1;
................................................................................
   357    357         }
   358    358       }
   359    359       execsql {SELECT * FROM t1}
   360    360     } {1 2 3 4 5 6 7 8 9 10}
   361    361   }
   362    362   
   363    363   db close
   364         -file delete -force test.db
          364  +forcedelete test.db
   365    365   sqlite3 db test.db
   366    366   catchsql { pragma recursive_triggers = off } 
   367    367   
   368    368   # Ticket #453.  If the SQL ended with "-", the tokenizer was calling that
   369    369   # an incomplete token, which caused problem.  The solution was to just call
   370    370   # it a minus sign.
   371    371   #

Changes to test/misc5.test.

   510    510   
   511    511   # Ticket #1370.  Do not overwrite small files (less than 1024 bytes)
   512    512   # when trying to open them as a database.
   513    513   #
   514    514   if {[permutation] == ""} {
   515    515     do_test misc5-4.1 {
   516    516       db close
   517         -    file delete -force test.db
          517  +    forcedelete test.db
   518    518       set fd [open test.db w]
   519    519       puts $fd "This is not really a database"
   520    520       close $fd
   521    521       sqlite3 db test.db
   522    522       catchsql {
   523    523         CREATE TABLE t1(a,b,c);
   524    524       }
................................................................................
   540    540     execsql {SELECT .4e+1}
   541    541   } 4.0
   542    542   
   543    543   # Ticket #1582.  Ensure that an unknown table in a LIMIT clause applied to
   544    544   # a UNION ALL query causes an error, not a crash.
   545    545   #
   546    546   db close
   547         -file delete -force test.db
          547  +forcedelete test.db
   548    548   sqlite3 db test.db
   549    549   ifcapable subquery&&compound {
   550    550     do_test misc5-6.1 {
   551    551       catchsql {
   552    552         SELECT * FROM sqlite_master 
   553    553         UNION ALL 
   554    554         SELECT * FROM sqlite_master

Changes to test/misc7.test.

    26     26   do_test misc7-3 {
    27     27     c_collation_test
    28     28   } {}
    29     29   
    30     30   # Try to open a directory:
    31     31   #
    32     32   do_test misc7-4 {
    33         -  file delete mydir
           33  +  delete_file mydir
    34     34     file mkdir mydir
    35     35     set rc [catch {
    36     36       sqlite3 db2 ./mydir
    37     37     } msg]
    38     38     list $rc $msg
    39     39   } {1 {unable to open database file}}
    40     40   
    41     41   # Try to open a file with a directory where its journal file should be.
    42     42   #
    43     43   do_test misc7-5 {
    44         -  file delete mydir
           44  +  delete_file mydir
    45     45     file mkdir mydir-journal
    46     46     sqlite3 db2 ./mydir
    47     47     catchsql {
    48     48       CREATE TABLE abc(a, b, c);
    49     49     } db2
    50     50   } {1 {unable to open database file}}
    51     51   db2 close
................................................................................
   148    148   db2 close
   149    149   
   150    150   #--------------------------------------------------------------------
   151    151   # Test that nothing goes horribly wrong when attaching a database
   152    152   # after the omit_readlock pragma has been exercised.
   153    153   #
   154    154   do_test misc7-7.1 {
   155         -  file delete -force test2.db
   156         -  file delete -force test2.db-journal
          155  +  forcedelete test2.db
          156  +  forcedelete test2.db-journal
   157    157     execsql {
   158    158       PRAGMA omit_readlock = 1;
   159    159       ATTACH 'test2.db' AS aux;
   160    160       CREATE TABLE aux.hello(world);
   161    161       SELECT name FROM aux.sqlite_master;
   162    162     }
   163    163   } {hello}
................................................................................
   250    250       set ::echo_module_cost 2.0e+99
   251    251       execsql {SELECT * FROM t1 WHERE a = 1;}
   252    252     } {1 2 3}
   253    253     unset ::echo_module_cost
   254    254   }
   255    255   
   256    256   db close
   257         -file delete -force test.db
   258         -file delete -force test.db-journal
          257  +forcedelete test.db
          258  +forcedelete test.db-journal
   259    259   sqlite3 db test.db
   260    260   
   261    261   ifcapable explain {
   262    262     do_execsql_test misc7-14.1 {
   263    263       CREATE TABLE abc(a PRIMARY KEY, b, c);
   264    264       EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid = 1;
   265    265     } {
................................................................................
   274    274       EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 ORDER BY a;
   275    275     } {0 0 0 
   276    276        {SCAN TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (~1000000 rows)}
   277    277     }
   278    278   }
   279    279   
   280    280   db close
   281         -file delete -force test.db
   282         -file delete -force test.db-journal
          281  +forcedelete test.db
          282  +forcedelete test.db-journal
   283    283   sqlite3 db test.db
   284    284   
   285    285   #--------------------------------------------------------------------
   286    286   # This is all to force the pager_remove_from_stmt_list() function
   287    287   # (inside pager.c) to remove a pager from the middle of the
   288    288   # statement-list.
   289    289   #
................................................................................
   319    319       DELETE FROM abc WHERE rowid > 12;
   320    320       INSERT INTO abc SELECT 
   321    321               randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;
   322    322     }
   323    323   } {}
   324    324   
   325    325   db close
   326         -file delete -force test.db
   327         -file delete -force test.db-journal
          326  +forcedelete test.db
          327  +forcedelete test.db-journal
   328    328   sqlite3 db test.db
   329    329   
   330    330   do_ioerr_test misc7-16 -sqlprep {
   331    331      PRAGMA cache_size = 10;
   332    332      PRAGMA default_cache_size = 10;
   333    333      CREATE TABLE t3(a, b, UNIQUE(a, b));
   334    334      INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
................................................................................
   381    381     if {[file attributes test.db -permissions]==0644} {
   382    382   
   383    383       do_test misc7-17.1 {
   384    384         execsql {
   385    385           BEGIN;
   386    386           DELETE FROM t3 WHERE (oid%3)==0;
   387    387         }
   388         -      copy_file test.db bak.db
   389         -      copy_file test.db-journal bak.db-journal
          388  +      forcecopy test.db bak.db
          389  +      forcecopy test.db-journal bak.db-journal
   390    390         execsql {
   391    391           COMMIT;
   392    392         }
   393    393       
   394    394         db close
   395         -      copy_file bak.db test.db
   396         -      copy_file bak.db-journal test.db-journal
          395  +      forcecopy bak.db test.db
          396  +      forcecopy bak.db-journal test.db-journal
   397    397         sqlite3 db test.db
   398    398       
   399    399         catch {file attributes test.db-journal -permissions r--------}
   400    400         catch {file attributes test.db-journal -readonly 1}
   401    401         catchsql {
   402    402           SELECT count(*) FROM t3;
   403    403         }
................................................................................
   480    480     set zFile [file join [pwd] "[string repeat abcde 104].db"]
   481    481     set rc [catch {sqlite3 db2 $zFile} msg]
   482    482     list $rc $msg
   483    483   } {1 {unable to open database file}}
   484    484   
   485    485   
   486    486   db close
   487         -file delete -force test.db
          487  +forcedelete test.db
   488    488   
   489    489   finish_test

Changes to test/misuse.test.

    35     35   }
    36     36   
    37     37   
    38     38   # Make sure the test logic works
    39     39   #
    40     40   do_test misuse-1.1 {
    41     41     db close
    42         -  catch {file delete -force test2.db}
    43         -  catch {file delete -force test2.db-journal}
           42  +  catch {forcedelete test2.db}
           43  +  catch {forcedelete test2.db-journal}
    44     44     sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
    45     45     execsql {
    46     46       CREATE TABLE t1(a,b);
    47     47       INSERT INTO t1 VALUES(1,2);
    48     48     }
    49     49     catchsql2 {
    50     50       SELECT * FROM t1

Changes to test/multiplex.test.

   141    141   #
   142    142   #   multiplex-2.7.*: Disable/enable tests.
   143    143   #
   144    144   
   145    145   sqlite3_multiplex_initialize "" 1
   146    146   multiplex_set db main 32768 16
   147    147   
   148         -file delete -force test.x
          148  +forcedelete test.x
   149    149   do_test multiplex-2.1.2 {
   150    150     sqlite3 db test.x
   151    151     execsql {
   152    152       PRAGMA page_size=1024;
   153    153       PRAGMA auto_vacuum=OFF;
   154    154       PRAGMA journal_mode=DELETE;
   155    155     }
................................................................................
   510    510   
   511    511   do_test multiplex-5.4.1 {
   512    512     catch { db close }
   513    513     multiplex_delete test.db
   514    514     file mkdir test.db
   515    515     list [catch { sqlite3 db test.db } msg] $msg
   516    516   } {1 {unable to open database file}}
   517         -catch { file delete test.db }
          517  +catch { delete_file test.db }
   518    518   
   519    519   do_faultsim_test multiplex-5.5 -prep {
   520    520     catch { sqlite3_multiplex_shutdown }
   521    521   } -body {
   522    522     sqlite3_multiplex_initialize "" 1
   523    523     multiplex_set db main 32768 16
   524    524   }

Changes to test/notify1.test.

   136    136   #
   137    137   # Test for slightly more complex deadlock involving three database
   138    138   # connections: db, db2 and db3.
   139    139   #
   140    140   do_test notify1-2.3.1 {
   141    141     db close
   142    142     db2 close
   143         -  file delete -force test.db test2.db test3.db
          143  +  forcedelete test.db test2.db test3.db
   144    144     foreach con {db db2 db3} {
   145    145       sqlite3 $con test.db
   146    146       $con eval { ATTACH 'test2.db' AS aux2 }
   147    147       $con eval { ATTACH 'test3.db' AS aux3 }
   148    148     }
   149    149     execsql {
   150    150       CREATE TABLE main.t1(a, b);
................................................................................
   290    290   #
   291    291   #   notify1-6.4.*: Like 6.3.*, except that instead of the second blocker
   292    292   #                  committing its transaction, the first does. The 
   293    293   #                  unlock-notify callback is therefore invoked.
   294    294   #
   295    295   db close
   296    296   do_test notify1-6.1.1 {
   297         -  file delete -force test.db test2.db
          297  +  forcedelete test.db test2.db
   298    298     foreach conn {db db2 db3} {
   299    299       sqlite3 $conn test.db
   300    300       execsql { ATTACH 'test2.db' AS two } $conn
   301    301     }
   302    302     execsql {
   303    303       CREATE TABLE t1(a, b);
   304    304       CREATE TABLE two.t2(a, b);

Changes to test/notify2.test.

   163    163     expr 0
   164    164   }
   165    165   
   166    166   foreach {iTest xStep xPrepare} {
   167    167     1 sqlite3_blocking_step sqlite3_blocking_prepare_v2
   168    168     2 sqlite3_step          sqlite3_nonblocking_prepare_v2
   169    169   } {
   170         -  file delete -force test.db test2.db test3.db
          170  +  forcedelete test.db test2.db test3.db
   171    171   
   172    172     set ThreadSetup "set xStep $xStep;set xPrepare $xPrepare;set nSecond $nSecond"
   173    173   
   174    174     # Set up the database schema used by this test. Each thread opens file
   175    175     # test.db as the main database, then attaches files test2.db and test3.db
   176    176     # as auxillary databases. Each file contains a single table (t1, t2 and t3, in
   177    177     # files test.db, test2.db and test3.db, respectively). 

Changes to test/notify3.test.

    21     21     finish_test 
    22     22     return 
    23     23   }
    24     24   
    25     25   set esc [sqlite3_enable_shared_cache 1]
    26     26   
    27     27   sqlite3 db  test.db
    28         -file delete -force test.db2 test.db2-journal test.db2-wal
           28  +forcedelete test.db2 test.db2-journal test.db2-wal
    29     29   sqlite3 db2 test.db2
    30     30   
    31     31   do_test notify3-1.1 {
    32     32     execsql { 
    33     33       CREATE TABLE t1(a, b); 
    34     34       INSERT INTO t1 VALUES('t1 A', 't1 B');
    35     35     }

Changes to test/openv2.test.

    13     13   #
    14     14   # $Id: openv2.test,v 1.2 2009/06/11 17:32:45 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   db close
    20         -file delete -force test.db test.db-journal
           20  +forcedelete test.db test.db-journal
    21     21   do_test openv2-1.1 {
    22     22     set rc [catch {sqlite3 db test.db -create 0} msg]
    23     23     lappend rc $msg
    24     24   } {1 {unable to open database file}}
    25     25   do_test openv2-1.2 {
    26     26     info commands db
    27     27   } {}

Changes to test/pager1.test.

   448    448     execsql {
   449    449       SELECT count(*) FROM t1;
   450    450       PRAGMA integrity_check;
   451    451     }
   452    452   } {4 ok}
   453    453   do_test pager1.4.2.3 {
   454    454     faultsim_restore_and_reopen
   455         -  foreach f [glob test.db-mj*] { file delete -force $f }
          455  +  foreach f [glob test.db-mj*] { forcedelete $f }
   456    456     execsql {
   457    457       SELECT count(*) FROM t1;
   458    458       PRAGMA integrity_check;
   459    459     }
   460    460   } {64 ok}
   461    461   do_test pager1.4.2.4 {
   462    462     faultsim_restore_and_reopen
................................................................................
   465    465       SELECT count(*) FROM t1;
   466    466       PRAGMA integrity_check;
   467    467     }
   468    468   } {4 ok}
   469    469   do_test pager1.4.2.5 {
   470    470     faultsim_restore_and_reopen
   471    471     hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456
   472         -  foreach f [glob test.db-mj*] { file delete -force $f }
          472  +  foreach f [glob test.db-mj*] { forcedelete $f }
   473    473     execsql {
   474    474       SELECT count(*) FROM t1;
   475    475       PRAGMA integrity_check;
   476    476     }
   477    477   } {4 ok}
   478    478   }
   479    479   
................................................................................
   645    645       
   646    646       # Restore the file-system again. This time, before reopening the databases,
   647    647       # delete the master-journal file from the file-system. It now appears that
   648    648       # the transaction was committed (no master-journal file == no rollback).
   649    649       #
   650    650       do_test pager1-4.4.$tn.7 {
   651    651         faultsim_restore_and_reopen $prefix
   652         -      foreach f [glob ${prefix}-mj*] { file delete -force $f }
          652  +      foreach f [glob ${prefix}-mj*] { forcedelete $f }
   653    653         execsql "ATTACH '${prefix}2' AS aux"
   654    654       } {}
   655    655       do_execsql_test pager1-4.4.$tn.8 {
   656    656         SELECT * FROM a
   657    657       } {double-you why zed won too free}
   658    658       do_execsql_test pager1-4.4.$tn.9 {
   659    659         SELECT * FROM b
................................................................................
   660    660       } {won too free double-you why zed}
   661    661     }
   662    662   
   663    663     cd $pwd
   664    664   }
   665    665   db close
   666    666   tv delete
   667         -file delete -force $dirname
          667  +forcedelete $dirname
   668    668   
   669    669   
   670    670   # Set up a VFS to make a copy of the file-system just before deleting a
   671    671   # journal file to commit a transaction. The transaction modifies exactly
   672    672   # two database pages (and page 1 - the change counter).
   673    673   #
   674    674   testvfs tv -default 1
................................................................................
   878    878     catch {file attributes test.db-journal -readonly 1}
   879    879     catchsql { SELECT * FROM t1 }
   880    880   } {1 {unable to open database file}}
   881    881   do_test pager1.4.7.3 {
   882    882     db close
   883    883     catch {file attributes test.db-journal -permissions rw-rw-rw-}
   884    884     catch {file attributes test.db-journal -readonly 0}
   885         -  file delete test.db-journal
          885  +  delete_file test.db-journal
   886    886     file exists test.db-journal
   887    887   } {0}
   888    888   
   889    889   #-------------------------------------------------------------------------
   890    890   # The following tests deal with multi-file commits.
   891    891   #
   892    892   # pager1-5.1.*: The case where a multi-file cannot be committed because
................................................................................
  2364   2364   # Test that if an empty database file (size 0 bytes) is opened in 
  2365   2365   # exclusive-locking mode, any journal file is deleted from the file-system
  2366   2366   # without being rolled back. And that the RESERVED lock obtained while
  2367   2367   # doing this is not released.
  2368   2368   #
  2369   2369   do_test pager1-30.1 {
  2370   2370     db close
  2371         -  file delete test.db
  2372         -  file delete test.db-journal
         2371  +  delete_file test.db
         2372  +  delete_file test.db-journal
  2373   2373     set fd [open test.db-journal w]
  2374   2374     seek $fd [expr 512+1032*2]
  2375   2375     puts -nonewline $fd x
  2376   2376     close $fd
  2377   2377   
  2378   2378     sqlite3 db test.db
  2379   2379     execsql {
................................................................................
  2405   2405       INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
  2406   2406       INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
  2407   2407       INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
  2408   2408       INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
  2409   2409       BEGIN;
  2410   2410         UPDATE t1 SET y = randomblob(1499);
  2411   2411     }
  2412         -  file copy test.db test.db2
  2413         -  file copy test.db-journal test.db2-journal
         2412  +  copy_file test.db test.db2
         2413  +  copy_file test.db-journal test.db2-journal
  2414   2414     
  2415   2415     hexio_write test.db2-journal 24 00000000
  2416   2416     sqlite3 db2 test.db2
  2417   2417     execsql { PRAGMA integrity_check } db2
  2418   2418   } {ok}
  2419   2419   }
  2420   2420   
  2421   2421   
  2422   2422   finish_test

Changes to test/pagerfault.test.

   229    229   } -test {
   230    230     faultsim_test_result {0 {}}
   231    231     faultsim_integrity_check
   232    232   }
   233    233   do_faultsim_test pagerfault-5.3 -faults oom-transient -prep {
   234    234     faultsim_restore_and_reopen
   235    235     db func a_string a_string
   236         -  file delete -force test2.db test2.db-journal test2.db-wal
          236  +  forcedelete test2.db test2.db-journal test2.db-wal
   237    237     execsql { 
   238    238       PRAGMA journal_mode = PERSIST;
   239    239       ATTACH 'test2.db' AS aux;
   240    240       PRAGMA aux.journal_mode = PERSIST;
   241    241       PRAGMA aux.journal_size_limit = 0;
   242    242     }
   243    243   } -body {
................................................................................
   637    637       PRAGMA journal_mode = PERSIST;
   638    638       BEGIN;
   639    639         CREATE TABLE t1(x, y UNIQUE);
   640    640         INSERT INTO t1 VALUES(a_string(333), a_string(444));
   641    641       COMMIT;
   642    642     }
   643    643     db close
   644         -  file delete -force test.db
          644  +  forcedelete test.db
   645    645     faultsim_save
   646    646   } {}
   647    647   do_faultsim_test pagerfault-13 -prep {
   648    648     faultsim_restore_and_reopen
   649    649   } -body {
   650    650     execsql { CREATE TABLE xx(a, b) }
   651    651   } -test {
................................................................................
  1102   1102   #   PagerCommitPhaseOne(<in-memory-db>)   ->   SQLITE_OK
  1103   1103   #   PagerCommitPhaseOne(<file-db>)        ->   SQLITE_IOERR
  1104   1104   #   PagerRollback(<in-memory-db>)
  1105   1105   #   PagerRollback(<file-db>)
  1106   1106   #
  1107   1107   do_faultsim_test pagerfault-23 -prep {
  1108   1108     sqlite3 db :memory:
  1109         -  foreach f [glob -nocomplain test.db*] { file delete -force $f }
         1109  +  foreach f [glob -nocomplain test.db*] { forcedelete $f }
  1110   1110     db eval { 
  1111   1111       ATTACH 'test.db2' AS aux;
  1112   1112       CREATE TABLE t1(a, b);
  1113   1113       CREATE TABLE aux.t2(a, b);
  1114   1114     }
  1115   1115   } -body {
  1116   1116     execsql { 

Changes to test/pagesize.test.

    38     38       PRAGMA page_size=2048;
    39     39       PRAGMA page_size;
    40     40     }
    41     41   } 1024
    42     42   
    43     43   do_test pagesize-1.4 {
    44     44     db close
    45         -  file delete -force test.db
           45  +  forcedelete test.db
    46     46     sqlite3 db test.db
    47     47     execsql {
    48     48       PRAGMA page_size=511;
    49     49       PRAGMA page_size;
    50     50     }
    51     51   } 1024
    52     52   do_test pagesize-1.5 {
................................................................................
    95     95           INSERT INTO t1 VALUES(2,3,4);
    96     96           SELECT * FROM t1;
    97     97         }
    98     98       } {1 2 3 2 3 4}
    99     99     }
   100    100     do_test pagesize-2.$PGSZ.1 {
   101    101       db close
   102         -    file delete -force test.db
          102  +    forcedelete test.db
   103    103       sqlite3 db test.db
   104    104       execsql "PRAGMA page_size=$PGSZ"
   105    105       execsql {
   106    106         CREATE TABLE t1(x);
   107    107         PRAGMA page_size;
   108    108       }
   109    109     } $PGSZ
................................................................................
   186    186     do_test pagesize-2.$PGSZ.16 {
   187    187       execsql {DROP TABLE t1}
   188    188       ifcapable {vacuum} {execsql VACUUM}
   189    189     } {}
   190    190     integrity_check pagesize-2.$PGSZ.17
   191    191   
   192    192     db close
   193         -  file delete -force test.db
          193  +  forcedelete test.db
   194    194     sqlite3 db test.db
   195    195     do_test pagesize-2.$PGSZ.30 {
   196    196       execsql "
   197    197         CREATE TABLE t1(x);
   198    198         PRAGMA temp.page_size=$PGSZ;
   199    199         CREATE TEMP TABLE t2(y);
   200    200         PRAGMA main.page_size;
   201    201         PRAGMA temp.page_size;
   202    202       "
   203    203     } [list 1024 $PGSZ]
   204    204   
   205    205     db close
   206         -  file delete -force test.db
          206  +  forcedelete test.db
   207    207     sqlite3 db test.db
   208    208     do_test pagesize-2.$PGSZ.40 {
   209    209       execsql "
   210    210         PRAGMA page_size=$PGSZ;
   211    211         CREATE TABLE t1(x);
   212    212         CREATE TEMP TABLE t2(y);
   213    213         PRAGMA main.page_size;
   214    214         PRAGMA temp.page_size;
   215    215       "
   216    216     } [list $PGSZ $PGSZ]
   217    217   }
   218    218   
   219    219   finish_test

Changes to test/pcache2.test.

    30     30     sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1
    31     31     sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0
    32     32   } {0 0 0}
    33     33   
    34     34   # Open up two database connections to separate files.
    35     35   #
    36     36   do_test pcache2-1.2 {
    37         -  file delete -force test.db test.db-journal
           37  +  forcedelete test.db test.db-journal
    38     38     sqlite3 db test.db
    39     39     db eval {PRAGMA cache_size=10}
    40     40     lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
    41     41   } {2}
    42     42   do_test pcache2-1.3 {
    43         -  file delete -force test2.db test2.db-journal
           43  +  forcedelete test2.db test2.db-journal
    44     44     sqlite3 db2 test2.db
    45     45     db2 eval {PRAGMA cache_size=50}
    46     46     lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
    47     47   } {4}
    48     48   
    49     49   
    50     50   # Make lots of changes on the first connection.  Verify that the

Changes to test/pragma.test.

    47     47     return
    48     48   }
    49     49   
    50     50   # Delete the preexisting database to avoid the special setup
    51     51   # that the "all.test" script does.
    52     52   #
    53     53   db close
    54         -file delete test.db test.db-journal
    55         -file delete test3.db test3.db-journal
           54  +delete_file test.db test.db-journal
           55  +delete_file test3.db test3.db-journal
    56     56   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
    57     57   
    58     58   
    59     59   ifcapable pager_pragmas {
    60     60   set DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}]
    61     61   set TEMP_CACHE_SZ [db one {PRAGMA temp.default_cache_size}]
    62     62   do_test pragma-1.1 {
................................................................................
   217    217       PRAGMA bogus = -1234;  -- Parsing of negative values
   218    218     }
   219    219   } {}
   220    220   
   221    221   # Test modifying the safety_level of an attached database.
   222    222   ifcapable pager_pragmas&&attach {
   223    223     do_test pragma-2.1 {
   224         -    file delete -force test2.db
   225         -    file delete -force test2.db-journal
          224  +    forcedelete test2.db
          225  +    forcedelete test2.db-journal
   226    226       execsql {
   227    227         ATTACH 'test2.db' AS aux;
   228    228       } 
   229    229     } {}
   230    230     do_test pragma-2.2 {
   231    231       execsql {
   232    232         pragma aux.synchronous;
................................................................................
   251    251   # Construct a corrupted index and make sure the integrity_check
   252    252   # pragma finds it.
   253    253   #
   254    254   # These tests won't work if the database is encrypted
   255    255   #
   256    256   do_test pragma-3.1 {
   257    257     db close
   258         -  file delete -force test.db test.db-journal
          258  +  forcedelete test.db test.db-journal
   259    259     sqlite3 db test.db
   260    260     execsql {
   261    261       PRAGMA auto_vacuum=OFF;
   262    262       BEGIN;
   263    263       CREATE TABLE t2(a,b,c);
   264    264       CREATE INDEX i2 ON t2(a);
   265    265       INSERT INTO t2 VALUES(11,2,3);
................................................................................
   308    308       } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
   309    309     
   310    310       # Add additional corruption by appending unused pages to the end of
   311    311       # the database file testerr.db
   312    312       #
   313    313       do_test pragma-3.8 {
   314    314         execsql {DETACH t2}
   315         -      file delete -force testerr.db testerr.db-journal
          315  +      forcedelete testerr.db testerr.db-journal
   316    316         set out [open testerr.db w]
   317    317         fconfigure $out -translation binary
   318    318         set in [open test.db r]
   319    319         fconfigure $in -translation binary
   320    320         puts -nonewline $out [read $in]
   321    321         seek $in 0
   322    322         puts -nonewline $out [read $in]
................................................................................
   415    415       } {{*** in database t2 ***
   416    416   Page 4 is never used
   417    417   Page 5 is never used
   418    418   Page 6 is never used} {rowid 1 missing from index i2}}
   419    419     }
   420    420     do_test pragma-3.19 {
   421    421       catch {db close}
   422         -    file delete -force test.db test.db-journal
          422  +    forcedelete test.db test.db-journal
   423    423       sqlite3 db test.db
   424    424       db eval {PRAGMA integrity_check}
   425    425     } {ok}
   426    426   }
   427    427   #exit
   428    428   
   429    429   # Test modifying the cache_size of an attached database.
................................................................................
   737    737     sqlite3_step $::STMT
   738    738   } SQLITE_ERROR
   739    739   do_test pragma-8.1.10 {
   740    740     sqlite3_finalize $::STMT
   741    741   } SQLITE_SCHEMA
   742    742   
   743    743   # Make sure the schema-version can be manipulated in an attached database.
   744         -file delete -force test2.db
   745         -file delete -force test2.db-journal
          744  +forcedelete test2.db
          745  +forcedelete test2.db-journal
   746    746   ifcapable attach {
   747    747     do_test pragma-8.1.11 {
   748    748       execsql {
   749    749         ATTACH 'test2.db' AS aux;
   750    750         CREATE TABLE aux.t1(a, b, c);
   751    751         PRAGMA aux.schema_version = 205;
   752    752       }
................................................................................
  1201   1201     }
  1202   1202   } {}
  1203   1203   
  1204   1204   } ;# ifcapable bloblit 
  1205   1205   
  1206   1206   ifcapable pager_pragmas {
  1207   1207     db close
  1208         -  file delete -force test.db
         1208  +  forcedelete test.db
  1209   1209     sqlite3 db test.db
  1210   1210   
  1211   1211     do_test pragma-14.1 {
  1212   1212       execsql { pragma auto_vacuum = 0 }
  1213   1213       execsql { pragma page_count }
  1214   1214     } {0}
  1215   1215   
................................................................................
  1237   1237       execsql {
  1238   1238         ROLLBACK;
  1239   1239         PRAGMA page_count;
  1240   1240       }
  1241   1241     } {2}
  1242   1242   
  1243   1243     do_test pragma-14.6 {
  1244         -    file delete -force test2.db
         1244  +    forcedelete test2.db
  1245   1245       sqlite3 db2 test2.db
  1246   1246       execsql {
  1247   1247         PRAGMA auto_vacuum = 0;
  1248   1248         CREATE TABLE t1(a, b, c);
  1249   1249         CREATE TABLE t2(a, b, c);
  1250   1250         CREATE TABLE t3(a, b, c);
  1251   1251         CREATE TABLE t4(a, b, c);

Changes to test/pragma2.test.

    29     29     return
    30     30   }
    31     31   
    32     32   # Delete the preexisting database to avoid the special setup
    33     33   # that the "all.test" script does.
    34     34   #
    35     35   db close
    36         -file delete test.db test.db-journal
    37         -file delete test3.db test3.db-journal
           36  +delete_file test.db test.db-journal
           37  +delete_file test3.db test3.db-journal
    38     38   sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
    39     39   db eval {PRAGMA auto_vacuum=0}
    40     40   
    41     41   do_test pragma2-1.1 {
    42     42     execsql {
    43     43       PRAGMA freelist_count;
    44     44     }
................................................................................
    57     57   } {1}
    58     58   do_test pragma2-1.4 {
    59     59     execsql {
    60     60       PRAGMA main.freelist_count;
    61     61     }
    62     62   } {1}
    63     63   
    64         -file delete -force test2.db
    65         -file delete -force test2.db-journal
           64  +forcedelete test2.db
           65  +forcedelete test2.db-journal
    66     66   
    67     67   ifcapable attach {
    68     68     do_test pragma2-2.1 {
    69     69       execsql {
    70     70         ATTACH 'test2.db' AS aux;
    71     71         PRAGMA aux.auto_vacuum=OFF;
    72     72         PRAGMA aux.freelist_count;

Changes to test/quota.test.

   119    119   proc quota_check {filename limitvar size} {
   120    120     upvar $limitvar limit
   121    121     lappend ::quota [set limit] $size
   122    122     if {[info exists ::quota_request_ok]} { set limit $size }
   123    123   }
   124    124   
   125    125   do_test quota-3.1.1 {
   126         -  file delete -force test.db
          126  +  forcedelete test.db
   127    127     sqlite3_quota_initialize "" 1
   128    128     sqlite3_quota_set *test.db 4096 quota_check
   129    129   } {SQLITE_OK}
   130    130   do_test quota-3.1.2 {
   131    131     sqlite3 db test.db
   132    132     execsql {
   133    133       PRAGMA page_size = 1024;
................................................................................
   154    154   do_test quota-3.1.6 {
   155    155     db close
   156    156     db2 close
   157    157     sqlite3_quota_set *test.db 0 {}
   158    158   } {SQLITE_OK}
   159    159   
   160    160   do_test quota-3.2.1 {
   161         -  file delete force test.db test2.db 
          161  +  delete_file force test.db test2.db 
   162    162   
   163    163     sqlite3_quota_set * 4096 {}
   164    164     sqlite3 db1a test.db
   165    165     sqlite3 db2a test2.db
   166    166   
   167    167     foreach db {db1a db2a} {
   168    168       execsql {
................................................................................
   253    253     quota_list
   254    254   } {*test.db *test2.db}
   255    255   do_test quota-4.1.5 {
   256    256     sqlite3_quota_set *test.db 0 {}
   257    257     quota_list
   258    258   } {*test2.db}
   259    259   do_test quota-4.1.6 {
   260         -  file delete -force test2.db test2.db-journal test2.db-wal
          260  +  forcedelete test2.db test2.db-journal test2.db-wal
   261    261     sqlite3 db test2.db
   262    262     db eval {CREATE TABLE t2(x); INSERT INTO t2 VALUES('tab-t2');}
   263    263     quota_list
   264    264   } {*test2.db}
   265    265   do_test quota-4.1.7 {
   266    266     catchsql {INSERT INTO t2 VALUES(zeroblob(200000))}
   267    267   } {1 {database or disk is full}}
................................................................................
   353    353   do_faultsim_test quota-5.2 -prep {
   354    354     catch {db close}
   355    355   } -body {
   356    356     sqlite3 db test.db
   357    357   }
   358    358   
   359    359   catch { db close }
   360         -file delete -force test.db
          360  +forcedelete test.db
   361    361   
   362    362   do_test quota-5.3.prep {
   363    363     sqlite3 db test.db
   364    364     execsql {
   365    365       PRAGMA auto_vacuum = 1;
   366    366       PRAGMA page_size = 1024;
   367    367       CREATE TABLE t1(a, b);
................................................................................
   373    373     faultsim_restore_and_reopen
   374    374   } -body {
   375    375     execsql { DELETE FROM t1 }
   376    376   }
   377    377   
   378    378   do_test quota-5.4.1 {
   379    379     catch { db close }
   380         -  file delete -force test.db
          380  +  forcedelete test.db
   381    381     file mkdir test.db
   382    382     list [catch { sqlite3 db test.db } msg] $msg
   383    383   } {1 {unable to open database file}}
   384    384   
   385    385   do_faultsim_test quota-5.5 -prep {
   386    386     catch { sqlite3_quota_shutdown }
   387    387   } -body {

Changes to test/rollback.test.

    84     84    && [permutation] ne "inmemory_journal"
    85     85   } {
    86     86     do_test rollback-2.1 {
    87     87       execsql {
    88     88         BEGIN;
    89     89         INSERT INTO t3 VALUES('hello world');
    90     90       }
    91         -    file copy -force test.db testA.db
    92         -    file copy -force test.db-journal testA.db-journal
           91  +    forcecopy test.db testA.db
           92  +    forcecopy test.db-journal testA.db-journal
    93     93       execsql {
    94     94         COMMIT;
    95     95       }
    96     96     } {}
    97     97   
    98     98     # At this point files testA.db and testA.db-journal are present in the
    99     99     # file system. This block adds a master-journal file pointer to the

Changes to test/savepoint.test.

   367    367   
   368    368   #-------------------------------------------------------------------------
   369    369   # The following tests, savepoint-6.*, test an incr-vacuum inside of a
   370    370   # couple of nested savepoints.
   371    371   #
   372    372   ifcapable {autovacuum && pragma} {
   373    373     db close
   374         -  file delete -force test.db
          374  +  forcedelete test.db
   375    375     sqlite3 db test.db
   376    376   
   377    377     do_test savepoint-6.1 {
   378    378       execsql { PRAGMA auto_vacuum = incremental }
   379    379       wal_set_journal_mode
   380    380       execsql {
   381    381         CREATE TABLE t1(a, b, c);
................................................................................
   415    415   }
   416    416   
   417    417   #-------------------------------------------------------------------------
   418    418   # The following tests, savepoint-7.*, attempt to break the logic 
   419    419   # surrounding savepoints by growing and shrinking the database file.
   420    420   #
   421    421   db close
   422         -file delete -force test.db
          422  +forcedelete test.db
   423    423   sqlite3 db test.db
   424    424   
   425    425   do_test savepoint-7.1 {
   426    426     execsql { PRAGMA auto_vacuum = incremental }
   427    427     wal_set_journal_mode
   428    428     execsql {
   429    429       PRAGMA cache_size = 10;
................................................................................
   486    486     }
   487    487     execsql { PRAGMA integrity_check }
   488    488   } {ok}
   489    489   wal_check_journal_mode savepoint-7.3.3
   490    490   
   491    491   do_test savepoint-7.4.1 {
   492    492     db close
   493         -  file delete -force test.db
          493  +  forcedelete test.db
   494    494     sqlite3 db test.db
   495    495     execsql { PRAGMA auto_vacuum = incremental }
   496    496     wal_set_journal_mode
   497    497     execsql {
   498    498       CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
   499    499       INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));
   500    500       BEGIN;
................................................................................
   636    636   # of the aux1 and aux2 locks.  So record the current lock status of
   637    637   # TEMP for use in the answers.
   638    638   set templockstate [lindex [db eval {PRAGMA lock_status}] 3]
   639    639   
   640    640   
   641    641   if {[wal_is_wal_mode]==0} {
   642    642     do_test savepoint-10.2.1 {
   643         -    file delete -force test3.db
   644         -    file delete -force test2.db
          643  +    forcedelete test3.db
          644  +    forcedelete test2.db
   645    645       execsql {
   646    646         ATTACH 'test2.db' AS aux1;
   647    647         ATTACH 'test3.db' AS aux2;
   648    648         DROP TABLE t1;
   649    649         CREATE TABLE main.t1(x, y);
   650    650         CREATE TABLE aux1.t2(x, y);
   651    651         CREATE TABLE aux2.t3(x, y);
................................................................................
   758    758   #-------------------------------------------------------------------------
   759    759   # The following tests - savepoint-11.* - test the interaction of 
   760    760   # savepoints and creating or dropping tables and indexes in 
   761    761   # auto-vacuum mode.
   762    762   # 
   763    763   do_test savepoint-11.1 {
   764    764     db close
   765         -  file delete -force test.db
          765  +  forcedelete test.db
   766    766     sqlite3 db test.db
   767    767     execsql { PRAGMA auto_vacuum = full; }
   768    768     wal_set_journal_mode
   769    769     execsql {
   770    770       CREATE TABLE t1(a, b, UNIQUE(a, b));
   771    771       INSERT INTO t1 VALUES(1, randstr(1000,1000));
   772    772       INSERT INTO t1 VALUES(2, randstr(1000,1000));
................................................................................
   864    864   #-------------------------------------------------------------------------
   865    865   # The following tests - savepoint-13.* - test the interaction of 
   866    866   # savepoints and "journal_mode = off".
   867    867   # 
   868    868   if {[wal_is_wal_mode]==0} {
   869    869     do_test savepoint-13.1 {
   870    870       db close
   871         -    catch {file delete -force test.db}
          871  +    catch {forcedelete test.db}
   872    872       sqlite3 db test.db
   873    873       execsql {
   874    874         BEGIN;
   875    875           CREATE TABLE t1(a PRIMARY KEY, b);
   876    876           INSERT INTO t1 VALUES(1, 2);
   877    877         COMMIT;
   878    878         PRAGMA journal_mode = off;
................................................................................
   905    905         ROLLBACK;
   906    906         SELECT * FROM t1;
   907    907       }
   908    908     } {1 2 3 4 5 6 7 8 9 10 11 12}
   909    909   }
   910    910   
   911    911   db close
   912         -file delete test.db
          912  +delete_file test.db
   913    913   do_multiclient_test tn {
   914    914     do_test savepoint-14.$tn.1 {
   915    915       sql1 {
   916    916         CREATE TABLE foo(x);
   917    917         INSERT INTO foo VALUES(1);
   918    918         INSERT INTO foo VALUES(2);
   919    919       }

Changes to test/savepoint6.test.

   242    242     sql { PRAGMA cache_size = 10 }
   243    243   }] {
   244    244   
   245    245     unset -nocomplain ::lSavepoint
   246    246     unset -nocomplain ::aEntry
   247    247   
   248    248     catch { db close }
   249         -  file delete -force test.db test.db-wal test.db-journal
          249  +  forcedelete test.db test.db-wal test.db-journal
   250    250     eval $zSetup
   251    251     sql $DATABASE_SCHEMA
   252    252   
   253    253     wal_set_journal_mode
   254    254   
   255    255     do_test savepoint6-$testname.setup {
   256    256       savepoint one

Changes to test/securedel.test.

    22     22   }
    23     23   
    24     24   
    25     25   do_test securedel-1.0 {
    26     26     db eval {PRAGMA secure_delete;}
    27     27   } $DEFAULT_SECDEL
    28     28   
    29         -file delete -force test2.db test2.db-journal
           29  +forcedelete test2.db test2.db-journal
    30     30   do_test securedel-1.1 {
    31     31     db eval {
    32     32       ATTACH 'test2.db' AS db2;
    33     33       PRAGMA main.secure_delete=ON;
    34     34       PRAGMA db2.secure_delete;
    35     35     }
    36     36   } [list 1 $DEFAULT_SECDEL]

Changes to test/shared.test.

    23     23   }
    24     24   
    25     25   set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
    26     26   
    27     27   foreach av [list 0 1] {
    28     28   
    29     29   # Open the database connection and execute the auto-vacuum pragma
    30         -file delete -force test.db
           30  +forcedelete test.db
    31     31   sqlite3 db test.db
    32     32   
    33     33   ifcapable autovacuum {
    34     34     do_test shared-[expr $av+1].1.0 {
    35     35       execsql "pragma auto_vacuum=$::av"
    36     36       execsql {pragma auto_vacuum}
    37     37     } "$av"
................................................................................
   289    289   # (as well as main):
   290    290   #
   291    291   #     db.main   ->   ./test.db
   292    292   #     db.test2  ->   ./test2.db
   293    293   #     db2.main  ->   ./test2.db
   294    294   #     db2.test  ->   ./test.db
   295    295   #
   296         -file delete -force test.db
   297         -file delete -force test2.db
   298         -file delete -force test2.db-journal
          296  +forcedelete test.db
          297  +forcedelete test2.db
          298  +forcedelete test2.db-journal
   299    299   sqlite3 db  test.db
   300    300   sqlite3 db2 test2.db
   301    301   do_test shared-$av.4.1.1 {
   302    302     set sqlite_open_file_count
   303    303     expr $sqlite_open_file_count-($extrafds_prelock*2)
   304    304   } {2}
   305    305   do_test shared-$av.4.1.2 {
................................................................................
   422    422   catch {db2 close}
   423    423   catch {db close}
   424    424   
   425    425   #--------------------------------------------------------------------------
   426    426   # Tests shared-5.* 
   427    427   #
   428    428   foreach db [list test.db test1.db test2.db test3.db] {
   429         -  file delete -force $db ${db}-journal
          429  +  forcedelete $db ${db}-journal
   430    430   }
   431    431   do_test shared-$av.5.1.1 {
   432    432     sqlite3 db1 test.db
   433    433     sqlite3 db2 test.db
   434    434     execsql {
   435    435       ATTACH 'test1.db' AS test1;
   436    436       ATTACH 'test2.db' AS test2;
................................................................................
   553    553     }
   554    554     set ret
   555    555   } {}
   556    556   
   557    557   catch {db1 close}
   558    558   catch {db2 close}
   559    559   foreach f [list test.db test2.db] {
   560         -  file delete -force $f ${f}-journal
          560  +  forcedelete $f ${f}-journal
   561    561   }
   562    562   
   563    563   #--------------------------------------------------------------------------
   564    564   # Tests shared-7.* test auto-vacuum does not invalidate cursors from
   565    565   # other shared-cache users when it reorganizes the database on 
   566    566   # COMMIT.
   567    567   #
................................................................................
   639    639   catch {db2 close}
   640    640   unset -nocomplain contents
   641    641   
   642    642   #--------------------------------------------------------------------------
   643    643   # The following tests try to trick the shared-cache code into assuming
   644    644   # the wrong encoding for a database.
   645    645   #
   646         -file delete -force test.db test.db-journal
          646  +forcedelete test.db test.db-journal
   647    647   ifcapable utf16 {
   648    648     do_test shared-$av.8.1.1 {
   649    649       sqlite3 db test.db
   650    650       execsql {
   651    651         PRAGMA encoding = 'UTF-16';
   652    652         SELECT * FROM sqlite_master;
   653    653       }
................................................................................
   671    671     do_test shared-$av.8.1.5 {
   672    672       db2 close
   673    673       execsql {
   674    674         PRAGMA encoding;
   675    675       }
   676    676     } {UTF-8}
   677    677   
   678         -  file delete -force test2.db test2.db-journal
          678  +  forcedelete test2.db test2.db-journal
   679    679     do_test shared-$av.8.2.1 {
   680    680       execsql {
   681    681         ATTACH 'test2.db' AS aux;
   682    682         SELECT * FROM aux.sqlite_master;
   683    683       }
   684    684     } {}
   685    685     do_test shared-$av.8.2.2 {
................................................................................
   689    689         CREATE TABLE def(d, e, f);
   690    690       } db2
   691    691       string range [execsql {PRAGMA encoding;} db2] 0 end-2
   692    692     } {UTF-16}
   693    693   
   694    694     catch {db close}
   695    695     catch {db2 close}
   696         -  file delete -force test.db test2.db
          696  +  forcedelete test.db test2.db
   697    697   
   698    698     do_test shared-$av.8.3.2 {
   699    699       sqlite3 db test.db
   700    700       execsql { CREATE TABLE def(d, e, f) }
   701    701       execsql { PRAGMA encoding }
   702    702     } {UTF-8}
   703    703     do_test shared-$av.8.3.3 {
................................................................................
   728    728       }
   729    729     } {1 {attached databases must use the same text encoding as main database}}
   730    730   }
   731    731   }
   732    732   
   733    733   catch {db close}
   734    734   catch {db2 close}
   735         -file delete -force test.db test2.db
          735  +forcedelete test.db test2.db
   736    736   
   737    737   #---------------------------------------------------------------------------
   738    738   # The following tests - shared-9.* - test interactions between TEMP triggers
   739    739   # and shared-schemas.
   740    740   #
   741    741   ifcapable trigger&&tempdb {
   742    742   
................................................................................
   768    768   
   769    769   #---------------------------------------------------------------------------
   770    770   # The following tests - shared-10.* - test that the library behaves 
   771    771   # correctly when a connection to a shared-cache is closed. 
   772    772   #
   773    773   do_test shared-$av.10.1 {
   774    774     # Create a small sample database with two connections to it (db and db2).
   775         -  file delete -force test.db
          775  +  forcedelete test.db
   776    776     sqlite3 db  test.db
   777    777     sqlite3 db2 test.db
   778    778     execsql {
   779    779       CREATE TABLE ab(a PRIMARY KEY, b);
   780    780       CREATE TABLE de(d PRIMARY KEY, e);
   781    781       INSERT INTO ab VALUES('Chiang Mai', 100000);
   782    782       INSERT INTO ab VALUES('Bangkok', 8000000);
................................................................................
   849    849   integrity_check shared-$av.10.10
   850    850   do_test shared-$av.10.11 {
   851    851     db close
   852    852     db3 close
   853    853   } {}
   854    854   
   855    855   do_test shared-$av.11.1 {
   856         -  file delete -force test.db
          856  +  forcedelete test.db
   857    857     sqlite3 db  test.db
   858    858     sqlite3 db2 test.db
   859    859     execsql {
   860    860       CREATE TABLE abc(a, b, c);
   861    861       CREATE TABLE abc2(a, b, c);
   862    862       BEGIN;
   863    863       INSERT INTO abc VALUES(1, 2, 3);
................................................................................
   912    912   do_test shared-$av.11.11 {
   913    913     db close
   914    914     db2 close
   915    915   } {}
   916    916   
   917    917   # This tests that if it is impossible to free any pages, SQLite will
   918    918   # exceed the limit set by PRAGMA cache_size.
   919         -file delete -force test.db test.db-journal
          919  +forcedelete test.db test.db-journal
   920    920   sqlite3 db test.db 
   921    921   ifcapable pager_pragmas {
   922    922     do_test shared-$av.12.1 {
   923    923       execsql {
   924    924         PRAGMA cache_size = 10;
   925    925         PRAGMA cache_size;
   926    926       }
................................................................................
   959    959   # Internally, locks are acquired on shared B-Tree structures in the order
   960    960   # that the structures appear in the virtual memory address space. This
   961    961   # test case attempts to cause the order of the structures in memory 
   962    962   # to be different from the order in which they are attached to a given
   963    963   # database handle. This covers an extra line or two.
   964    964   #
   965    965   do_test shared-$av.13.1 {
   966         -  file delete -force test2.db test3.db test4.db test5.db
          966  +  forcedelete test2.db test3.db test4.db test5.db
   967    967     sqlite3 db :memory:
   968    968     execsql {
   969    969       ATTACH 'test2.db' AS aux2;
   970    970       ATTACH 'test3.db' AS aux3;
   971    971       ATTACH 'test4.db' AS aux4;
   972    972       ATTACH 'test5.db' AS aux5;
   973    973       DETACH aux2;
................................................................................
  1022   1022   # [db2]. This is to try to find any points where shared-schema elements
  1023   1023   # are allocated using the lookaside buffer of [db].
  1024   1024   # 
  1025   1025   # Mutexes are enabled for this test as that activates a couple of useful
  1026   1026   # assert() statements in the C code.
  1027   1027   #
  1028   1028   do_test shared-$av-15.1 {
  1029         -  file delete -force test.db
         1029  +  forcedelete test.db
  1030   1030     sqlite3 db test.db -fullmutex 1
  1031   1031     sqlite3 db2 test.db -fullmutex 1
  1032   1032     execsql {
  1033   1033       CREATE TABLE t1(a, b, c);
  1034   1034       CREATE INDEX i1 ON t1(a, b);
  1035   1035       CREATE VIEW v1 AS SELECT * FROM t1; 
  1036   1036       CREATE VIEW v2 AS SELECT * FROM t1, v1 

Changes to test/shared2.test.

   125    125   db1 close
   126    126   db2 close
   127    127   
   128    128   do_test shared2-3.2 {
   129    129     sqlite3_enable_shared_cache 1
   130    130   } {1}
   131    131   
   132         -file delete -force test.db
          132  +forcedelete test.db
   133    133   
   134    134   sqlite3 db test.db
   135    135   do_test shared2-4.1 {
   136    136     execsql {
   137    137       CREATE TABLE t0(a, b);
   138    138       CREATE TABLE t1(a, b DEFAULT 'hello world');
   139    139     }

Changes to test/shared3.test.

    20     20     return
    21     21   }
    22     22   set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
    23     23   
    24     24   # Ticket #1824
    25     25   #
    26     26   do_test shared3-1.1 {
    27         -  file delete -force test.db test.db-journal
           27  +  forcedelete test.db test.db-journal
    28     28     sqlite3 db1 test.db
    29     29     db1 eval {
    30     30       PRAGMA encoding=UTF16;
    31     31       CREATE TABLE t1(x,y);
    32     32       INSERT INTO t1 VALUES('abc','This is a test string');
    33     33     }
    34     34     db1 close

Changes to test/shared4.test.

    26     26     return
    27     27   }
    28     28   set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
    29     29   
    30     30   # Prepare multiple databases in shared cache mode.
    31     31   #
    32     32   do_test shared4-1.1 {
    33         -  file delete -force test1.db test1.db-journal
    34         -  file delete -force test2.db test2.db-journal
    35         -  file delete -force test3.db test3.db-journal
    36         -  file delete -force test4.db test4.db-journal
           33  +  forcedelete test1.db test1.db-journal
           34  +  forcedelete test2.db test2.db-journal
           35  +  forcedelete test3.db test3.db-journal
           36  +  forcedelete test4.db test4.db-journal
    37     37     sqlite3 db1 test1.db
    38     38     sqlite3 db2 test2.db
    39     39     sqlite3 db3 test3.db
    40     40     sqlite3 db4 test4.db
    41     41     db1 eval {
    42     42       CREATE TABLE t1(a);
    43     43       INSERT INTO t1 VALUES(111);

Changes to test/shared6.test.

   231    231   do_test shared6-3.X {
   232    232     db1 close
   233    233     db2 close
   234    234     db3 close
   235    235   } {}
   236    236   
   237    237   do_test shared6-4.1 {
   238         -  #file delete -force test.db test.db-journal
          238  +  #forcedelete test.db test.db-journal
   239    239     sqlite3 db1 test.db
   240    240     sqlite3 db2 test.db
   241    241   
   242    242     set ::STMT [sqlite3_prepare_v2 db1 "SELECT * FROM t1" -1 DUMMY]
   243    243     execsql { CREATE TABLE t5(a, b) } db2
   244    244   } {}
   245    245   do_test shared6-4.2 {

Changes to test/shared7.test.

    31     31     }
    32     32     catchsql {
    33     33       ATTACH 'test.db' AS err1;
    34     34     }
    35     35   } {1 {database is already attached}}
    36     36   
    37     37   do_test shared7-1.3 {
    38         -  file delete -force test2.db test2.db-journal
           38  +  forcedelete test2.db test2.db-journal
    39     39     db eval {
    40     40       ATTACH 'test2.db' AS test2;
    41     41       CREATE TABLE test2.t2(y);
    42     42     }
    43     43     catchsql {
    44     44       ATTACH 'test2.db' AS err2;
    45     45     }

Changes to test/speed3.test.

   112    112       PRAGMA main.cache_size = 200000;
   113    113       PRAGMA main.auto_vacuum = 'incremental';
   114    114       ATTACH 'test2.db' AS 'aux'; 
   115    115       PRAGMA aux.auto_vacuum = 'none';
   116    116     }
   117    117   }
   118    118   
   119         -file delete -force test2.db test2.db-journal
          119  +forcedelete test2.db test2.db-journal
   120    120   reset_db
   121    121   
   122    122   # Set up a database in auto-vacuum mode and create a database schema.
   123    123   #
   124    124   do_test speed3-0.1 {
   125    125     execsql {
   126    126       CREATE TABLE main.t1(a INTEGER, b TEXT, c INTEGER);

Changes to test/sqllimits1.test.

   755    755   #--------------------------------------------------------------------
   756    756   # Test cases sqllimits1-12.*: Test the SQLITE_MAX_ATTACHED limit.
   757    757   #
   758    758   ifcapable attach {
   759    759     do_test sqllimits1-12.1 {
   760    760       set max $::SQLITE_MAX_ATTACHED
   761    761       for {set i 0} {$i < ($max)} {incr i} {
   762         -      file delete -force test${i}.db test${i}.db-journal
          762  +      forcedelete test${i}.db test${i}.db-journal
   763    763       }
   764    764       for {set i 0} {$i < ($max)} {incr i} {
   765    765         execsql "ATTACH 'test${i}.db' AS aux${i}"
   766    766       }
   767    767       catchsql "ATTACH 'test${i}.db' AS aux${i}"
   768    768     } "1 {too many attached databases - max $::SQLITE_MAX_ATTACHED}"
   769    769     do_test sqllimits1-12.2 {

Changes to test/stat.test.

   135    135     SELECT * FROM stat WHERE name = 't5' OR name = 'i5';
   136    136   } [list  \
   137    137     i5 / 5 leaf 0 0 1016 0 \
   138    138     t5 / 4 leaf 0 0 1016 0 \
   139    139   ]
   140    140   
   141    141   db close
   142         -file delete -force test.db
          142  +forcedelete test.db
   143    143   sqlite3 db test.db
   144    144   register_dbstat_vtab db
   145    145   breakpoint
   146    146   do_execsql_test stat-5.1 {
   147    147     PRAGMA auto_vacuum = OFF;
   148    148     CREATE VIRTUAL TABLE temp.stat USING dbstat;
   149    149     CREATE TABLE t1(x);

Changes to test/sync.test.

    38     38         incr sqlite_sync_count $adj
    39     39       }
    40     40     }
    41     41   }
    42     42   
    43     43   do_test sync-1.1 {
    44     44     set sqlite_sync_count 0
    45         -  file delete -force test2.db
    46         -  file delete -force test2.db-journal
           45  +  forcedelete test2.db
           46  +  forcedelete test2.db-journal
    47     47     execsql {
    48     48       PRAGMA fullfsync=OFF;
    49     49       CREATE TABLE t1(a,b);
    50     50       ATTACH DATABASE 'test2.db' AS db2;
    51     51       CREATE TABLE db2.t2(x,y);
    52     52     }
    53     53     cond_incr_sync_count 2

Changes to test/table.test.

   663    663     set result [list $rc $msg]
   664    664   } {1 {database table is locked}}
   665    665   
   666    666   ifcapable attach {
   667    667     # Now attach a database and ensure that a table can be created in the 
   668    668     # attached database whilst in a callback from a query on the main database.
   669    669     do_test table-14.3 {
   670         -    file delete -force test2.db
   671         -    file delete -force test2.db-journal
          670  +    forcedelete test2.db
          671  +    forcedelete test2.db-journal
   672    672       execsql {
   673    673         ATTACH 'test2.db' as aux;
   674    674       }
   675    675       db eval {SELECT * FROM tablet8 LIMIT 1} {} {
   676    676         db eval {CREATE TABLE aux.t1(a, b, c)}
   677    677       }
   678    678     } {}

Changes to test/temptable.test.

   400    400     db close
   401    401     sqlite3 db test.db
   402    402     catchsql {
   403    403       SELECT * FROM t8,t9;
   404    404     }
   405    405   } {1 {no such table: t9}}
   406    406   
   407         -file delete -force test2.db test2.db-journal
          407  +forcedelete test2.db test2.db-journal
   408    408   ifcapable attach {
   409    409     do_test temptable-7.1 {
   410    410       catchsql {
   411    411         ATTACH 'test2.db' AS two;
   412    412         CREATE TEMP TABLE two.abc(x,y);
   413    413       }
   414    414     } {1 {temporary table name must be unqualified}}
   415    415   }
   416    416   
   417    417   # Need to do the following for tcl 8.5 on mac. On that configuration, the
   418         -# -readonly flag is taken so seriously that a subsequent [file delete -force]
          418  +# -readonly flag is taken so seriously that a subsequent [forcedelete]
   419    419   # (required before the next test file can be executed) will fail.
   420    420   #
   421    421   catch {file attributes test.db -readonly 0}
   422    422   
   423    423   do_test temptable-8.0 {
   424    424     db close
   425         -  catch {file delete -force test.db}
          425  +  catch {forcedelete test.db}
   426    426     sqlite3 db test.db
   427    427   } {}
   428    428   do_test temptable-8.1 {
   429    429     execsql { CREATE TEMP TABLE tbl2(a, b); }
   430    430     execsql {
   431    431       CREATE TABLE tbl(a, b);
   432    432       INSERT INTO tbl VALUES(1, 2);

Changes to test/temptrigger.test.

   153    153   #                    connection. This forces [db] to reload the 'test2.db'
   154    154   #                    schema. Check that the temp trigger is still fired
   155    155   #                    correctly.
   156    156   #
   157    157   #   temptrigger-3.4: Check that the temp trigger can be dropped without error.
   158    158   # 
   159    159   do_test temptrigger-3.1 {
   160         -  catch { file delete -force test2.db test2.db-journal }
   161         -  catch { file delete -force test.db test.db-journal }
          160  +  catch { forcedelete test2.db test2.db-journal }
          161  +  catch { forcedelete test.db test.db-journal }
   162    162     sqlite3 db test.db 
   163    163     sqlite3 db2 test2.db 
   164    164     execsql { CREATE TABLE t2(a, b) } db2
   165    165     execsql {
   166    166       ATTACH 'test2.db' AS aux;
   167    167       CREATE TEMP TABLE tt2(a, b);
   168    168       CREATE TEMP TRIGGER tr2 AFTER INSERT ON aux.t2 BEGIN

Changes to test/tester.tcl.

    16     16   #-------------------------------------------------------------------------
    17     17   # The commands provided by the code in this file to help with creating 
    18     18   # test cases are as follows:
    19     19   #
    20     20   # Commands to manipulate the db and the file-system at a high level:
    21     21   #
    22     22   #      copy_file              FROM TO
           23  +#      delete_file            FILENAME
    23     24   #      drop_all_tables        ?DB?
           25  +#      forcecopy              FROM TO
    24     26   #      forcedelete            FILENAME
    25     27   #
    26     28   # Test the capability of the SQLite version built into the interpreter to
    27     29   # determine if a specific test can be run:
    28     30   #
    29     31   #      ifcapable              EXPR
    30     32   #
................................................................................
   118    120         # This command is not opening a new database connection. Pass the 
   119    121         # arguments through to the C implemenation as the are.
   120    122         #
   121    123         uplevel 1 sqlite_orig $args
   122    124       }
   123    125     }
   124    126   }
          127  +
          128  +proc getFileRetries {} {
          129  +  if {![info exists ::G(file-retries)]} {
          130  +    #
          131  +    # NOTE: Return the default number of retries for [file] operations.  A
          132  +    #       value of zero or less here means "disabled".
          133  +    #
          134  +    return [expr {$::tcl_platform(platform) eq "windows" ? 10 : 0}]
          135  +  }
          136  +  return $::G(file-retries)
          137  +}
          138  +
          139  +proc getFileRetryDelay {} {
          140  +  if {![info exists ::G(file-retry-delay)]} {
          141  +    #
          142  +    # NOTE: Return the default number of milliseconds to wait when retrying
          143  +    #       failed [file] operations.  A value of zero or less means "do not
          144  +    #       wait".
          145  +    #
          146  +    return 100; # TODO: Good default?
          147  +  }
          148  +  return $::G(file-retry-delay)
          149  +}
          150  +
          151  +# Copy file $from into $to. This is used because some versions of
          152  +# TCL for windows (notably the 8.4.1 binary package shipped with the
          153  +# current mingw release) have a broken "file copy" command.
          154  +#
          155  +proc copy_file {from to} {
          156  +  do_copy_file false $from $to
          157  +}
          158  +
          159  +proc forcecopy {from to} {
          160  +  do_copy_file true $from $to
          161  +}
          162  +
          163  +proc do_copy_file {force from to} {
          164  +  set nRetry [getFileRetries]     ;# Maximum number of retries.
          165  +  set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.
          166  +
          167  +  # On windows, sometimes even a [file copy -force] can fail. The cause is
          168  +  # usually "tag-alongs" - programs like anti-virus software, automatic backup
          169  +  # tools and various explorer extensions that keep a file open a little longer
          170  +  # than we expect, causing the delete to fail.
          171  +  #
          172  +  # The solution is to wait a short amount of time before retrying the copy.
          173  +  #
          174  +  if {$nRetry > 0} {
          175  +    for {set i 0} {$i<$nRetry} {incr i} {
          176  +      set rc [catch {
          177  +        if {$force} {
          178  +          file copy -force $from $to
          179  +        } else {
          180  +          file copy $from $to
          181  +        }
          182  +      } msg]
          183  +      if {$rc==0} break
          184  +      if {$nDelay > 0} { after $nDelay }
          185  +    }
          186  +    if {$rc} { error $msg }
          187  +  } else {
          188  +    if {$force} {
          189  +      file copy -force $from $to
          190  +    } else {
          191  +      file copy $from $to
          192  +    }
          193  +  }
          194  +}
          195  +
          196  +# Delete a file or directory
          197  +#
          198  +proc delete_file {args} {
          199  +  do_delete_file false {*}$args
          200  +}
          201  +
          202  +proc forcedelete {args} {
          203  +  do_delete_file true {*}$args
          204  +}
          205  +
          206  +proc do_delete_file {force args} {
          207  +  set nRetry [getFileRetries]     ;# Maximum number of retries.
          208  +  set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.
          209  +
          210  +  foreach filename $args {
          211  +    # On windows, sometimes even a [file delete -force] can fail just after
          212  +    # a file is closed. The cause is usually "tag-alongs" - programs like
          213  +    # anti-virus software, automatic backup tools and various explorer
          214  +    # extensions that keep a file open a little longer than we expect, causing
          215  +    # the delete to fail.
          216  +    #
          217  +    # The solution is to wait a short amount of time before retrying the
          218  +    # delete.
          219  +    #
          220  +    if {$nRetry > 0} {
          221  +      for {set i 0} {$i<$nRetry} {incr i} {
          222  +        set rc [catch {
          223  +          if {$force} {
          224  +            file delete -force $filename
          225  +          } else {
          226  +            file delete $filename
          227  +          }
          228  +        } msg]
          229  +        if {$rc==0} break
          230  +        if {$nDelay > 0} { after $nDelay }
          231  +      }
          232  +      if {$rc} { error $msg }
          233  +    } else {
          234  +      if {$force} {
          235  +        file delete -force $filename
          236  +      } else {
          237  +        file delete $filename
          238  +      }
          239  +    }
          240  +  }
          241  +}
   125    242   
   126    243   proc execpresql {handle args} {
   127    244     trace remove execution $handle enter [list execpresql $handle]
   128    245     if {[info exists ::G(perm:presql)]} {
   129    246       $handle eval $::G(perm:presql)
   130    247     }
   131    248   }
................................................................................
   150    267     #   --pause
   151    268     #   --soft-heap-limit=NN
   152    269     #   --maxerror=NN
   153    270     #   --malloctrace=N
   154    271     #   --backtrace=N
   155    272     #   --binarylog=N
   156    273     #   --soak=N
          274  +  #   --file-retries=N
          275  +  #   --file-retry-delay=N
   157    276     #   --start=[$permutation:]$testfile
   158    277     #
   159    278     set cmdlinearg(soft-heap-limit)    0
   160    279     set cmdlinearg(maxerror)        1000
   161    280     set cmdlinearg(malloctrace)        0
   162    281     set cmdlinearg(backtrace)         10
   163    282     set cmdlinearg(binarylog)          0
   164    283     set cmdlinearg(soak)               0
          284  +  set cmdlinearg(file-retries)       0
          285  +  set cmdlinearg(file-retry-delay)   0
   165    286     set cmdlinearg(start)             "" 
   166    287   
   167    288     set leftover [list]
   168    289     foreach a $argv {
   169    290       switch -regexp -- $a {
   170    291         {^-+pause$} {
   171    292           # Wait for user input before continuing. This is to give the user an 
................................................................................
   193    314         {^-+binarylog=.+$} {
   194    315           foreach {dummy cmdlinearg(binarylog)} [split $a =] break
   195    316         }
   196    317         {^-+soak=.+$} {
   197    318           foreach {dummy cmdlinearg(soak)} [split $a =] break
   198    319           set ::G(issoak) $cmdlinearg(soak)
   199    320         }
          321  +      {^-+file-retries=.+$} {
          322  +        foreach {dummy cmdlinearg(file-retries)} [split $a =] break
          323  +        set ::G(file-retries) $cmdlinearg(file-retries)
          324  +      }
          325  +      {^-+file-retry-delay=.+$} {
          326  +        foreach {dummy cmdlinearg(file-retry-delay)} [split $a =] break
          327  +        set ::G(file-retry-delay) $cmdlinearg(file-retry-delay)
          328  +      }
   200    329         {^-+start=.+$} {
   201    330           foreach {dummy cmdlinearg(start)} [split $a =] break
   202    331   
   203    332           set ::G(start:file) $cmdlinearg(start)
   204    333           if {[regexp {(.*):(.*)} $cmdlinearg(start) -> s.perm s.file]} {
   205    334             set ::G(start:permutation) ${s.perm}
   206    335             set ::G(start:file)        ${s.file}
................................................................................
   242    371   #
   243    372   sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
   244    373   
   245    374   # Create a test database
   246    375   #
   247    376   proc reset_db {} {
   248    377     catch {db close}
   249         -  file delete -force test.db
   250         -  file delete -force test.db-journal
   251         -  file delete -force test.db-wal
          378  +  forcedelete test.db
          379  +  forcedelete test.db-journal
          380  +  forcedelete test.db-wal
   252    381     sqlite3 db ./test.db
   253    382     set ::DB [sqlite3_connection_pointer db]
   254    383     if {[info exists ::SETUP_SQL]} {
   255    384       db eval $::SETUP_SQL
   256    385     }
   257    386   }
   258    387   reset_db
................................................................................
   618    747       if {[sqlite3_memory_used]>0} {
   619    748         puts "Writing leaks.sql..."
   620    749         sqlite3_memdebug_log sync
   621    750         memdebug_log_sql leaks.sql
   622    751       }
   623    752     }
   624    753     foreach f [glob -nocomplain test.db-*-journal] {
   625         -    file delete -force $f
          754  +    forcedelete $f
   626    755     }
   627    756     foreach f [glob -nocomplain test.db-mj*] {
   628         -    file delete -force $f
          757  +    forcedelete $f
   629    758     }
   630    759     exit [expr {$nErr>0}]
   631    760   }
   632    761   
   633    762   # Display memory statistics for analysis and debugging purposes.
   634    763   #
   635    764   proc show_memstats {} {
................................................................................
   736    865       if {[catch {sqlite3_finalize $vm} errmsg]} {
   737    866         return [list 1 $errmsg]
   738    867       }
   739    868     }
   740    869     return $r
   741    870   }
   742    871   
   743         -# Delete a file or directory
   744         -#
   745         -proc forcedelete {args} {
   746         -  foreach filename $args {
   747         -    # On windows, sometimes even a [file delete -force] can fail just after
   748         -    # a file is closed. The cause is usually "tag-alongs" - programs like
   749         -    # anti-virus software, automatic backup tools and various explorer
   750         -    # extensions that keep a file open a little longer than we expect, causing
   751         -    # the delete to fail.
   752         -    #
   753         -    # The solution is to wait a short amount of time before retrying the 
   754         -    # delete.
   755         -    #
   756         -    set nRetry  50                  ;# Maximum number of retries.
   757         -    set nDelay 100                  ;# Delay in ms before retrying.
   758         -    for {set i 0} {$i<$nRetry} {incr i} {
   759         -      set rc [catch {file delete -force $filename} msg]
   760         -      if {$rc==0} break
   761         -      after $nDelay
   762         -    }
   763         -    if {$rc} { error $msg }
   764         -  }
   765         -}
   766         -
   767    872   # Do an integrity check of the entire database
   768    873   #
   769    874   proc integrity_check {name {db db}} {
   770    875     ifcapable integrityck {
   771    876       do_test $name [list execsql {PRAGMA integrity_check} $db] {ok}
   772    877     }
   773    878   }
................................................................................
   960   1065   
   961   1066       # Delete the files test.db and test2.db, then execute the TCL and 
   962   1067       # SQL (in that order) to prepare for the test case.
   963   1068       do_test $testname.$n.1 {
   964   1069         set ::sqlite_io_error_pending 0
   965   1070         catch {db close}
   966   1071         catch {db2 close}
   967         -      catch {file delete -force test.db}
   968         -      catch {file delete -force test.db-journal}
   969         -      catch {file delete -force test2.db}
   970         -      catch {file delete -force test2.db-journal}
         1072  +      catch {forcedelete test.db}
         1073  +      catch {forcedelete test.db-journal}
         1074  +      catch {forcedelete test2.db}
         1075  +      catch {forcedelete test2.db-journal}
   971   1076         set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
   972   1077         sqlite3_extended_result_codes $::DB $::ioerropts(-erc)
   973   1078         if {[info exists ::ioerropts(-tclprep)]} {
   974   1079           eval $::ioerropts(-tclprep)
   975   1080         }
   976   1081         if {[info exists ::ioerropts(-sqlprep)]} {
   977   1082           execsql $::ioerropts(-sqlprep)
................................................................................
  1237   1342     }
  1238   1343   
  1239   1344     set fd [open $filename w]
  1240   1345     puts $fd "BEGIN; ${tbl}${tbl2}${tbl3}${sql} ; COMMIT;"
  1241   1346     close $fd
  1242   1347   }
  1243   1348   
  1244         -# Copy file $from into $to. This is used because some versions of
  1245         -# TCL for windows (notably the 8.4.1 binary package shipped with the
  1246         -# current mingw release) have a broken "file copy" command.
  1247         -#
  1248         -proc copy_file {from to} {
  1249         -  if {$::tcl_platform(platform)=="unix"} {
  1250         -    file copy -force $from $to
  1251         -  } else {
  1252         -    set f [open $from]
  1253         -    fconfigure $f -translation binary
  1254         -    set t [open $to w]
  1255         -    fconfigure $t -translation binary
  1256         -    puts -nonewline $t [read $f [file size $from]]
  1257         -    close $t
  1258         -    close $f
  1259         -  }
  1260         -}
  1261         -
  1262   1349   # Drop all tables in database [db]
  1263   1350   proc drop_all_tables {{db db}} {
  1264   1351     ifcapable trigger&&foreignkey {
  1265   1352       set pk [$db one "PRAGMA foreign_keys"]
  1266   1353       $db eval "PRAGMA foreign_keys = OFF"
  1267   1354     }
  1268   1355     foreach {idx name file} [db eval {PRAGMA database_list}] {
................................................................................
  1436   1523     return ""
  1437   1524   }
  1438   1525   
  1439   1526   proc db_save {} {
  1440   1527     foreach f [glob -nocomplain sv_test.db*] { forcedelete $f }
  1441   1528     foreach f [glob -nocomplain test.db*] {
  1442   1529       set f2 "sv_$f"
  1443         -    file copy -force $f $f2
         1530  +    forcecopy $f $f2
  1444   1531     }
  1445   1532   }
  1446   1533   proc db_save_and_close {} {
  1447   1534     db_save
  1448   1535     catch { db close }
  1449   1536     return ""
  1450   1537   }
  1451   1538   proc db_restore {} {
  1452   1539     foreach f [glob -nocomplain test.db*] { forcedelete $f }
  1453   1540     foreach f2 [glob -nocomplain sv_test.db*] {
  1454   1541       set f [string range $f2 3 end]
  1455         -    file copy -force $f2 $f
         1542  +    forcecopy $f2 $f
  1456   1543     }
  1457   1544   }
  1458   1545   proc db_restore_and_reopen {{dbfile test.db}} {
  1459   1546     catch { db close }
  1460   1547     db_restore
  1461   1548     sqlite3 db $dbfile
  1462   1549   }
  1463   1550   proc db_delete_and_reopen {{file test.db}} {
  1464   1551     catch { db close }
  1465         -  foreach f [glob -nocomplain test.db*] { file delete -force $f }
         1552  +  foreach f [glob -nocomplain test.db*] { forcedelete $f }
  1466   1553     sqlite3 db $file
  1467   1554   }
  1468   1555   
  1469   1556   # If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
  1470   1557   # to non-zero, then set the global variable $AUTOVACUUM to 1.
  1471   1558   set AUTOVACUUM $sqlite_options(default_autovacuum)
  1472   1559   
  1473   1560   source $testdir/thread_common.tcl
  1474   1561   source $testdir/malloc_common.tcl

Changes to test/thread002.test.

    23     23   set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
    24     24   
    25     25   set ::NTHREAD 10
    26     26   
    27     27   do_test thread002.1 {
    28     28     # Create 3 databases with identical schemas:
    29     29     for {set ii 0} {$ii < 3} {incr ii} {
    30         -    file delete -force test${ii}.db
           30  +    forcedelete test${ii}.db
    31     31       sqlite3 db test${ii}.db
    32     32       execsql {
    33     33         CREATE TABLE t1(k, v);
    34     34         CREATE INDEX t1_i ON t1(v);
    35     35         INSERT INTO t1(v) VALUES(1.0);
    36     36       }
    37     37       db close

Changes to test/thread003.test.

    36     36     }
    37     37   } {}
    38     38   do_test thread003.1.2 {
    39     39     expr {([file size test.db] / 1024) > 2000}
    40     40   } {1}
    41     41   do_test thread003.1.3 {
    42     42     db close
    43         -  file delete -force test2.db
           43  +  forcedelete test2.db
    44     44     sqlite3 db test2.db
    45     45   } {}
    46     46   do_test thread003.1.4 {
    47     47     execsql {
    48     48       BEGIN;
    49     49       CREATE TABLE t1(a, b, c);
    50     50     }

Changes to test/thread005.test.

   117    117   # when using an ATTACHed database. There doesn't seem to be any reason
   118    118   # for this, other than that operating on an ATTACHed database means there
   119    119   # are a few more mutex grabs and releases during the window of time open
   120    120   # for the race-condition. Maybe this encourages the scheduler to context
   121    121   # switch or something...
   122    122   #
   123    123   
   124         -file delete -force test.db test2.db
          124  +forcedelete test.db test2.db
   125    125   unset -nocomplain finished
   126    126   
   127    127   do_test thread005-2.1 {
   128    128     sqlite3 db test.db
   129    129     execsql { ATTACH 'test2.db' AS aux }
   130    130     execsql {
   131    131       CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b UNIQUE);

Changes to test/tkt-2d1a5c67d.test.

   114    114     execsql { SELECT * FROM t4 WHERE a = 'xyz' }
   115    115   } {xyz}
   116    116   
   117    117   # Check that recovery works on the WAL file.
   118    118   #
   119    119   forcedelete test.db2-wal test.db2
   120    120   do_test 3.6 {
   121         -  file copy test.db-wal test.db2-wal
   122         -  file copy test.db test.db2
          121  +  copy_file test.db-wal test.db2-wal
          122  +  copy_file test.db test.db2
   123    123     sqlite3 db2 test.db2
   124    124     execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2
   125    125   } {xyz}
   126    126   
   127    127   finish_test

Changes to test/tkt-5ee23731f.test.

    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   do_test tkt-5ee237-1.1 {
    21     21     db close
    22         -  file delete -force test.db
           22  +  forcedelete test.db
    23     23     sqlite3 db test.db
    24     24     db eval {
    25     25       CREATE TABLE t1(x UNIQUE);
    26     26       INSERT INTO t1 VALUES(1);
    27     27       INSERT INTO t1 VALUES(2);
    28     28       INSERT INTO t1 SELECT x+2 FROM t1;
    29     29       INSERT INTO t1 SELECT x+4 FROM t1;

Changes to test/tkt-f3e5abed55.test.

    10     10   #***********************************************************************
    11     11   #
    12     12   
    13     13   set testdir [file dirname $argv0]
    14     14   source $testdir/tester.tcl
    15     15   source $testdir/malloc_common.tcl
    16     16   
    17         -foreach f [glob -nocomplain test.db*mj*] { file delete -force $f }
    18         -file delete -force test.db2
           17  +foreach f [glob -nocomplain test.db*mj*] { forcedelete $f }
           18  +forcedelete test.db2
    19     19   
    20     20   do_test tkt-f3e5abed55-1.1 {
    21     21     execsql {
    22     22       ATTACH 'test.db2' AS aux;
    23     23       CREATE TABLE main.t1(a, b);
    24     24       CREATE TABLE aux.t2(c, d);
    25     25     }
................................................................................
    47     47     execsql COMMIT db2
    48     48     execsql COMMIT
    49     49   } {}
    50     50   
    51     51   do_test tkt-f3e5abed55-1.6 {
    52     52     glob -nocomplain test.db*mj*
    53     53   } {}
    54         -foreach f [glob -nocomplain test.db*mj*] { file delete -force $f }
           54  +foreach f [glob -nocomplain test.db*mj*] { forcedelete $f }
    55     55   db close
    56     56   db2 close
    57     57   
    58     58   
    59     59   
    60     60   # Set up a testvfs so that the next time SQLite tries to delete the
    61     61   # file "test.db-journal", a snapshot of the current file-system contents

Changes to test/tkt1667.test.

    21     21   
    22     22   ifcapable !autovacuum||!tclvar {
    23     23     finish_test
    24     24     return
    25     25   }
    26     26   
    27     27   db close
    28         -file delete -force test.db test.db-journal
           28  +forcedelete test.db test.db-journal
    29     29   
    30     30   # Set the pending byte offset such that the page it is on is
    31     31   # the first autovacuum pointer map page in the file (assume a page 
    32     32   # size of 1024).
    33     33   
    34     34   set first_ptrmap_page   [expr 1024/5 + 3]
    35     35   sqlite3_test_control_pending_byte [expr 1024 * ($first_ptrmap_page-1)]

Changes to test/tkt1873.test.

    20     20   source $testdir/tester.tcl
    21     21   
    22     22   ifcapable !attach {
    23     23     finish_test
    24     24     return
    25     25   }
    26     26   
    27         -file delete -force test2.db test2.db-journal
           27  +forcedelete test2.db test2.db-journal
    28     28   
    29     29   do_test tkt1873-1.1 {
    30     30     execsql {
    31     31       CREATE TABLE t1(x, y);
    32     32       ATTACH 'test2.db' AS aux;
    33     33       CREATE TABLE aux.t2(x, y);
    34     34       INSERT INTO t1 VALUES(1, 2);

Changes to test/tkt2686.test.

    45     45       }
    46     46     } {}
    47     47     integrity_check tkt2686-$i.3
    48     48     catch {db eval COMMIT}
    49     49   }
    50     50   
    51     51   db close
    52         -file delete -force test.db test.db-journal
           52  +forcedelete test.db test.db-journal
    53     53   sqlite3 db test.db
    54     54   
    55     55   db eval {
    56     56     PRAGMA page_size=1024;
    57     57     PRAGMA max_page_count=50;
    58     58     PRAGMA auto_vacuum=1;
    59     59     CREATE TABLE filler (fill);

Changes to test/tkt2817.test.

    44     44   
    45     45   
    46     46   # These tests - tkt2817-2.* - are the same as the previous block, except
    47     47   # for the fact that the temp-table and the main table do not share the
    48     48   # same name. #2817 did not cause a problem with these tests.
    49     49   #
    50     50   db close
    51         -file delete -force test.db
           51  +forcedelete test.db
    52     52   sqlite3 db test.db
    53     53   do_test tkt2817-2.0 {
    54     54     execsql {
    55     55       CREATE TEMP TABLE tmp(a, b, c);
    56     56       INSERT INTO tmp VALUES(1, 'abc', 'def');
    57     57       INSERT INTO tmp VALUES(2, 'ghi', 'jkl');
    58     58     }

Changes to test/tkt2820.test.

    21     21   #
    22     22   
    23     23   set testdir [file dirname $argv0]
    24     24   source $testdir/tester.tcl
    25     25   
    26     26   proc test_schema_change {testid init ddl res} {
    27     27     db close
    28         -  file delete -force test.db test.db-journal
           28  +  forcedelete test.db test.db-journal
    29     29     sqlite3 db test.db
    30     30     execsql $init
    31     31     do_test tkt2820-$testid.1 {
    32     32       set STMT [sqlite3_prepare db {SELECT * FROM sqlite_master} -1 DUMMY]
    33     33       sqlite3_step $STMT
    34     34     } {SQLITE_ROW}
    35     35   #if {$testid==3} {execsql {PRAGMA vdbe_trace=ON}}
................................................................................
    66     66   # We further observe that prior to the fix associated with ticket #2820,
    67     67   # no statement journal would be created on an SQL statement that was run
    68     68   # while a second statement was active, as long as we are in autocommit
    69     69   # mode.  This is incorrect.
    70     70   #
    71     71   do_test tkt2820-4.1 {
    72     72     db close
    73         -  file delete -force test.db test.db-journal
           73  +  forcedelete test.db test.db-journal
    74     74     sqlite3 db test.db
    75     75     db eval {
    76     76       CREATE TABLE t1(a INTEGER PRIMARY KEY);
    77     77       INSERT INTO t1 VALUES(1);
    78     78       INSERT INTO t1 VALUES(2);
    79     79     }
    80     80   

Changes to test/tkt2854.test.

   124    124     execsql { SELECT * FROM abc } db2
   125    125   } {}
   126    126   
   127    127   # Check that if an attempt to obtain an exclusive lock fails because an
   128    128   # attached db cannot be locked, the internal exclusive flag used by
   129    129   # shared-cache users is correctly cleared.
   130    130   do_test tkt2854-1.19 {
   131         -  file delete -force test2.db test2.db-journal
          131  +  forcedelete test2.db test2.db-journal
   132    132     sqlite3 db4 test2.db
   133    133     execsql { CREATE TABLE def(d, e, f) } db4
   134    134     execsql { ATTACH 'test2.db' AS aux } db
   135    135   } {}
   136    136   do_test tkt2854-1.20 {
   137    137     execsql {BEGIN IMMEDIATE} db4
   138    138     catchsql {BEGIN EXCLUSIVE} db

Changes to test/tkt3457.test.

    42     42     execsql {
    43     43       CREATE TABLE t1(a, b, c);
    44     44       INSERT INTO t1 VALUES(1, 2, 3);
    45     45       BEGIN;
    46     46       INSERT INTO t1 VALUES(4, 5, 6);
    47     47     }
    48     48   
    49         -  file copy -force test.db bak.db
    50         -  file copy -force test.db-journal bak.db-journal
           49  +  forcecopy test.db bak.db
           50  +  forcecopy test.db-journal bak.db-journal
    51     51   
    52     52     # Fix the first journal-header in the journal-file. Because the
    53     53     # journal file has not yet been synced, the 8-byte magic string at the
    54     54     # start of the first journal-header has not been written by SQLite.
    55     55     # So write it now.
    56     56     set fd [open bak.db-journal a+]
    57     57     fconfigure $fd -encoding binary -translation binary
................................................................................
    59     59     puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
    60     60     close $fd
    61     61   
    62     62     execsql COMMIT
    63     63   } {}
    64     64   
    65     65   do_test tkt3457-1.2 {
    66         -  file copy -force bak.db-journal test.db-journal
           66  +  forcecopy bak.db-journal test.db-journal
    67     67     file attributes test.db-journal -permissions ---------
    68     68     catchsql { SELECT * FROM t1 }
    69     69   } {1 {unable to open database file}}
    70     70   do_test tkt3457-1.3 {
    71         -  file copy -force bak.db-journal test.db-journal
           71  +  forcecopy bak.db-journal test.db-journal
    72     72     file attributes test.db-journal -permissions -w--w--w-
    73     73     catchsql { SELECT * FROM t1 }
    74     74   } {1 {unable to open database file}}
    75     75   do_test tkt3457-1.4 {
    76         -  file copy -force bak.db-journal test.db-journal
           76  +  forcecopy bak.db-journal test.db-journal
    77     77     file attributes test.db-journal -permissions r--r--r--
    78     78     catchsql { SELECT * FROM t1 }
    79     79   } {1 {unable to open database file}}
    80     80   
    81     81   do_test tkt3457-1.5 {
    82         -  file copy -force bak.db-journal test.db-journal
           82  +  forcecopy bak.db-journal test.db-journal
    83     83     file attributes test.db-journal -permissions rw-rw-rw-
    84     84     catchsql { SELECT * FROM t1 }
    85     85   } {0 {1 2 3 4 5 6}}
    86     86   
    87     87   finish_test

Changes to test/tkt35xx.test.

    46     46       INSERT INTO t1 VALUES(1, 1, zeroblob(676));
    47     47     }
    48     48   } {}
    49     49   
    50     50   # Trigger the problem using statement rollback.
    51     51   #
    52     52   db close
    53         -file delete test.db
           53  +delete_file test.db
    54     54   sqlite3 db test.db
    55     55   set big [string repeat abcdefghij 22]    ;# 220 byte string
    56     56   do_test tkt35xx-1.2.1 {
    57     57     execsql {
    58     58       PRAGMA auto_vacuum = 0;
    59     59       PRAGMA page_size = 1024;
    60     60       CREATE TABLE t3(a INTEGER PRIMARY KEY, b);

Changes to test/trigger1.test.

   530    530   # correctly re-installed.
   531    531   #
   532    532   # Also verify that references within trigger programs are resolved at
   533    533   # statement compile time, not trigger installation time. This means, for
   534    534   # example, that you can drop and re-create tables referenced by triggers. 
   535    535   ifcapable tempdb&&attach {
   536    536     do_test trigger1-10.0 {
   537         -    file delete -force test2.db
   538         -    file delete -force test2.db-journal
          537  +    forcedelete test2.db
          538  +    forcedelete test2.db-journal
   539    539       execsql {
   540    540         ATTACH 'test2.db' AS aux;
   541    541       }
   542    542     } {}
   543    543     do_test trigger1-10.1 {
   544    544       execsql {
   545    545         CREATE TABLE main.t4(a, b, c);

Changes to test/trigger4.test.

   126    126       update test set b=99 where id=7;
   127    127       select * from test2;
   128    128     }
   129    129   } {7 99}
   130    130   
   131    131   do_test trigger4-4.1 {
   132    132       db close
   133         -    file delete -force trigtest.db
   134         -    file delete -force trigtest.db-journal
          133  +    forcedelete trigtest.db
          134  +    forcedelete trigtest.db-journal
   135    135       sqlite3 db trigtest.db
   136    136       catchsql {drop table tbl; drop view vw}
   137    137       execsql {
   138    138   	create table tbl(a integer primary key, b integer);
   139    139   	create view vw as select * from tbl;
   140    140   	create trigger t_del_tbl instead of delete on vw for each row begin
   141    141   	  delete from tbl where a = old.a;
................................................................................
   191    191   } {0 {}}
   192    192   do_test trigger4-7.2 {
   193    193       execsql {select a, b from vw where a<=102 or a>=227 order by a}
   194    194   } {101 1001 102 2002 227 2127 228 2128}
   195    195   
   196    196   integrity_check trigger4-99.9
   197    197   db close
   198         -file delete -force trigtest.db trigtest.db-journal
          198  +forcedelete trigtest.db trigtest.db-journal
   199    199   
   200    200   finish_test

Changes to test/triggerA.test.

   201    201      return
   202    202   }
   203    203   source $testdir/malloc_common.tcl
   204    204   
   205    205   # Save a copy of the current database configuration.
   206    206   #
   207    207   db close
   208         -file delete -force test.db-triggerA
   209         -file copy test.db test.db-triggerA
          208  +forcedelete test.db-triggerA
          209  +copy_file test.db test.db-triggerA
   210    210   sqlite3 db test.db
   211    211   
   212    212   # Run malloc tests on the INSTEAD OF trigger firing.
   213    213   #
   214    214   do_malloc_test triggerA-3 -tclprep {
   215    215     db close
   216         -  file delete -force test.db test.db-journal
   217         -  file copy -force test.db-triggerA test.db
          216  +  forcedelete test.db test.db-journal
          217  +  forcecopy test.db-triggerA test.db
   218    218     sqlite3 db test.db
   219    219     sqlite3_extended_result_codes db 1  
   220    220     db eval {SELECT * FROM v5; -- warm up the cache}
   221    221   } -sqlbody {
   222    222      DELETE FROM v5 WHERE x=5;
   223    223      UPDATE v5 SET b=b+9900000 WHERE x BETWEEN 3 AND 5;
   224    224   }
   225    225   
   226    226   # Clean up the saved database copy.
   227    227   #
   228         -file delete -force test.db-triggerA
          228  +forcedelete test.db-triggerA
   229    229   
   230    230   finish_test

Changes to test/triggerC.test.

   914    914       INSERT INTO v2 DEFAULT VALUES;
   915    915       SELECT a, b, a IS NULL, b IS NULL FROM log;
   916    916     }
   917    917   } {{} {} 1 1}
   918    918   
   919    919   do_test triggerC-12.1 {
   920    920     db close
   921         -  file delete -force test.db
          921  +  forcedelete test.db
   922    922     sqlite3 db test.db
   923    923   
   924    924     execsql {
   925    925       CREATE TABLE t1(a, b);
   926    926       INSERT INTO t1 VALUES(1, 2);
   927    927       INSERT INTO t1 VALUES(3, 4);
   928    928       INSERT INTO t1 VALUES(5, 6);

Changes to test/triggerD.test.

   189    189   # the sqlite_master table.  We cannot fix the bug simply by disallowing
   190    190   # "xyz.tab" since that could break legacy applications.  We have to 
   191    191   # fix the system so that the "xyz." on "xyz.tab" is ignored.
   192    192   # Verify that this is the case.
   193    193   #
   194    194   do_test triggerD-4.1 {
   195    195     db close
   196         -  file delete -force test.db test2.db
          196  +  forcedelete test.db test2.db
   197    197     sqlite3 db test.db
   198    198     db eval {
   199    199       CREATE TABLE t1(x);
   200    200       ATTACH 'test2.db' AS db2;
   201    201       CREATE TABLE db2.t2(y);
   202    202       CREATE TABLE db2.log(z);
   203    203       CREATE TRIGGER db2.trig AFTER INSERT ON db2.t2 BEGIN

Changes to test/vacuum.test.

   204    204   
   205    205   # Ticket #427.  Make sure VACUUM works when the EMPTY_RESULT_CALLBACKS
   206    206   # pragma is turned on.
   207    207   #
   208    208   do_test vacuum-3.1 {
   209    209     db close
   210    210     db2 close
   211         -  file delete test.db
          211  +  delete_file test.db
   212    212     sqlite3 db test.db
   213    213     execsql {
   214    214       PRAGMA empty_result_callbacks=on;
   215    215       VACUUM;
   216    216     }
   217    217   } {}
   218    218   
................................................................................
   230    230   
   231    231   # Ticket #515.  VACUUM after deleting and recreating the table that
   232    232   # a view refers to. Omit this test if the library is not view-enabled.
   233    233   #
   234    234   ifcapable view {
   235    235   do_test vacuum-5.1 {
   236    236     db close
   237         -  file delete -force test.db
          237  +  forcedelete test.db
   238    238     sqlite3 db test.db
   239    239     catchsql {
   240    240       CREATE TABLE Test (TestID int primary key);
   241    241       INSERT INTO Test VALUES (NULL);
   242    242       CREATE VIEW viewTest AS SELECT * FROM Test;
   243    243   
   244    244       BEGIN;
................................................................................
   286    286       execsql {
   287    287         select count(*) from "abc abc" WHERE a = X'00112233';
   288    288       }
   289    289     } {1}
   290    290   }
   291    291   
   292    292   # Check what happens when an in-memory database is vacuumed. The
   293         -# [file delete] command covers us in case the library was compiled
          293  +# [delete_file] command covers us in case the library was compiled
   294    294   # without in-memory database support.
   295    295   #
   296         -file delete -force :memory:
          296  +forcedelete :memory:
   297    297   do_test vacuum-7.0 {
   298    298     sqlite3 db2 :memory:
   299    299     execsql {
   300    300       CREATE TABLE t1(t);
   301    301       VACUUM;
   302    302     } db2
   303    303   } {}
................................................................................
   333    333     } {1}
   334    334   }
   335    335   db2 close
   336    336   
   337    337   # Ticket #873.  VACUUM a database that has ' in its name.
   338    338   #
   339    339   do_test vacuum-8.1 {
   340         -  file delete -force a'z.db
   341         -  file delete -force a'z.db-journal
          340  +  forcedelete a'z.db
          341  +  forcedelete a'z.db-journal
   342    342     sqlite3 db2 a'z.db
   343    343     execsql {
   344    344       CREATE TABLE t1(t);
   345    345       VACUUM;
   346    346     } db2
   347    347   } {}
   348    348   db2 close
................................................................................
   379    379       execsql {
   380    380         VACUUM;
   381    381       }
   382    382       cksum
   383    383     } $::cksum
   384    384   }
   385    385   
   386         -file delete -force {a'z.db}
          386  +forcedelete {a'z.db}
   387    387   
   388    388   finish_test

Changes to test/vacuum2.test.

   131    131   } {ok}
   132    132   
   133    133   db2 close
   134    134   
   135    135   ifcapable autovacuum {
   136    136     do_test vacuum2-4.1 {
   137    137       db close
   138         -    file delete -force test.db
          138  +    forcedelete test.db
   139    139       sqlite3 db test.db
   140    140       execsql {
   141    141         pragma auto_vacuum=1;
   142    142         create table t(a, b);
   143    143         insert into t values(1, 2);
   144    144         insert into t values(1, 2);
   145    145         pragma auto_vacuum=0;

Changes to test/vacuum3.test.

   192    192     integrity_check vacuum3-3.$I.3
   193    193   
   194    194     incr I
   195    195   }
   196    196   
   197    197   do_test vacuum3-4.1 {
   198    198     db close
   199         -  file delete test.db
          199  +  delete_file test.db
   200    200     sqlite3 db test.db
   201    201     execsql {
   202    202       PRAGMA page_size=1024;
   203    203       CREATE TABLE abc(a, b, c);
   204    204       INSERT INTO abc VALUES(1, 2, 3);
   205    205       INSERT INTO abc VALUES(4, 5, 6);
   206    206     }

Changes to test/view.test.

   454    454     catchsql {
   455    455       CREATE VIEW v12 AS SELECT a FROM t1 WHERE b=?
   456    456     }
   457    457   } {1 {parameters are not allowed in views}}
   458    458   
   459    459   ifcapable attach {
   460    460     do_test view-13.1 {
   461         -    file delete -force test2.db
          461  +    forcedelete test2.db
   462    462       catchsql {
   463    463         ATTACH 'test2.db' AS two;
   464    464         CREATE TABLE two.t2(x,y);
   465    465         CREATE VIEW v13 AS SELECT y FROM two.t2;
   466    466       }
   467    467     } {1 {view v13 cannot reference objects in database two}}
   468    468   }

Changes to test/vtab1.test.

   720    720   do_test vtab1-6-8.4 {
   721    721     execsql {
   722    722       SELECT * FROM techo ORDER BY a;
   723    723     }
   724    724   } {}
   725    725   execsql {PRAGMA count_changes=OFF}
   726    726   
   727         -file delete -force test2.db
   728         -file delete -force test2.db-journal
          727  +forcedelete test2.db
          728  +forcedelete test2.db-journal
   729    729   sqlite3 db2 test2.db
   730    730   execsql {
   731    731     CREATE TABLE techo(a PRIMARY KEY, b, c);
   732    732   } db2
   733    733   proc check_echo_table {tn} {
   734    734     set ::data1 [execsql {SELECT rowid, * FROM techo}]
   735    735     set ::data2 [execsql {SELECT rowid, * FROM techo} db2]

Changes to test/vtab7.test.

   130    130     set ::rc
   131    131   } {1 {database table is locked}}
   132    132   execsql {DROP TABLE newtab}
   133    133   
   134    134   # Write to an attached database from xSync().
   135    135   ifcapable attach {
   136    136     do_test vtab7-3.1 {
   137         -    file delete -force test2.db
   138         -    file delete -force test2.db-journal
          137  +    forcedelete test2.db
          138  +    forcedelete test2.db-journal
   139    139       execsql {
   140    140         ATTACH 'test2.db' AS db2;
   141    141         CREATE TABLE db2.stuff(description, shape, color);
   142    142       }
   143    143       set ::callbacks(xSync,abc) {
   144    144         execsql { INSERT INTO db2.stuff VALUES('abc', 'square', 'green'); }
   145    145       }

Changes to test/vtabC.test.

    27     27   
    28     28   
    29     29   # N will be the number of virtual tables we have defined.
    30     30   #
    31     31   unset -nocomplain N
    32     32   for {set N 1} {$N<=20} {incr N} {
    33     33     db close
    34         -  file delete -force test.db test.db-journal
           34  +  forcedelete test.db test.db-journal
    35     35     sqlite3 db test.db
    36     36     register_echo_module [sqlite3_connection_pointer db]
    37     37   
    38     38     # Create $N tables and $N virtual tables to echo them.
    39     39     #
    40     40     unset -nocomplain tablist
    41     41     set tablist {}

Changes to test/wal.test.

    21     21   
    22     22   set testprefix wal
    23     23   
    24     24   ifcapable !wal {finish_test ; return }
    25     25   
    26     26   proc reopen_db {} {
    27     27     catch { db close }
    28         -  file delete -force test.db test.db-wal test.db-wal-summary
           28  +  forcedelete test.db test.db-wal test.db-wal-summary
    29     29     sqlite3_wal db test.db
    30     30   }
    31     31   
    32     32   set ::blobcnt 0
    33     33   proc blob {nByte} {
    34     34     incr ::blobcnt
    35     35     return [string range [string repeat "${::blobcnt}x" $nByte] 1 $nByte]
................................................................................
   207    207     }
   208    208     expr { $logsize == [file size test.db-wal] }
   209    209   } {1}
   210    210   do_test wal-4.4.5 {
   211    211     execsql { SELECT count(*) FROM t2 }
   212    212   } {1}
   213    213   do_test wal-4.4.6 {
   214         -  file copy -force test.db test2.db
   215         -  file copy -force test.db-wal test2.db-wal
          214  +  forcecopy test.db test2.db
          215  +  forcecopy test.db-wal test2.db-wal
   216    216     sqlite3 db2 test2.db
   217    217     execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2
   218    218   } {1 2}
   219    219   do_test wal-4.4.7 {
   220    220     execsql { PRAGMA integrity_check } db2
   221    221   } {ok}
   222    222   db2 close
................................................................................
   265    265     }
   266    266     expr { $logsize == [file size test.db-wal] }
   267    267   } {1}
   268    268   do_test wal-4.5.5 {
   269    269     execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 }
   270    270   } {1 2}
   271    271   do_test wal-4.5.6 {
   272         -  file copy -force test.db test2.db
   273         -  file copy -force test.db-wal test2.db-wal
          272  +  forcecopy test.db test2.db
          273  +  forcecopy test.db-wal test2.db-wal
   274    274     sqlite3 db2 test2.db
   275    275     execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2
   276    276   } {1 2}
   277    277   do_test wal-4.5.7 {
   278    278     execsql { PRAGMA integrity_check } db2
   279    279   } {ok}
   280    280   db2 close
................................................................................
   330    330     }
   331    331   } {1 2 3 4}
   332    332   db close
   333    333   
   334    334   foreach sector {512 4096} {
   335    335     sqlite3_simulate_device -sectorsize $sector
   336    336     foreach pgsz {512 1024 2048 4096} {
   337         -    file delete -force test.db test.db-wal
          337  +    forcedelete test.db test.db-wal
   338    338       do_test wal-6.$sector.$pgsz.1 {
   339    339         sqlite3 db test.db -vfs devsym
   340    340         execsql "
   341    341           PRAGMA page_size = $pgsz;
   342    342           PRAGMA auto_vacuum = 0;
   343    343           PRAGMA journal_mode = wal;
   344    344         "
................................................................................
   353    353       do_test wal-6.$sector.$pgsz.2 {
   354    354         log_deleted test.db-wal
   355    355       } {1}
   356    356     }
   357    357   }
   358    358   
   359    359   do_test wal-7.1 {
   360         -  file delete -force test.db test.db-wal
          360  +  forcedelete test.db test.db-wal
   361    361     sqlite3_wal db test.db
   362    362     execsql {
   363    363       PRAGMA page_size = 1024;
   364    364       CREATE TABLE t1(a, b);
   365    365       INSERT INTO t1 VALUES(1, 2);
   366    366     }
   367    367     list [file size test.db] [file size test.db-wal]
................................................................................
   373    373   
   374    374   # Execute some transactions in auto-vacuum mode to test database file
   375    375   # truncation.
   376    376   #
   377    377   do_test wal-8.1 {
   378    378     reopen_db
   379    379     catch { db close }
   380         -  file delete -force test.db test.db-wal
          380  +  forcedelete test.db test.db-wal
   381    381   
   382    382     sqlite3 db test.db
   383    383     db function blob blob
   384    384     execsql {
   385    385       PRAGMA auto_vacuum = 1;
   386    386       PRAGMA journal_mode = wal;
   387    387       PRAGMA auto_vacuum;
................................................................................
   431    431   } 1024
   432    432   do_test wal-9.2 {
   433    433     sqlite3_wal db2 test.db
   434    434     execsql {PRAGMA integrity_check } db2
   435    435   } {ok}
   436    436   
   437    437   do_test wal-9.3 {
   438         -  file delete -force test2.db test2.db-wal
   439         -  file copy test.db test2.db
   440         -  file copy test.db-wal test2.db-wal
          438  +  forcedelete test2.db test2.db-wal
          439  +  copy_file test.db test2.db
          440  +  copy_file test.db-wal test2.db-wal
   441    441     sqlite3_wal db3 test2.db 
   442    442     execsql {PRAGMA integrity_check } db3
   443    443   } {ok}
   444    444   db3 close
   445    445   
   446    446   do_test wal-9.4 {
   447    447     execsql { PRAGMA wal_checkpoint }
................................................................................
   782    782     list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
   783    783   } {3 1}
   784    784   do_test wal-12.3 {
   785    785     execsql { INSERT INTO t2 VALUES('B', 1) }
   786    786     list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
   787    787   } {3 2}
   788    788   do_test wal-12.4 {
   789         -  file copy -force test.db test2.db
   790         -  file copy -force test.db-wal test2.db-wal
          789  +  forcecopy test.db test2.db
          790  +  forcecopy test.db-wal test2.db-wal
   791    791     sqlite3_wal db2 test2.db
   792    792     execsql { SELECT * FROM t2 } db2
   793    793   } {B 1}
   794    794   db2 close
   795    795   do_test wal-12.5 {
   796    796     execsql {
   797    797       PRAGMA wal_checkpoint;
................................................................................
   800    800       UPDATE t1 SET y = 1 WHERE x = 'A';
   801    801       PRAGMA wal_checkpoint;
   802    802       UPDATE t1 SET y = 0 WHERE x = 'A';
   803    803     }
   804    804     execsql {  SELECT * FROM t2 }
   805    805   } {B 2}
   806    806   do_test wal-12.6 {
   807         -  file copy -force test.db test2.db
   808         -  file copy -force test.db-wal test2.db-wal
          807  +  forcecopy test.db test2.db
          808  +  forcecopy test.db-wal test2.db-wal
   809    809     sqlite3_wal db2 test2.db
   810    810     execsql { SELECT * FROM t2 } db2
   811    811   } {B 2}
   812    812   db2 close
   813    813   db close
   814    814   
   815    815   #-------------------------------------------------------------------------
................................................................................
   905    905   # that had an out-of-date pager-cache, the next time the connection was
   906    906   # used it did not realize the cache was out-of-date and proceeded to
   907    907   # operate with an inconsistent cache. Leading to corruption.
   908    908   #
   909    909   catch { db close }
   910    910   catch { db2 close }
   911    911   catch { db3 close }
   912         -file delete -force test.db test.db-wal
          912  +forcedelete test.db test.db-wal
   913    913   sqlite3 db test.db
   914    914   sqlite3 db2 test.db
   915    915   do_test wal-14 {
   916    916     execsql {
   917    917       PRAGMA journal_mode = WAL;
   918    918       CREATE TABLE t1(a PRIMARY KEY, b);
   919    919       INSERT INTO t1 VALUES(randomblob(10), randomblob(100));
................................................................................
   943    943   catch { db close }
   944    944   catch { db2 close }
   945    945   
   946    946   #-------------------------------------------------------------------------
   947    947   # The following block of tests - wal-15.* - focus on testing the 
   948    948   # implementation of the sqlite3_wal_checkpoint() interface.
   949    949   #
   950         -file delete -force test.db test.db-wal
          950  +forcedelete test.db test.db-wal
   951    951   sqlite3 db test.db
   952    952   do_test wal-15.1 {
   953    953     execsql {
   954    954       PRAGMA auto_vacuum = 0;
   955    955       PRAGMA page_size = 1024;
   956    956       PRAGMA journal_mode = WAL;
   957    957     }
................................................................................
  1039   1039     5 {sqlite3_wal_checkpoint db aux}          SQLITE_OK     0 1
  1040   1040     6 {sqlite3_wal_checkpoint db temp}         SQLITE_OK     0 0
  1041   1041     7 {db eval "PRAGMA main.wal_checkpoint"}   {0 10 10}     1 0
  1042   1042     8 {db eval "PRAGMA aux.wal_checkpoint"}    {0 16 16}     0 1
  1043   1043     9 {db eval "PRAGMA temp.wal_checkpoint"}   {0 -1 -1}     0 0
  1044   1044   } {
  1045   1045     do_test wal-16.$tn.1 {
  1046         -    file delete -force test2.db test2.db-wal test2.db-journal
  1047         -    file delete -force test.db test.db-wal test.db-journal
         1046  +    forcedelete test2.db test2.db-wal test2.db-journal
         1047  +    forcedelete test.db test.db-wal test.db-journal
  1048   1048   
  1049   1049       sqlite3 db test.db
  1050   1050       execsql {
  1051   1051         ATTACH 'test2.db' AS aux;
  1052   1052         PRAGMA main.auto_vacuum = 0;
  1053   1053         PRAGMA aux.auto_vacuum = 0;
  1054   1054         PRAGMA main.journal_mode = WAL;
................................................................................
  1112   1112     2   256  [wal_file_size 172 512]
  1113   1113     3   512  [wal_file_size 172 512] 
  1114   1114     4  1024  [wal_file_size 172 512]
  1115   1115     5  2048  [wal_file_size 172 512]
  1116   1116     6  4096  [wal_file_size 176 512]
  1117   1117     7  8192  [wal_file_size 184 512]
  1118   1118   " {
  1119         -  file delete -force test.db test.db-wal test.db-journal
         1119  +  forcedelete test.db test.db-wal test.db-journal
  1120   1120     sqlite3_simulate_device -sectorsize $sectorsize
  1121   1121     sqlite3 db test.db -vfs devsym
  1122   1122   
  1123   1123     do_test wal-17.$tn.1 {
  1124   1124       execsql {
  1125   1125         PRAGMA auto_vacuum = 0;
  1126   1126         PRAGMA page_size = 512;
................................................................................
  1156   1156   #
  1157   1157   #   wal-18.1.* When the first 32-bits of a frame checksum is correct but 
  1158   1158   #              the second 32-bits are false, and
  1159   1159   #
  1160   1160   #   wal-18.2.* When the page-size field that occurs at the start of a log
  1161   1161   #              file is a power of 2 greater than 16384 or smaller than 512.
  1162   1162   #
  1163         -file delete -force test.db test.db-wal test.db-journal
         1163  +forcedelete test.db test.db-wal test.db-journal
  1164   1164   do_test wal-18.0 {
  1165   1165     sqlite3 db test.db
  1166   1166     execsql {
  1167   1167       PRAGMA page_size = 1024;
  1168   1168       PRAGMA auto_vacuum = 0;
  1169   1169       PRAGMA journal_mode = WAL;
  1170   1170       PRAGMA synchronous = OFF;
................................................................................
  1174   1174       PRAGMA wal_checkpoint;
  1175   1175   
  1176   1176       INSERT INTO t1 VALUES(1, 2);          -- frames 1 and 2
  1177   1177       INSERT INTO t1 VALUES(3, 4);          -- frames 3 and 4
  1178   1178       INSERT INTO t1 VALUES(5, 6);          -- frames 5 and 6
  1179   1179     }
  1180   1180   
  1181         -  file copy -force test.db testX.db
  1182         -  file copy -force test.db-wal testX.db-wal
         1181  +  forcecopy test.db testX.db
         1182  +  forcecopy test.db-wal testX.db-wal
  1183   1183     db close
  1184   1184     list [file size testX.db] [file size testX.db-wal]
  1185   1185   } [list [expr 3*1024] [wal_file_size 6 1024]]
  1186   1186   
  1187   1187   unset -nocomplain nFrame result
  1188   1188   foreach {nFrame result} {
  1189   1189            0      {0 0}
................................................................................
  1191   1191            2      {0 0 1 2}
  1192   1192            3      {0 0 1 2}
  1193   1193            4      {0 0 1 2 3 4}
  1194   1194            5      {0 0 1 2 3 4}
  1195   1195            6      {0 0 1 2 3 4 5 6}
  1196   1196   } {
  1197   1197     do_test wal-18.1.$nFrame {
  1198         -    file copy -force testX.db test.db
  1199         -    file copy -force testX.db-wal test.db-wal
         1198  +    forcecopy testX.db test.db
         1199  +    forcecopy testX.db-wal test.db-wal
  1200   1200   
  1201   1201       hexio_write test.db-wal [expr 24 + $nFrame*(24+1024) + 20] 00000000
  1202   1202   
  1203   1203       sqlite3 db test.db
  1204   1204       execsql { 
  1205   1205         SELECT * FROM t1;
  1206   1206         PRAGMA integrity_check; 
................................................................................
  1228   1228     binary scan $blob $scanpattern values
  1229   1229     foreach {v1 v2} $values {
  1230   1230       set c1 [expr {($c1 + $v1 + $c2)&0xFFFFFFFF}]
  1231   1231       set c2 [expr {($c2 + $v2 + $c1)&0xFFFFFFFF}]
  1232   1232     }
  1233   1233   }
  1234   1234   
  1235         -file copy -force test.db testX.db
         1235  +forcecopy test.db testX.db
  1236   1236   foreach {tn pgsz works} { 
  1237   1237     1    128    0
  1238   1238     2    256    0
  1239   1239     3    512    1
  1240   1240     4   1024    1
  1241   1241     5   2048    1
  1242   1242     6   4096    1
................................................................................
  1249   1249   } {
  1250   1250   
  1251   1251     if {$::SQLITE_MAX_PAGE_SIZE < $pgsz} {
  1252   1252       set works 0
  1253   1253     }
  1254   1254   
  1255   1255     for {set pg 1} {$pg <= 3} {incr pg} {
  1256         -    file copy -force testX.db test.db
  1257         -    file delete -force test.db-wal
         1256  +    forcecopy testX.db test.db
         1257  +    forcedelete test.db-wal
  1258   1258     
  1259   1259       # Check that the database now exists and consists of three pages. And
  1260   1260       # that there is no associated wal file.
  1261   1261       #
  1262   1262       do_test wal-18.2.$tn.$pg.1 { file exists test.db-wal } 0
  1263   1263       do_test wal-18.2.$tn.$pg.2 { file exists test.db } 1
  1264   1264       do_test wal-18.2.$tn.$pg.3 { file size test.db } [expr 1024*3]
................................................................................
  1317   1317   # connection knows that it is the last connection to disconnect from
  1318   1318   # the database, so it runs a checkpoint operation. The bug was that
  1319   1319   # the connection was not updating its private copy of the wal-index 
  1320   1320   # header before doing so, meaning that it could checkpoint an old
  1321   1321   # snapshot.
  1322   1322   #
  1323   1323   do_test wal-19.1 {
  1324         -  file delete -force test.db test.db-wal test.db-journal
         1324  +  forcedelete test.db test.db-wal test.db-journal
  1325   1325     sqlite3 db test.db
  1326   1326     sqlite3 db2 test.db
  1327   1327     execsql {
  1328   1328       PRAGMA journal_mode = WAL;
  1329   1329       CREATE TABLE t1(a, b);
  1330   1330       INSERT INTO t1 VALUES(1, 2);
  1331   1331       INSERT INTO t1 VALUES(3, 4);
................................................................................
  1366   1366   #      the data is present and the database is not corrupt.
  1367   1367   #
  1368   1368   # At one point, SQLite was failing to grow the mapping of the wal-index
  1369   1369   # file in step 3 and the checkpoint was corrupting the database file.
  1370   1370   #
  1371   1371   do_test wal-20.1 {
  1372   1372     catch {db close}
  1373         -  file delete -force test.db test.db-wal test.db-journal
         1373  +  forcedelete test.db test.db-wal test.db-journal
  1374   1374     sqlite3 db test.db
  1375   1375     execsql {
  1376   1376       PRAGMA journal_mode = WAL;
  1377   1377       CREATE TABLE t1(x);
  1378   1378       INSERT INTO t1 VALUES(randomblob(900));
  1379   1379       SELECT count(*) FROM t1;
  1380   1380     }
................................................................................
  1472   1472   
  1473   1473   #-------------------------------------------------------------------------
  1474   1474   # Test that when 1 or more pages are recovered from a WAL file, 
  1475   1475   # sqlite3_log() is invoked to report this to the user.
  1476   1476   #
  1477   1477   set walfile [file nativename [file join [pwd] test.db-wal]]
  1478   1478   catch {db close}
  1479         -file delete -force test.db
         1479  +forcedelete test.db
  1480   1480   do_test wal-23.1 {
  1481   1481     faultsim_delete_and_reopen
  1482   1482     execsql {
  1483   1483       CREATE TABLE t1(a, b);
  1484   1484       PRAGMA journal_mode = WAL;
  1485   1485       INSERT INTO t1 VALUES(1, 2);
  1486   1486       INSERT INTO t1 VALUES(3, 4);

Changes to test/wal2.test.

   160    160     do_test wal2-1.$tn.2 {
   161    161       set ::locks
   162    162     } $wal_locks
   163    163   }
   164    164   db close
   165    165   db2 close
   166    166   tvfs delete
   167         -file delete -force test.db test.db-wal test.db-journal
          167  +forcedelete test.db test.db-wal test.db-journal
   168    168   
   169    169   #-------------------------------------------------------------------------
   170    170   # This test case is very similar to the previous one, except, after
   171    171   # the reader reads the corrupt wal-index header, but before it has
   172    172   # a chance to re-read it under the cover of the RECOVER lock, the
   173    173   # wal-index header is replaced with a valid, but out-of-date, header.
   174    174   #
................................................................................
   267    267       }
   268    268       execsql { SELECT count(a), sum(a) FROM t1 } db2
   269    269     } $res1
   270    270   }
   271    271   db close
   272    272   db2 close
   273    273   tvfs delete
   274         -file delete -force test.db test.db-wal test.db-journal
          274  +forcedelete test.db test.db-wal test.db-journal
   275    275   
   276    276   
   277    277   if 0 {
   278    278   #-------------------------------------------------------------------------
   279    279   # This test case - wal2-3.* - tests the response of the library to an
   280    280   # SQLITE_BUSY when attempting to obtain a READ or RECOVER lock.
   281    281   #
................................................................................
   340    340     execsql { SELECT count(a), sum(a) FROM t1 }
   341    341   } {4 10}
   342    342   do_test wal2-3.5 {
   343    343     list [info exists ::sabotage] [info exists ::locked]
   344    344   } {0 0}
   345    345   db close
   346    346   tvfs delete
   347         -file delete -force test.db test.db-wal test.db-journal
          347  +forcedelete test.db test.db-wal test.db-journal
   348    348   
   349    349   }
   350    350   
   351    351   #-------------------------------------------------------------------------
   352    352   # Test that a database connection using a VFS that does not support the
   353    353   # xShmXXX interfaces cannot open a WAL database.
   354    354   #
................................................................................
   437    437   #   wal2-6.5.*: 
   438    438   #
   439    439   #   wal2-6.6.*: Check that if the xShmLock() to reaquire a WAL read-lock when
   440    440   #               exiting exclusive mode fails (i.e. SQLITE_IOERR), then the
   441    441   #               connection silently remains in exclusive mode.
   442    442   #
   443    443   do_test wal2-6.1.1 {
   444         -  file delete -force test.db test.db-wal test.db-journal
          444  +  forcedelete test.db test.db-wal test.db-journal
   445    445     sqlite3 db test.db
   446    446     execsql {
   447    447       Pragma Journal_Mode = Wal;
   448    448     }
   449    449   } {wal}
   450    450   do_test wal2-6.1.2 {
   451    451     execsql { PRAGMA lock_status }
................................................................................
   480    480       INSERT INTO t1 VALUES(3, 4);
   481    481       PRAGMA lock_status;
   482    482     }
   483    483   } {main shared temp closed}
   484    484   db close
   485    485   
   486    486   do_test wal2-6.2.1 {
   487         -  file delete -force test.db test.db-wal test.db-journal
          487  +  forcedelete test.db test.db-wal test.db-journal
   488    488     sqlite3 db test.db
   489    489     execsql {
   490    490       Pragma Locking_Mode = Exclusive;
   491    491       Pragma Journal_Mode = Wal;
   492    492       Pragma Lock_Status;
   493    493     }
   494    494   } {exclusive wal main exclusive temp closed}
................................................................................
   548    548       SELECT * FROM t1;
   549    549       pragma lock_status;
   550    550     }
   551    551   } {1 2 3 4 5 6 main shared temp closed}
   552    552   db close
   553    553   
   554    554   do_test wal2-6.3.1 {
   555         -  file delete -force test.db test.db-wal test.db-journal
          555  +  forcedelete test.db test.db-wal test.db-journal
   556    556     sqlite3 db test.db
   557    557     execsql {
   558    558       PRAGMA journal_mode = WAL;
   559    559       PRAGMA locking_mode = exclusive;
   560    560       BEGIN;
   561    561         CREATE TABLE t1(x);
   562    562         INSERT INTO t1 VALUES('Chico');
................................................................................
   593    593   
   594    594   
   595    595   # This test - wal2-6.4.* - uses a single database connection and the
   596    596   # [testvfs] instrumentation to test that xShmLock() is being called
   597    597   # as expected when a WAL database is used with locking_mode=exclusive.
   598    598   #
   599    599   do_test wal2-6.4.1 {
   600         -  file delete -force test.db test.db-wal test.db-journal
          600  +  forcedelete test.db test.db-wal test.db-journal
   601    601     proc tvfs_cb {method args} {
   602    602       set ::shm_file [lindex $args 0]
   603    603       if {$method == "xShmLock"} { lappend ::locks [lindex $args 2] }
   604    604       return "SQLITE_OK"
   605    605     }
   606    606     testvfs tvfs
   607    607     tvfs script tvfs_cb
................................................................................
   788    788   db2 close
   789    789   T delete
   790    790   
   791    791   #-------------------------------------------------------------------------
   792    792   # Test a theory about the checksum algorithm. Theory was false and this
   793    793   # test did not provoke a bug.
   794    794   #
   795         -file delete -force test.db test.db-wal test.db-journal
          795  +forcedelete test.db test.db-wal test.db-journal
   796    796   do_test wal2-7.1.1 {
   797    797     sqlite3 db test.db
   798    798     execsql {
   799    799       PRAGMA page_size = 4096;
   800    800       PRAGMA journal_mode = WAL;
   801    801       CREATE TABLE t1(a, b);
   802    802     }
   803    803     file size test.db
   804    804   } {4096}
   805    805   do_test wal2-7.1.2 {
   806         -  file copy -force test.db test2.db
   807         -  file copy -force test.db-wal test2.db-wal
          806  +  forcecopy test.db test2.db
          807  +  forcecopy test.db-wal test2.db-wal
   808    808     hexio_write test2.db-wal 48 FF
   809    809   } {1}
   810    810   do_test wal2-7.1.3 {
   811    811     sqlite3 db2 test2.db
   812    812     execsql { PRAGMA wal_checkpoint } db2
   813    813     execsql { SELECT * FROM sqlite_master } db2
   814    814   } {}
   815    815   db close
   816    816   db2 close
   817         -file delete -force test.db test.db-wal test.db-journal
          817  +forcedelete test.db test.db-wal test.db-journal
   818    818   do_test wal2-8.1.2 {
   819    819     sqlite3 db test.db
   820    820     execsql {
   821    821       PRAGMA auto_vacuum=OFF;
   822    822       PRAGMA page_size = 1024;
   823    823       PRAGMA journal_mode = WAL;
   824    824       CREATE TABLE t1(x);
................................................................................
   866    866   # 
   867    867   #
   868    868   proc get_name {method args} { set ::filename [lindex $args 0] ; tvfs filter {} }
   869    869   testvfs tvfs
   870    870   tvfs script get_name
   871    871   tvfs filter xShmOpen
   872    872   
   873         -file delete -force test.db test.db-wal test.db-journal
          873  +forcedelete test.db test.db-wal test.db-journal
   874    874   do_test wal2-9.1 {
   875    875     sqlite3 db test.db -vfs tvfs
   876    876     execsql {
   877    877       PRAGMA journal_mode = WAL;
   878    878       CREATE TABLE x(y);
   879    879       INSERT INTO x VALUES('Barton');
   880    880       INSERT INTO x VALUES('Deakin');

Changes to test/wal3.test.

    90     90     do_test wal3-1.$i.4 {
    91     91       execsql { PRAGMA integrity_check } db2
    92     92     } {ok}
    93     93     db2 close
    94     94     
    95     95     # Check that the file-system in its current state can be recovered.
    96     96     # 
    97         -  file copy -force test.db test2.db
    98         -  file copy -force test.db-wal test2.db-wal
    99         -  file delete -force test2.db-journal
           97  +  forcecopy test.db test2.db
           98  +  forcecopy test.db-wal test2.db-wal
           99  +  forcedelete test2.db-journal
   100    100     sqlite3 db2 test2.db
   101    101     do_test wal3-1.$i.5 {
   102    102       execsql { SELECT count(*) FROM t1 } db2
   103    103     } 4018
   104    104     do_test wal3-1.$i.6 {
   105    105       execsql { SELECT x FROM t1 WHERE rowid = $i }
   106    106     } $str
................................................................................
   204    204   } {
   205    205   
   206    206     proc sync_counter {args} { 
   207    207       foreach {method filename id flags} $args break
   208    208       lappend ::syncs [file tail $filename] $flags
   209    209     }
   210    210     do_test wal3-3.$tn {
   211         -    file delete -force test.db test.db-wal test.db-journal
          211  +    forcedelete test.db test.db-wal test.db-journal
   212    212     
   213    213       testvfs T
   214    214       T filter {} 
   215    215       T script sync_counter
   216    216       sqlite3 db test.db -vfs T
   217    217     
   218    218       execsql "PRAGMA synchronous = $syncmode"
................................................................................
   407    407   #   + The attempt to obtain the lock on aReadMark[0] fails with SQLITE_BUSY.
   408    408   #     This can happen if a checkpoint is ongoing. In this case also simply
   409    409   #     obtain a different read-lock.
   410    410   #
   411    411   catch {db close}
   412    412   testvfs T -default 1
   413    413   do_test wal3-6.1.1 {
   414         -  file delete -force test.db test.db-journal test.db wal
          414  +  forcedelete test.db test.db-journal test.db wal
   415    415     sqlite3 db test.db
   416    416     execsql { PRAGMA auto_vacuum = off }
   417    417     execsql { PRAGMA journal_mode = WAL }
   418    418     execsql {
   419    419       CREATE TABLE t1(a, b);
   420    420       INSERT INTO t1 VALUES('o', 't');
   421    421       INSERT INTO t1 VALUES('t', 'f');
................................................................................
   488    488   } {1}
   489    489   
   490    490   db3 close
   491    491   db2 close
   492    492   db close
   493    493   
   494    494   do_test wal3-6.2.1 {
   495         -  file delete -force test.db test.db-journal test.db wal
          495  +  forcedelete test.db test.db-journal test.db wal
   496    496     sqlite3 db test.db
   497    497     sqlite3 db2 test.db
   498    498     execsql { PRAGMA auto_vacuum = off }
   499    499     execsql { PRAGMA journal_mode = WAL }
   500    500     execsql {
   501    501       CREATE TABLE t1(a, b);
   502    502       INSERT INTO t1 VALUES('h', 'h');
................................................................................
   554    554   #
   555    555   #   + The value in the aReadMark[x] slot has been modified since it was
   556    556   #     read.
   557    557   #
   558    558   catch {db close}
   559    559   testvfs T -default 1
   560    560   do_test wal3-7.1.1 {
   561         -  file delete -force test.db test.db-journal test.db wal
          561  +  forcedelete test.db test.db-journal test.db wal
   562    562     sqlite3 db test.db
   563    563     execsql {
   564    564       PRAGMA journal_mode = WAL;
   565    565       CREATE TABLE blue(red PRIMARY KEY, green);
   566    566     }
   567    567   } {wal}
   568    568   
................................................................................
   611    611   db close
   612    612   db2 close
   613    613   T delete
   614    614   
   615    615   #-------------------------------------------------------------------------
   616    616   # 
   617    617   do_test wal3-8.1 {
   618         -  file delete -force test.db test.db-journal test.db wal
          618  +  forcedelete test.db test.db-journal test.db wal
   619    619     sqlite3 db test.db
   620    620     sqlite3 db2 test.db
   621    621     execsql {
   622    622       PRAGMA auto_vacuum = off;
   623    623       PRAGMA journal_mode = WAL;
   624    624       CREATE TABLE b(c);
   625    625       INSERT INTO b VALUES('Tehran');
................................................................................
   705    705   # on any aReadMark[] slot (because there are already several readers),
   706    706   # the client takes a shared-lock on a slot without modifying the value
   707    707   # and continues.
   708    708   #
   709    709   set nConn 50
   710    710   if { [string match *BSD $tcl_platform(os)] } { set nConn 25 }
   711    711   do_test wal3-9.0 {
   712         -  file delete -force test.db test.db-journal test.db wal
          712  +  forcedelete test.db test.db-journal test.db wal
   713    713     sqlite3 db test.db
   714    714     execsql {
   715    715       PRAGMA page_size = 1024;
   716    716       PRAGMA journal_mode = WAL;
   717    717       CREATE TABLE whoami(x);
   718    718       INSERT INTO whoami VALUES('nobody');
   719    719     }

Changes to test/wal4.test.

    27     27     }
    28     28   } {wal 1 2}
    29     29   
    30     30   do_test wal4-1.2 {
    31     31     # Save a copy of the file-system containing the wal and wal-index files 
    32     32     # only (no database file).
    33     33     faultsim_save_and_close
    34         -  file delete -force sv_test.db
           34  +  forcedelete sv_test.db
    35     35   } {}
    36     36   
    37     37   do_test wal4-1.3 {
    38     38     faultsim_restore_and_reopen
    39     39     catchsql { SELECT * FROM t1 }
    40     40   } {1 {no such table: t1}}
    41     41   

Changes to test/walbak.test.

    44     44       BEGIN;
    45     45         CREATE TABLE t1(a PRIMARY KEY, b);
    46     46         INSERT INTO t1 VALUES('I', 'one');
    47     47       COMMIT;
    48     48     }
    49     49   } {wal}
    50     50   do_test walbak-1.1 {
    51         -  file delete -force bak.db bak.db-journal bak.db-wal
           51  +  forcedelete bak.db bak.db-journal bak.db-wal
    52     52     db backup bak.db
    53     53     file size bak.db
    54     54   } [expr 3*1024]
    55     55   do_test walbak-1.2 {
    56     56     sqlite3 db2 bak.db
    57     57     execsql { 
    58     58       SELECT * FROM t1;
................................................................................
   102    102   proc sig {{db db}} {
   103    103     $db eval { 
   104    104       PRAGMA integrity_check;
   105    105       SELECT md5sum(a, b) FROM t1; 
   106    106     }
   107    107   }
   108    108   db close
   109         -file delete test.db
          109  +delete_file test.db
   110    110   sqlite3 db test.db
   111    111   do_test walbak-2.1 {
   112    112     execsql { PRAGMA journal_mode = WAL }
   113    113     execsql {
   114    114       CREATE TABLE t1(a PRIMARY KEY, b);
   115    115       BEGIN;
   116    116         INSERT INTO t1 VALUES(randomblob(500), randomblob(500));
................................................................................
   232    232         PRAGMA page_size = 2048;
   233    233         PRAGMA journal_mode = PERSIST;
   234    234         CREATE TABLE xx(x);
   235    235       }
   236    236     }
   237    237   
   238    238   } {
   239         -  foreach f [glob -nocomplain test.db*] { file delete -force $f }
          239  +  foreach f [glob -nocomplain test.db*] { forcedelete $f }
   240    240   
   241    241     eval $setup
   242    242   
   243    243     do_test walbak-3.$tn.1 {
   244    244       execsql {
   245    245         CREATE TABLE t1(a, b);
   246    246         INSERT INTO t1 VALUES(1, 2);

Changes to test/walcksum.test.

   149    149   if {$::tcl_platform(byteOrder) == "littleEndian"} { set native "little" }
   150    150   foreach endian {big little} {
   151    151   
   152    152     # Create a database. Leave some data in the log file.
   153    153     #
   154    154     do_test walcksum-1.$endian.1 {
   155    155       catch { db close }
   156         -    file delete -force test.db test.db-wal test.db-journal
          156  +    forcedelete test.db test.db-wal test.db-journal
   157    157       sqlite3 db test.db
   158    158       execsql {
   159    159         PRAGMA page_size = 1024;
   160    160         PRAGMA auto_vacuum = 0;
   161    161         PRAGMA synchronous = NORMAL;
   162    162   
   163    163         CREATE TABLE t1(a PRIMARY KEY, b);
................................................................................
   168    168   
   169    169         PRAGMA journal_mode = WAL;
   170    170         INSERT INTO t1 VALUES(8,  'eight');
   171    171         INSERT INTO t1 VALUES(13, 'thirteen');
   172    172         INSERT INTO t1 VALUES(21, 'twentyone');
   173    173       }
   174    174   
   175         -    file copy -force test.db test2.db
   176         -    file copy -force test.db-wal test2.db-wal
          175  +    forcecopy test.db test2.db
          176  +    forcecopy test.db-wal test2.db-wal
   177    177       db close
   178    178   
   179    179       list [file size test2.db] [file size test2.db-wal]
   180    180     } [list [expr 1024*3] [wal_file_size 6 1024]]
   181    181   
   182    182     # Verify that the checksums are valid for all frames and that they
   183    183     # are calculated by interpreting data in native byte-order.
................................................................................
   195    195     for {set f 1} {$f <= 6} {incr f} {
   196    196       do_test walcksum-1.$endian.3.$f {
   197    197         log_checksum_write test2.db-wal $f $endian
   198    198         log_checksum_verify test2.db-wal $f $endian
   199    199       } {1}
   200    200     }
   201    201     do_test walcksum-1.$endian.4.1 {
   202         -    file copy -force test2.db test.db
   203         -    file copy -force test2.db-wal test.db-wal
          202  +    forcecopy test2.db test.db
          203  +    forcecopy test2.db-wal test.db-wal
   204    204       sqlite3 db test.db
   205    205       execsql { SELECT a FROM t1 }
   206    206     } {1 2 3 5 8 13 21}
   207    207   
   208    208     # Following recovery, any frames written to the log should use the same 
   209    209     # endianness as the existing frames. Check that this is the case.
   210    210     #
................................................................................
   244    244         log_checksum_verify test.db-wal $f $endian
   245    245       } {1}
   246    246     }
   247    247   
   248    248     # Now that both the recoverer and non-recoverer have added frames to the
   249    249     # log file, check that it can still be recovered.
   250    250     #
   251         -  file copy -force test.db test2.db
   252         -  file copy -force test.db-wal test2.db-wal
          251  +  forcecopy test.db test2.db
          252  +  forcecopy test.db-wal test2.db-wal
   253    253     do_test walcksum-1.$endian.7.11 {
   254    254       sqlite3 db3 test2.db
   255    255       execsql { 
   256    256         PRAGMA integrity_check;
   257    257         SELECT a FROM t1;
   258    258       } db3
   259    259     } {ok 1 2 3 5 8 13 21 34 55}
................................................................................
   290    290   #-------------------------------------------------------------------------
   291    291   # Test case walcksum-2.* tests that if a statement transaction is rolled
   292    292   # back after frames are written to the WAL, and then (after writing some
   293    293   # more) the outer transaction is committed, the WAL file is still correctly
   294    294   # formatted (and can be recovered by a second process if required).
   295    295   #
   296    296   do_test walcksum-2.1 {
   297         -  file delete -force test.db test.db-wal test.db-journal
          297  +  forcedelete test.db test.db-wal test.db-journal
   298    298     sqlite3 db test.db
   299    299     execsql {
   300    300       PRAGMA synchronous = NORMAL;
   301    301       PRAGMA page_size = 1024;
   302    302       PRAGMA journal_mode = WAL;
   303    303       PRAGMA cache_size = 10;
   304    304       CREATE TABLE t1(x PRIMARY KEY);
................................................................................
   318    318         INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*  32 */
   319    319         INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*  64 */
   320    320         INSERT INTO t1 SELECT randomblob(800) FROM t1;   /* 128 */
   321    321         INSERT INTO t1 SELECT randomblob(800) FROM t1;   /* 256 */
   322    322       COMMIT;
   323    323     }
   324    324   
   325         -  file copy -force test.db test2.db
   326         -  file copy -force test.db-wal test2.db-wal
          325  +  forcecopy test.db test2.db
          326  +  forcecopy test.db-wal test2.db-wal
   327    327   
   328    328     sqlite3 db2 test2.db
   329    329     execsql {
   330    330       PRAGMA integrity_check;
   331    331       SELECT count(*) FROM t1;
   332    332     } db2
   333    333   } {ok 256}
................................................................................
   336    336   
   337    337   #-------------------------------------------------------------------------
   338    338   # Test case walcksum-3.* tests that the checksum calculation detects single 
   339    339   # byte changes to frame or frame-header data and considers the frame
   340    340   # invalid as a result.
   341    341   #
   342    342   do_test walcksum-3.1 {
   343         -  file delete -force test.db test.db-wal test.db-journal
          343  +  forcedelete test.db test.db-wal test.db-journal
   344    344     sqlite3 db test.db
   345    345   
   346    346     execsql {
   347    347       PRAGMA synchronous = NORMAL;
   348    348       PRAGMA page_size = 1024;
   349    349       CREATE TABLE t1(a, b);
   350    350       INSERT INTO t1 VALUES(1, randomblob(300));
................................................................................
   352    352       PRAGMA journal_mode = WAL;
   353    353       INSERT INTO t1 VALUES(3, randomblob(300));
   354    354     }
   355    355   
   356    356     file size test.db-wal
   357    357   } [wal_file_size 1 1024]
   358    358   do_test walcksum-3.2 {
   359         -  file copy -force test.db-wal test2.db-wal
   360         -  file copy -force test.db test2.db
          359  +  forcecopy test.db-wal test2.db-wal
          360  +  forcecopy test.db test2.db
   361    361     sqlite3 db2 test2.db
   362    362     execsql { SELECT a FROM t1 } db2
   363    363   } {1 2 3}
   364    364   db2 close
   365         -file copy -force test.db test2.db
          365  +forcecopy test.db test2.db
   366    366   
   367    367   
   368    368   foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {
   369    369     do_test walcksum-3.3.$incr {
   370    370       set FAIL 0
   371    371       for {set iOff 0} {$iOff < [wal_file_size 1 1024]} {incr iOff} {
   372    372   
   373         -      file copy -force test.db-wal test2.db-wal
          373  +      forcecopy test.db-wal test2.db-wal
   374    374         set fd [open test2.db-wal r+]
   375    375         fconfigure $fd -encoding binary
   376    376         fconfigure $fd -translation binary
   377    377     
   378    378         seek $fd $iOff
   379    379         binary scan [read $fd 1] c x
   380    380         seek $fd $iOff

Changes to test/walcrash.test.

    33     33   
    34     34   set seed 0
    35     35   set REPEATS 100
    36     36   
    37     37   # walcrash-1.*
    38     38   #
    39     39   for {set i 1} {$i < $REPEATS} {incr i} {
    40         -  file delete -force test.db test.db-wal
           40  +  forcedelete test.db test.db-wal
    41     41     do_test walcrash-1.$i.1 {
    42     42       crashsql -delay 4 -file test.db-wal -seed [incr seed] {
    43     43         PRAGMA journal_mode = WAL;
    44     44         CREATE TABLE t1(a, b);
    45     45         INSERT INTO t1 VALUES(1, 1);
    46     46         INSERT INTO t1 VALUES(2, 3);
    47     47         INSERT INTO t1 VALUES(3, 6);
................................................................................
    70     70     } {wal}
    71     71     db close
    72     72   }
    73     73   
    74     74   # walcrash-2.*
    75     75   #
    76     76   for {set i 1} {$i < $REPEATS} {incr i} {
    77         -  file delete -force test.db test.db-wal
           77  +  forcedelete test.db test.db-wal
    78     78     do_test walcrash-2.$i.1 {
    79     79       crashsql -delay 4 -file test.db-wal -seed [incr seed] {
    80     80         PRAGMA journal_mode = WAL;
    81     81         CREATE TABLE t1(a PRIMARY KEY, b);
    82     82         INSERT INTO t1 VALUES(1, 2);
    83     83         INSERT INTO t1 VALUES(3, 4);
    84     84         INSERT INTO t1 VALUES(5, 9);
................................................................................
   107    107     } {wal}
   108    108     db close
   109    109   }
   110    110   
   111    111   # walcrash-3.*
   112    112   #
   113    113   # for {set i 1} {$i < $REPEATS} {incr i} {
   114         -#   file delete -force test.db test.db-wal
   115         -#   file delete -force test2.db test2.db-wal
          114  +#   forcedelete test.db test.db-wal
          115  +#   forcedelete test2.db test2.db-wal
   116    116   # 
   117    117   #   do_test walcrash-3.$i.1 {
   118    118   #     crashsql -delay 2 -file test2.db-wal -seed [incr seed] {
   119    119   #       PRAGMA journal_mode = WAL;
   120    120   #       ATTACH 'test2.db' AS aux;
   121    121   #       CREATE TABLE t1(a PRIMARY KEY, b);
   122    122   #       CREATE TABLE aux.t2(a PRIMARY KEY, b);
................................................................................
   139    139   # 
   140    140   #   db close
   141    141   # }
   142    142   
   143    143   # walcrash-4.*
   144    144   #
   145    145   for {set i 1} {$i < $REPEATS} {incr i} {
   146         -  file delete -force test.db test.db-wal
   147         -  file delete -force test2.db test2.db-wal
          146  +  forcedelete test.db test.db-wal
          147  +  forcedelete test2.db test2.db-wal
   148    148   
   149    149     do_test walcrash-4.$i.1 {
   150    150       crashsql -delay 3 -file test.db-wal -seed [incr seed] -blocksize 4096 {
   151    151         PRAGMA journal_mode = WAL;
   152    152         PRAGMA page_size = 1024;
   153    153         CREATE TABLE t1(a PRIMARY KEY, b);
   154    154         INSERT INTO t1 VALUES(1, 2);
................................................................................
   167    167   
   168    168     db close
   169    169   }
   170    170   
   171    171   # walcrash-5.*
   172    172   #
   173    173   for {set i 1} {$i < $REPEATS} {incr i} {
   174         -  file delete -force test.db test.db-wal
   175         -  file delete -force test2.db test2.db-wal
          174  +  forcedelete test.db test.db-wal
          175  +  forcedelete test2.db test2.db-wal
   176    176   
   177    177     do_test walcrash-5.$i.1 {
   178    178       crashsql -delay 11 -file test.db-wal -seed [incr seed] -blocksize 4096 {
   179    179         PRAGMA journal_mode = WAL;
   180    180         PRAGMA page_size = 1024;
   181    181         BEGIN;
   182    182           CREATE TABLE t1(x PRIMARY KEY);
................................................................................
   208    208   
   209    209     db close
   210    210   }
   211    211   
   212    212   # walcrash-6.*
   213    213   #
   214    214   for {set i 1} {$i < $REPEATS} {incr i} {
   215         -  file delete -force test.db test.db-wal
   216         -  file delete -force test2.db test2.db-wal
          215  +  forcedelete test.db test.db-wal
          216  +  forcedelete test2.db test2.db-wal
   217    217   
   218    218     do_test walcrash-6.$i.1 {
   219    219       crashsql -delay 12 -file test.db-wal -seed [incr seed] -blocksize 512 {
   220    220         PRAGMA journal_mode = WAL;
   221    221         PRAGMA page_size = 1024;
   222    222         BEGIN;
   223    223           CREATE TABLE t1(x PRIMARY KEY);
................................................................................
   258    258   #
   259    259   #   (a) that the database is a WAL database, and 
   260    260   #   (b) the database page-size
   261    261   #
   262    262   # based on the log file.
   263    263   #
   264    264   for {set i 1} {$i < $REPEATS} {incr i} {
   265         -  file delete -force test.db test.db-wal
          265  +  forcedelete test.db test.db-wal
   266    266   
   267    267     # Select a page-size for this test.
   268    268     #
   269    269     set pgsz [lindex {512 1024 2048 4096 8192 16384} [expr $i%6]]
   270    270   
   271    271     do_test walcrash-7.$i.1 {
   272    272       crashsql -delay 3 -file test.db -seed [incr seed] -blocksize 512 "

Changes to test/walfault.test.

   461    461       BEGIN;
   462    462         CREATE TABLE abc(a PRIMARY KEY);
   463    463         INSERT INTO abc VALUES(randomblob(1500));
   464    464         INSERT INTO abc VALUES(randomblob(1500));
   465    465       COMMIT;
   466    466     }
   467    467     faultsim_save_and_close
   468         -  file delete sv_test.db-shm
          468  +  delete_file sv_test.db-shm
   469    469   } {}
   470    470   
   471    471   do_faultsim_test walfault-13.1 -prep {
   472    472     faultsim_restore_and_reopen
   473    473   } -body {
   474    474     db eval { PRAGMA locking_mode = exclusive }
   475    475     db eval { SELECT count(*) FROM abc }

Changes to test/walmode.test.

   291    291   
   292    292   #-------------------------------------------------------------------------
   293    293   # Test the effect of a "PRAGMA journal_mode" command being the first 
   294    294   # thing executed by a new connection. This means that the schema is not
   295    295   # loaded when sqlite3_prepare_v2() is called to compile the statement.
   296    296   #
   297    297   do_test walmode-7.0 {
   298         -  file delete -force test.db
          298  +  forcedelete test.db
   299    299     sqlite3 db test.db
   300    300     execsql {
   301    301       PRAGMA journal_mode = WAL;
   302    302       CREATE TABLE t1(a, b);
   303    303     }
   304    304   } {wal}
   305    305   foreach {tn sql result} {

Changes to test/walnoshm.test.

    83     83     PRAGMA locking_mode = exclusive;
    84     84     PRAGMA journal_mode = WAL;
    85     85     INSERT INTO t2 VALUES('e', 'f');
    86     86     INSERT INTO t2 VALUES('g', 'h');
    87     87   } {exclusive wal}
    88     88   
    89     89   do_test 2.1.3 {
    90         -  file copy -force test.db     test2.db
    91         -  file copy -force test.db-wal test2.db-wal
           90  +  forcecopy test.db     test2.db
           91  +  forcecopy test.db-wal test2.db-wal
    92     92     sqlite3 db2 test2.db
    93     93     catchsql { SELECT * FROM t2 } db2
    94     94   } {1 {unable to open database file}}
    95     95   do_test 2.1.4 {
    96     96     catchsql { PRAGMA journal_mode = delete } db2
    97     97   } {1 {unable to open database file}}
    98     98   do_test 2.1.5 {
................................................................................
   100    100       PRAGMA locking_mode = exclusive; 
   101    101       PRAGMA journal_mode = delete;
   102    102       SELECT * FROM t2;
   103    103     } db2
   104    104   } {exclusive delete a b c d e f g h}
   105    105   
   106    106   do_test 2.2.1 {
   107         -  file copy -force test.db     test2.db
   108         -  file copy -force test.db-wal test2.db-wal
          107  +  forcecopy test.db     test2.db
          108  +  forcecopy test.db-wal test2.db-wal
   109    109     sqlite3 db3 test2.db -vfs tvfsshm
   110    110     sqlite3 db2 test2.db
   111    111     execsql { SELECT * FROM t2 } db3
   112    112   } {a b c d e f g h}
   113    113   
   114    114   do_test 2.2.2 {
   115    115     execsql  { PRAGMA locking_mode = exclusive }  db2

Changes to test/walslow.test.

    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   ifcapable !wal {finish_test ; return }
    21     21   
    22     22   proc reopen_db {} {
    23     23     catch { db close }
    24         -  file delete -force test.db test.db-wal
           24  +  forcedelete test.db test.db-wal
    25     25     sqlite3 db test.db
    26     26     execsql { PRAGMA journal_mode = wal }
    27     27   }
    28     28   
    29     29   db close
    30     30   save_prng_state
    31     31   for {set seed 1} {$seed<10} {incr seed} {
................................................................................
    49     49   
    50     50       do_test walslow-1.seed=$seed.$iTest.2 {
    51     51         execsql "PRAGMA wal_checkpoint;"
    52     52         execsql { PRAGMA integrity_check }
    53     53       } {ok}
    54     54   
    55     55       do_test walslow-1.seed=$seed.$iTest.3 {
    56         -      file delete -force testX.db testX.db-wal
    57         -      file copy test.db testX.db
    58         -      file copy test.db-wal testX.db-wal
           56  +      forcedelete testX.db testX.db-wal
           57  +      copy_file test.db testX.db
           58  +      copy_file test.db-wal testX.db-wal
    59     59     
    60     60         sqlite3 db2 testX.db
    61     61         execsql { PRAGMA journal_mode = WAL } db2
    62     62         execsql { PRAGMA integrity_check } db2
    63     63       } {ok}
    64     64     
    65     65       do_test walslow-1.seed=$seed.$iTest.4 {

Changes to test/walthread.test.

   125    125       puts "Skipping $P(testname)"
   126    126       return
   127    127     }
   128    128   
   129    129     puts "Running $P(testname) for $P(seconds) seconds..."
   130    130   
   131    131     catch { db close }
   132         -  file delete -force test.db test.db-journal test.db-wal
          132  +  forcedelete test.db test.db-journal test.db-wal
   133    133   
   134    134     sqlite3 db test.db
   135    135     eval $P(init)
   136    136     catch { db close }
   137    137   
   138    138     foreach T $P(threads) {
   139    139       set name  [lindex $T 0]
................................................................................
   504    504         INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  8192 */
   505    505         INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 16384 */
   506    506         INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 32768 */
   507    507         INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 65536 */
   508    508       COMMIT;
   509    509     }
   510    510   
   511         -  file copy -force test.db-wal bak.db-wal
   512         -  file copy -force test.db bak.db
          511  +  forcecopy test.db-wal bak.db-wal
          512  +  forcecopy test.db bak.db
   513    513     db close
   514    514   
   515         -  file copy -force bak.db-wal test.db-wal
   516         -  file copy -force bak.db test.db
          515  +  forcecopy bak.db-wal test.db-wal
          516  +  forcecopy bak.db test.db
   517    517   
   518    518     if {[file size test.db-wal] < [log_file_size [expr 64*1024] 1024]} {
   519    519       error "Somehow failed to create a large log file"
   520    520     }
   521    521     puts "Database with large log file recovered. Now running clients..."
   522    522   } -thread T 5 {
   523    523     db eval { SELECT count(*) FROM t1 }
   524    524   }
   525    525   unset -nocomplain seconds
   526    526   
   527    527   finish_test

Changes to test/win32lock.test.

    37     37       INSERT INTO t1 VALUES(3,randomblob(25000));
    38     38       INSERT INTO t1 VALUES(4,randomblob(12500));
    39     39       SELECT x, length(y) FROM t1 ORDER BY rowid;
    40     40     }
    41     41   } {1 100000 2 50000 3 25000 4 12500}
    42     42   
    43     43   unset -nocomplain delay1 rc msg
    44         -set delay1 50
    45         -set rc 0
    46     44   set old_pending_byte [sqlite3_test_control_pending_byte 0x40000000]
           45  +
           46  +set win32_lock_ok [list]
           47  +set win32_lock_error [list]
           48  +set delay1 25
    47     49   while {1} {
    48         -  sqlite3_sleep 10
    49     50     lock_win32_file test.db 0 $::delay1
           51  +  set ::log {}
    50     52     set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg]
    51     53     if {$rc} {
    52         -    do_test win32lock-1.2-$delay1-fin {
           54  +    lappend win32_lock_error $::delay1
           55  +    do_test win32lock-1.2-$delay1-error {
    53     56          set ::msg
    54     57       } {disk I/O error}
    55         -    break
    56     58     } else {
    57         -    do_test win32lock-1.2-$delay1 {
           59  +    lappend win32_lock_ok $::delay1
           60  +    do_test win32lock-1.2-$delay1-ok {
    58     61          set ::msg
    59     62       } {1 100000 2 50000 3 25000 4 12500}
    60     63       if {[info exists ::log] && $::log!=""} {
    61     64         do_test win32lock-1.2-$delay1-log1 {
    62     65           regsub {\d+} $::log # x
    63     66           set x
    64     67         } {{delayed #ms for lock/sharing conflict}}
    65     68       }
    66         -    incr delay1 50
    67     69     }
    68         -  set ::log {}
           70  +  if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break
           71  +  incr delay1 25
           72  +  sqlite3_sleep 10
    69     73   }
    70     74   
    71     75   do_test win32lock-2.0 {
    72     76     file_control_win32_av_retry db -1 -1
    73     77   } {0 10 25}
    74     78   do_test win32lock-2.1 {
    75     79     file_control_win32_av_retry db 1 1
    76     80   } {0 1 1}
    77     81   
    78         -set delay1 50
           82  +#
           83  +# NOTE: It is known that the win32lock-2.2-* tests may fail if the system is
           84  +#       experiencing heavy load (i.e. they are very timing sensitive).  This is
           85  +#       primarily due to the AV retry delay being set to 1 millisecond in the
           86  +#       win32lock-2.1 test (above).  While it is important to test this corner
           87  +#       case for the AV retry logic, a failure of this test should probably not
           88  +#       be interpreted as a bug in SQLite or these test cases.
           89  +#
           90  +set win32_lock_ok [list]
           91  +set win32_lock_error [list]
           92  +set delay1 1
    79     93   while {1} {
    80         -  sqlite3_sleep 10
    81     94     lock_win32_file test.db 0 $::delay1
           95  +  set ::log {}
    82     96     set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg]
    83     97     if {$rc} {
    84         -    do_test win32lock-2.2-$delay1-fin {
           98  +    lappend win32_lock_error $::delay1
           99  +    do_test win32lock-2.2-$delay1-error {
    85    100          set ::msg
    86    101       } {disk I/O error}
    87         -    break
    88    102     } else {
    89         -    do_test win32lock-2.2-$delay1 {
          103  +    lappend win32_lock_ok $::delay1
          104  +    do_test win32lock-2.2-$delay1-ok {
    90    105          set ::msg
    91    106       } {1 100000 2 50000 3 25000 4 12500}
    92         -    if {$::log!=""} {
          107  +    if {[info exists ::log] && $::log!=""} {
    93    108         do_test win32lock-2.2-$delay1-log1 {
    94    109           regsub {\d+} $::log # x
    95    110           set x
    96    111         } {{delayed #ms for lock/sharing conflict}}
    97    112       }
    98         -    incr delay1 50
    99    113     }
   100         -  set ::log {}
          114  +  if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break
          115  +  incr delay1 1
          116  +  sqlite3_sleep 10
   101    117   }
   102    118   
   103    119   file_control_win32_av_retry db 10 25
   104    120   sqlite3_test_control_pending_byte $old_pending_byte
   105    121   sqlite3_shutdown
   106    122   test_sqlite3_log 
   107    123   sqlite3_initialize
   108    124   finish_test