/ Check-in [a107f75d]
Login

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

Overview
Comment:Add further multi-client tests to mmap1.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a107f75d93b8acd3403d8473a75137378041a833
User & Date: dan 2013-04-04 19:32:53
Context
2013-04-05
20:40
Improve the code coverage of "permutations.test coverage-pager". check-in: b095e2cd user: dan tags: trunk
2013-04-04
19:32
Add further multi-client tests to mmap1.test. check-in: a107f75d user: dan tags: trunk
17:28
Disable memory-mapped I/O for the win32lock.test module check-in: 2b3d9805 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/mmap1.test.

    19     19     set bt [btree_from_db $db]
    20     20     db_enter $db
    21     21     array set stats [btree_pager_stats $bt]
    22     22     db_leave $db
    23     23     # puts [array get stats]
    24     24     return $stats(read)
    25     25   }
           26  +
           27  +proc register_rblob_code {dbname seed} {
           28  +  return [subst -nocommands {
           29  +    set ::rcnt $seed
           30  +    proc rblob {n} {
           31  +      set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF]
           32  +      set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]] 
           33  +      string range [string repeat [set str] [expr [set n]/4]] 1 [set n]
           34  +    }
           35  +    $dbname func rblob rblob
           36  +  }]
           37  +}
    26     38   
    27     39   foreach {t mmap_limit nRead c2init} {
    28         -  1.1 { PRAGMA mmap_limit = 67108864 }   4 {}
    29         -  1.2 { PRAGMA mmap_limit =    53248 } 150 {}
    30         -  1.3 { PRAGMA mmap_limit =        0 } 344 {}
           40  +  1.1 { PRAGMA mmap_limit = 67108864 }   4 {PRAGMA mmap_limit = 0}
           41  +  1.2 { PRAGMA mmap_limit =    53248 } 150 {PRAGMA mmap_limit = 0}
           42  +  1.3 { PRAGMA mmap_limit =        0 } 344 {PRAGMA mmap_limit = 0}
    31     43     1.4 { PRAGMA mmap_limit = 67108864 }   4 {PRAGMA mmap_limit = 67108864 }
    32     44     1.5 { PRAGMA mmap_limit =    53248 } 150 {PRAGMA mmap_limit = 67108864 }
    33     45     1.6 { PRAGMA mmap_limit =        0 } 344 {PRAGMA mmap_limit = 67108864 }
    34     46   } {
    35     47     do_multiclient_test tn {
    36     48       sql1 {PRAGMA page_size=1024}
    37     49       sql1 $mmap_limit
    38     50       sql2 $c2init
    39     51   
    40         -    code2 {
    41         -      set ::rcnt 0
    42         -      proc rblob {n} {
    43         -        set ::rcnt [expr (($::rcnt << 3) + $::rcnt + 456) & 0xFFFFFFFF]
    44         -        set str [format %.8x [expr $::rcnt ^ 0xbdf20da3]] 
    45         -        string range [string repeat $str [expr $n/4]] 1 $n
    46         -      }
    47         -      db2 func rblob rblob
    48         -    }
           52  +    code2 [register_rblob_code db2 0]
    49     53   
    50     54       sql2 {
    51     55         PRAGMA page_size=1024;
    52     56         PRAGMA auto_vacuum = 1;
    53     57         CREATE TABLE t1(a, b, UNIQUE(a, b));
    54     58         INSERT INTO t1 VALUES(rblob(500), rblob(500));
    55     59         INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    2
................................................................................
   240    244     sqlite3_step $::STMT
   241    245     sqlite3_column_text $::STMT 0
   242    246   } $bbb
   243    247   
   244    248   do_test 5.5 {
   245    249     sqlite3_finalize $::STMT
   246    250   } SQLITE_OK
          251  +
          252  +#-------------------------------------------------------------------------
          253  +# Test various mmap_limit settings.
          254  +#
          255  +foreach {tn1 mmap1 mmap2} {
          256  +     1 6144       167773
          257  +     2 18432      140399
          258  +     3 43008      401302
          259  +     4 92160      253899
          260  +     5 190464          2
          261  +     6 387072     752431
          262  +     7 780288     291143
          263  +     8 1566720    594306
          264  +     9 3139584    829137
          265  +     10 6285312   793963
          266  +     11 12576768 1015590
          267  +} {
          268  +  do_multiclient_test tn {
          269  +    sql1 {
          270  +      CREATE TABLE t1(a PRIMARY KEY);
          271  +      CREATE TABLE t2(x);
          272  +      INSERT INTO t2 VALUES('');
          273  +    }
          274  +
          275  +    code1 [register_rblob_code db  0]
          276  +    code2 [register_rblob_code db2 444]
          277  +
          278  +    sql1 "PRAGMA mmap_limit = $mmap1"
          279  +    sql2 "PRAGMA mmap_limit = $mmap2"
          280  +
          281  +    do_test $tn1.$tn { 
          282  +      for {set i 1} {$i <= 100} {incr i} {
          283  +        if {$i % 2} {
          284  +          set c1 sql1
          285  +            set c2 sql2
          286  +        } else {
          287  +          set c1 sql2
          288  +            set c2 sql1
          289  +        }
          290  +
          291  +        $c1 {
          292  +          INSERT INTO t1 VALUES( rblob(5000) );
          293  +          UPDATE t2 SET x = (SELECT md5sum(a) FROM t1);
          294  +        }
          295  +
          296  +        set res [$c2 { 
          297  +            SELECT count(*) FROM t1;
          298  +            SELECT x == (SELECT md5sum(a) FROM t1) FROM t2;
          299  +            PRAGMA integrity_check;
          300  +        }]
          301  +        if {$res != [list $i 1 ok]} {
          302  +          do_test $tn1.$tn.$i {
          303  +            set ::res
          304  +          } [list $i 1 ok]
          305  +        }
          306  +      }
          307  +      set res 1
          308  +    } {1}
          309  +  }
          310  +}
          311  +
   247    312   
   248    313   finish_test
   249    314   
   250    315