/ Check-in [c7de6f68]
Login

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

Overview
Comment:Add extra tests for the multiplexor VFS. No changes to code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nx-devkit
Files: files | file ages | folders
SHA1: c7de6f683d0fec62bc138b4a53b5cccc80c736c3
User & Date: dan 2011-12-13 16:40:33
Context
2011-12-13
18:22
Change the SQLITE_EXTRA_INIT routine to take a single argument which is a pointer to a string. Call SQLITE_EXTRA_INIT with a NULL argument. Fixes to multiplexor to treat the VFS properly in corner cases. Fix the initialization of multiplex3.test. check-in: 8e65b913 user: drh tags: nx-devkit
16:40
Add extra tests for the multiplexor VFS. No changes to code. check-in: c7de6f68 user: dan tags: nx-devkit
15:25
Update the multiplex.test script to conform to that found in the "experimental" branch off of trunk. check-in: 2eb79efb user: drh tags: nx-devkit
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/multiplex2.test.

            1  +# 2010 October 29
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +
           13  +set testdir [file dirname $argv0]
           14  +source $testdir/tester.tcl
           15  +source $testdir/malloc_common.tcl
           16  +source $testdir/lock_common.tcl
           17  +db close
           18  +
           19  +do_multiclient_test tn {
           20  +  foreach f [glob -nocomplain test.*] { forcedelete $f }
           21  +
           22  +  code1 { catch { sqlite3_multiplex_initialize "" 0 } }
           23  +  code2 { catch { sqlite3_multiplex_initialize "" 0 } }
           24  +
           25  +  code1 { db close }
           26  +  code2 { db2 close }
           27  +
           28  +  code1 { sqlite3 db test.db -vfs multiplex }
           29  +  code2 { sqlite3 db2 test.db -vfs multiplex }
           30  +
           31  +  code1 { sqlite3_multiplex_control db main chunk_size [expr 1024*1024] }
           32  +  code2 { sqlite3_multiplex_control db2 main chunk_size [expr 1024*1024] }
           33  +
           34  +  sql1 {
           35  +    CREATE TABLE t1(a, b);
           36  +    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1
           37  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2
           38  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4
           39  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8
           40  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16
           41  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32
           42  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64
           43  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128
           44  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256
           45  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512
           46  +    SELECT count(*) FROM t1;
           47  +  } 
           48  +
           49  +  do_test multiplex-1.$tn.1 { sql1 { SELECT count(*) FROM t1 } } 512
           50  +  do_test multiplex-1.$tn.2 { sql2 { SELECT count(*) FROM t1 } } 512
           51  +  sql2 { DELETE FROM t1 ; VACUUM }
           52  +  do_test multiplex-1.$tn.3 { sql1 { SELECT count(*) FROM t1 } } 0
           53  +
           54  +  sql1 {
           55  +    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1
           56  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2
           57  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4
           58  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8
           59  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16
           60  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32
           61  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64
           62  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128
           63  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256
           64  +    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512
           65  +    SELECT count(*) FROM t1;
           66  +  }
           67  +
           68  +  do_test multiplex-1.$tn.4 { sql2 { SELECT count(*) FROM t1 } } 512
           69  +}
           70  +
           71  +catch { sqlite3_multiplex_shutdown }
           72  +finish_test

Changes to test/multiplex3.test.

    51     51     foreach f [glob -nocomplain sv_test.*] { forcedelete $f }
    52     52     foreach f [glob -nocomplain test.*]    { forcecopy $f "sv_$f" }
    53     53   }
    54     54   proc multiplex_restore_db {} {
    55     55     foreach f [glob -nocomplain test.*]    {forcedelete $f}
    56     56     foreach f [glob -nocomplain sv_test.*] {forcecopy $f [string range $f 3 end]} }
    57     57   
    58         -
    59         -do_test 1.0 {
           58  +proc setup_and_save_db {} {
    60     59     multiplex_delete_db
    61     60     sqlite3 db file:test.db?8_3_names=1
    62     61     sqlite3_multiplex_control db main chunk_size [expr 256*1024]
    63     62     execsql {
    64     63       CREATE TABLE t1(a PRIMARY KEY, b);
    65     64       INSERT INTO t1 VALUES(randomblob(15), randomblob(2000));
    66     65       INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    --   2
................................................................................
    72     71       INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    -- 128
    73     72       INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    -- 256
    74     73       INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    -- 512
    75     74     }
    76     75     set ::cksum1 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a}]
    77     76     db close
    78     77     multiplex_save_db
    79         -} {}
           78  +}
    80     79   
           80  +do_test 1.0 { setup_and_save_db } {}
    81     81   do_faultsim_test 1 -prep {
    82     82     multiplex_restore_db
    83     83     sqlite3 db file:test.db?8_3_names=1
    84     84     sqlite3_multiplex_control db main chunk_size [expr 256*1024]
    85     85   } -body {
    86         -  execsql "UPDATE t1 SET a=randomblob(12), b=randomblob(1500) WHERE (rowid%32)=0"
           86  +  execsql {
           87  +    UPDATE t1 SET a=randomblob(12), b=randomblob(1500) WHERE (rowid%32)=0
           88  +  }
    87     89   } -test {
    88     90     faultsim_test_result {0 {}}
    89     91     if {$testrc!=0} {
    90     92       set cksum2 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a}]
    91     93       if {$cksum2 != $::cksum1} { error "data mismatch" }
    92     94     }
    93     95   }
    94     96   
    95         -catch { db close }
           97  +#-------------------------------------------------------------------------
           98  +# The following tests verify that hot-journal rollback works. As follows:
           99  +#
          100  +#   1. Create a large database.
          101  +#   2. Set the pager cache to be very small.
          102  +#   3. Open a transaction. 
          103  +#   4. Run the following 100 times:
          104  +#      a. Update a row.
          105  +#      b. Copy all files on disk to a new db location, including the journal.
          106  +#      c. Verify that the new db can be opened and that the content matches
          107  +#         the database created in step 1 (proving the journal was rolled
          108  +#         back).
          109  +
          110  +do_test 2.0 { 
          111  +  setup_and_save_db
          112  +  multiplex_restore_db
          113  +  sqlite3 db file:test.db?8_3_names=1
          114  +  execsql { PRAGMA cache_size = 10 }
          115  +  execsql { BEGIN }
          116  +} {}
          117  +
          118  +for {set iTest 1} {$iTest<=100} {incr iTest} {
          119  +  do_test 2.$iTest {
          120  +    execsql { 
          121  +      UPDATE t1 SET a=randomblob(12), b=randomblob(1400) WHERE rowid=5*$iTest
          122  +    }
          123  +    foreach f [glob -nocomplain test.*] {forcecopy $f "xx_$f"}
          124  +    sqlite3 db2 file:xx_test.db?8_3_names=1
          125  +    execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2
          126  +  } $::cksum1
          127  +
          128  +  db2 close
          129  +}
    96    130   
          131  +catch { db close }
    97    132   sqlite3_multiplex_shutdown
    98    133   finish_test
    99         -