/ Check-in [20ddfb47]
Login

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

Overview
Comment:Enable the thread test logic to work with the SQLITE_HAS_CODEC compile-time option.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 20ddfb4780b87953718f3a8e67b777dcff0e3b5e
User & Date: drh 2011-08-30 19:52:32
Context
2011-08-31
13:27
Add checks to make sure cells in corrupt database files do not overflow a page when doing autovacuum. Problem detected by valgrind. check-in: d0b347b4 user: drh tags: trunk
2011-08-30
19:52
Enable the thread test logic to work with the SQLITE_HAS_CODEC compile-time option. check-in: 20ddfb47 user: drh tags: trunk
01:29
Change the build process so that it does not require the unix "sort" command. This avoids confusion between ms-sort and mingw-sort on windows systems. check-in: f1bd5bba user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/test_thread.c.

   278    278     extern void Md5_Register(sqlite3*);
   279    279   
   280    280     UNUSED_PARAMETER(clientData);
   281    281     UNUSED_PARAMETER(objc);
   282    282   
   283    283     zFilename = Tcl_GetString(objv[2]);
   284    284     rc = sqlite3_open(zFilename, &db);
          285  +#ifdef SQLITE_HAS_CODEC
          286  +  if( db && objc>=4 ){
          287  +    const char *zKey;
          288  +    int nKey;
          289  +    zKey = Tcl_GetStringFromObj(objv[3], &nKey);
          290  +    rc = sqlite3_key(db, zKey, nKey);
          291  +    if( rc!=SQLITE_OK ){
          292  +      char *zErrMsg = sqlite3_mprintf("error %d: %s", rc, sqlite3_errmsg(db));
          293  +      sqlite3_close(db);
          294  +      Tcl_AppendResult(interp, zErrMsg, (char*)0);
          295  +      sqlite3_free(zErrMsg);
          296  +      return TCL_ERROR;
          297  +    }
          298  +  }
          299  +#endif
   285    300     Md5_Register(db);
   286    301     sqlite3_busy_handler(db, xBusy, 0);
   287    302     
   288    303     if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR;
   289    304     Tcl_AppendResult(interp, zBuf, 0);
   290    305   
   291    306     return TCL_OK;
................................................................................
   345    360   
   346    361     rc = Tcl_GetIndexFromObjStruct(
   347    362         interp, objv[1], aSub, sizeof(aSub[0]), "sub-command", 0, &iIndex
   348    363     );
   349    364     if( rc!=TCL_OK ) return rc;
   350    365     pSub = &aSub[iIndex];
   351    366   
   352         -  if( objc!=(pSub->nArg+2) ){
          367  +  if( objc<(pSub->nArg+2) ){
   353    368       Tcl_WrongNumArgs(interp, 2, objv, pSub->zUsage);
   354    369       return TCL_ERROR;
   355    370     }
   356    371   
   357    372     return pSub->xProc(clientData, interp, objc, objv);
   358    373   }
   359    374   

Changes to test/thread001.test.

    38     38     catchsql { DROP TABLE ab; }
    39     39   
    40     40     do_test thread001.$tn.0 {
    41     41       db close
    42     42       sqlite3_enable_shared_cache $shared_cache
    43     43       sqlite3_enable_shared_cache $shared_cache
    44     44     } $shared_cache
    45         -  sqlite3 db test.db -fullmutex 1
           45  +  sqlite3 db test.db -fullmutex 1 -key xyzzy
    46     46   
    47     47     set dbconfig ""
    48     48     if {$same_db} {
    49     49       set dbconfig [list set ::DB [sqlite3_connection_pointer db]]
    50     50     }
    51     51   
    52     52     # Set up a database and a schema. The database contains a single
................................................................................
    73     73       execsql { PRAGMA integrity_check }
    74     74     } {ok}
    75     75   
    76     76     set thread_program {
    77     77       #sqlthread parent {puts STARTING..}
    78     78       set needToClose 0
    79     79       if {![info exists ::DB]} {
    80         -      set ::DB [sqlthread open test.db]
           80  +      set ::DB [sqlthread open test.db xyzzy]
    81     81         #sqlthread parent "puts \"OPEN $::DB\""
    82     82         set needToClose 1
    83     83       }
    84     84     
    85     85       for {set i 0} {$i < 100} {incr i} {
    86     86         # Test that the invariant is true.
    87     87         do_test t1 {

Changes to test/thread002.test.

    12     12   #   This test attempts to deadlock SQLite in shared-cache mode.
    13     13   #     
    14     14   #
    15     15   # $Id: thread002.test,v 1.9 2009/03/26 14:48:07 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   
           19  +set do_not_use_codec 1
    19     20   source $testdir/tester.tcl
    20     21   if {[run_thread_tests]==0} { finish_test ; return }
           22  +
    21     23   
    22     24   db close
    23     25   set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
    24     26   
    25     27   set ::NTHREAD 10
    26     28   
    27     29   do_test thread002.1 {

Changes to test/thread003.test.

    76     76   #
    77     77   set nSecond 30
    78     78   puts "Starting thread003.2 (should run for ~$nSecond seconds)"
    79     79   do_test thread003.2 {
    80     80     foreach zFile {test.db test2.db} {
    81     81       set SCRIPT [format {
    82     82         set iEnd [expr {[clock_seconds] + %d}]
    83         -      set ::DB [sqlthread open %s]
           83  +      set ::DB [sqlthread open %s xyzzy]
    84     84     
    85     85         # Set the cache size to 15 pages per cache. 30 available globally.
    86     86         execsql { PRAGMA cache_size = 15 }
    87     87     
    88     88         while {[clock_seconds] < $iEnd} {
    89     89           set iQuery [expr {int(rand()*5000)}]
    90     90           execsql " SELECT * FROM t1 WHERE a = $iQuery "
................................................................................
   113    113   set nSecond 30
   114    114   puts "Starting thread003.3 (should run for ~$nSecond seconds)"
   115    115   do_test thread003.3 {
   116    116     foreach zFile {test.db test2.db} {
   117    117       set SCRIPT [format {
   118    118         set iStart [clock_seconds]
   119    119         set iEnd [expr {[clock_seconds] + %d}]
   120         -      set ::DB [sqlthread open %s]
          120  +      set ::DB [sqlthread open %s xyzzy]
   121    121     
   122    122         # Set the cache size to 15 pages per cache. 30 available globally.
   123    123         execsql { PRAGMA cache_size = 15 }
   124    124     
   125    125         while {[clock_seconds] < $iEnd} {
   126    126           set iQuery [expr {int(rand()*5000)}]
   127    127           execsql "SELECT * FROM t1 WHERE a = $iQuery"
................................................................................
   152    152   set nSecond 30
   153    153   puts "Starting thread003.4 (should run for ~$nSecond seconds)"
   154    154   unset -nocomplain finished(1)
   155    155   unset -nocomplain finished(2)
   156    156   do_test thread003.4 {
   157    157     thread_spawn finished(1) $thread_procs [format {
   158    158       set iEnd [expr {[clock_seconds] + %d}]
   159         -    set ::DB [sqlthread open test.db]
          159  +    set ::DB [sqlthread open test.db xyzzy]
   160    160   
   161    161       # Set the cache size to 15 pages per cache. 30 available globally.
   162    162       execsql { PRAGMA cache_size = 15 }
   163    163   
   164    164       while {[clock_seconds] < $iEnd} {
   165    165         set iQuery [expr {int(rand()*5000)}]
   166    166         execsql "SELECT * FROM t1 WHERE a = $iQuery"