]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add extra tests for the multiplexor VFS. No changes to code.
authordan <dan@noemail.net>
Tue, 13 Dec 2011 16:40:33 +0000 (16:40 +0000)
committerdan <dan@noemail.net>
Tue, 13 Dec 2011 16:40:33 +0000 (16:40 +0000)
FossilOrigin-Name: c7de6f683d0fec62bc138b4a53b5cccc80c736c3

manifest
manifest.uuid
test/multiplex2.test [new file with mode: 0644]
test/multiplex3.test

index 53293465dd65e2813cac299bb2282d0aedac473b..2927bef9ea461babee48c3150170c6e903ba9da4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\sthe\smultiplex.test\sscript\sto\sconform\sto\sthat\sfound\sin\sthe\s"experimental"\nbranch\soff\sof\strunk.
-D 2011-12-13T15:25:06.872
+C Add\sextra\stests\sfor\sthe\smultiplexor\sVFS.\sNo\schanges\sto\scode.
+D 2011-12-13T16:40:33.044
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -606,7 +606,8 @@ F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
 F test/misc7.test eafaa41b9133d7a2ded4641bbe5f340731d35a52
 F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054
 F test/multiplex.test 8bc3c71f73fe833bc8a659d454d320044a33b5da
-F test/multiplex3.test 2860177d0ec8d494c538f2199b8812df1c09c7c5
+F test/multiplex2.test 7e507a63f3981731556224b23646d29013b98c03
+F test/multiplex3.test 6772008fcaa754ae1b5ddc27c55aa813b12569b2
 F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41
 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
 F test/nan.test e9648b9d007c7045242af35e11a984d4b169443a
@@ -977,7 +978,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P eb95d2f72c625bcfd0f8e9db1db2cb8799854b57
-R f11319d97c8d3b9123b61c079ca9c86c
-U drh
-Z b47be607cba7caec297cb5893d5ae313
+P 2eb79efbff9cdab843b172e9fa9fb400c542fab1
+R 77c5fb359ca24a528b4e0f7440c132da
+U dan
+Z 0e58dc3998254ef9753cd678e848dfd4
index a66362662f6cc4a459c3a2131864cf5adda5611e..fe6cb114ee41857b8b0b6adba9dec7c0065bf540 100644 (file)
@@ -1 +1 @@
-2eb79efbff9cdab843b172e9fa9fb400c542fab1
\ No newline at end of file
+c7de6f683d0fec62bc138b4a53b5cccc80c736c3
\ No newline at end of file
diff --git a/test/multiplex2.test b/test/multiplex2.test
new file mode 100644 (file)
index 0000000..b3a1656
--- /dev/null
@@ -0,0 +1,72 @@
+# 2010 October 29
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+source $testdir/lock_common.tcl
+db close
+
+do_multiclient_test tn {
+  foreach f [glob -nocomplain test.*] { forcedelete $f }
+
+  code1 { catch { sqlite3_multiplex_initialize "" 0 } }
+  code2 { catch { sqlite3_multiplex_initialize "" 0 } }
+
+  code1 { db close }
+  code2 { db2 close }
+
+  code1 { sqlite3 db test.db -vfs multiplex }
+  code2 { sqlite3 db2 test.db -vfs multiplex }
+
+  code1 { sqlite3_multiplex_control db main chunk_size [expr 1024*1024] }
+  code2 { sqlite3_multiplex_control db2 main chunk_size [expr 1024*1024] }
+
+  sql1 {
+    CREATE TABLE t1(a, b);
+    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512
+    SELECT count(*) FROM t1;
+  } 
+
+  do_test multiplex-1.$tn.1 { sql1 { SELECT count(*) FROM t1 } } 512
+  do_test multiplex-1.$tn.2 { sql2 { SELECT count(*) FROM t1 } } 512
+  sql2 { DELETE FROM t1 ; VACUUM }
+  do_test multiplex-1.$tn.3 { sql1 { SELECT count(*) FROM t1 } } 0
+
+  sql1 {
+    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256
+    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512
+    SELECT count(*) FROM t1;
+  }
+
+  do_test multiplex-1.$tn.4 { sql2 { SELECT count(*) FROM t1 } } 512
+}
+
+catch { sqlite3_multiplex_shutdown }
+finish_test
index b1fd4d1f84760a0113aa83fc23a020fda1f3a078..9764ab4e60038cb0bc305545cd2c21a9350f657a 100644 (file)
@@ -55,8 +55,7 @@ proc multiplex_restore_db {} {
   foreach f [glob -nocomplain test.*]    {forcedelete $f}
   foreach f [glob -nocomplain sv_test.*] {forcecopy $f [string range $f 3 end]} }
 
-
-do_test 1.0 {
+proc setup_and_save_db {} {
   multiplex_delete_db
   sqlite3 db file:test.db?8_3_names=1
   sqlite3_multiplex_control db main chunk_size [expr 256*1024]
@@ -76,14 +75,17 @@ do_test 1.0 {
   set ::cksum1 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a}]
   db close
   multiplex_save_db
-} {}
+}
 
+do_test 1.0 { setup_and_save_db } {}
 do_faultsim_test 1 -prep {
   multiplex_restore_db
   sqlite3 db file:test.db?8_3_names=1
   sqlite3_multiplex_control db main chunk_size [expr 256*1024]
 } -body {
-  execsql "UPDATE t1 SET a=randomblob(12), b=randomblob(1500) WHERE (rowid%32)=0"
+  execsql {
+    UPDATE t1 SET a=randomblob(12), b=randomblob(1500) WHERE (rowid%32)=0
+  }
 } -test {
   faultsim_test_result {0 {}}
   if {$testrc!=0} {
@@ -92,8 +94,40 @@ do_faultsim_test 1 -prep {
   }
 }
 
-catch { db close }
+#-------------------------------------------------------------------------
+# The following tests verify that hot-journal rollback works. As follows:
+#
+#   1. Create a large database.
+#   2. Set the pager cache to be very small.
+#   3. Open a transaction. 
+#   4. Run the following 100 times:
+#      a. Update a row.
+#      b. Copy all files on disk to a new db location, including the journal.
+#      c. Verify that the new db can be opened and that the content matches
+#         the database created in step 1 (proving the journal was rolled
+#         back).
+
+do_test 2.0 { 
+  setup_and_save_db
+  multiplex_restore_db
+  sqlite3 db file:test.db?8_3_names=1
+  execsql { PRAGMA cache_size = 10 }
+  execsql { BEGIN }
+} {}
+
+for {set iTest 1} {$iTest<=100} {incr iTest} {
+  do_test 2.$iTest {
+    execsql { 
+      UPDATE t1 SET a=randomblob(12), b=randomblob(1400) WHERE rowid=5*$iTest
+    }
+    foreach f [glob -nocomplain test.*] {forcecopy $f "xx_$f"}
+    sqlite3 db2 file:xx_test.db?8_3_names=1
+    execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2
+  } $::cksum1
 
+  db2 close
+}
+
+catch { db close }
 sqlite3_multiplex_shutdown
 finish_test
-