]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance walro2.test to better ensure that readonly_shm clients are not using
authordan <dan@noemail.net>
Thu, 9 Nov 2017 20:34:35 +0000 (20:34 +0000)
committerdan <dan@noemail.net>
Thu, 9 Nov 2017 20:34:35 +0000 (20:34 +0000)
invalid *-shm files.

FossilOrigin-Name: ff630b66714b20c09888ead0a45f344d63e0d9a5208867d6266e74f79187076c

manifest
manifest.uuid
test/walro2.test

index 05976da35665bc817a47b1867f90192291e5962a..e214aee04cbedc2bc543f3bd159d6a2132c90b55 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Get\sread-only\sSHM\sfile\stests\spassing\son\sWin32.
-D 2017-11-09T20:02:44.785
+C Enhance\swalro2.test\sto\sbetter\sensure\sthat\sreadonly_shm\sclients\sare\snot\susing\ninvalid\s*-shm\sfiles.
+D 2017-11-09T20:34:35.406
 F Makefile.in 5bae3f2f3d42f2ad52b141562d74872c97ac0fca6c54953c91bb150a0e6427a8
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3a5cb477ec3ce5274663b693164e349db63348667cd45bad78cc13d580b691e2
@@ -1527,7 +1527,7 @@ F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03
 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
 F test/walprotocol.test 0b92feb132ccebd855494d917d3f6c2d717ace20
 F test/walro.test cb438d05ba0d191f10b688e39c4f0cd5b71569a1d1f4440e5bdf3c6880e08c20
-F test/walro2.test bde4b25b701be452ba1436409d9ee418513f77bf4c11229d558fd14282330e00
+F test/walro2.test 8812e514c968bf4ee317571fafedac43443360ae23edd7d0f4ef1eae0c13e8e8
 F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68
 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
 F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
@@ -1669,7 +1669,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 43c311701bdf1202918cd46fa6133a11458e0ef8ddb09e46290a231083f395ce
-R b51af4203460b2806284a868a4615565
-U mistachkin
-Z 2f0a43c33871392e0df8028f39e6b334
+P abef05353554e72f4d08aff562b87ff8530e8537a79e58d831205ea8c46eed07
+R 43c8def15803418ff2b6211daf889aff
+U dan
+Z b374f730e5d2822de9c4c678f7c53c0c
index dd49a781d5a0c6759dd816acd3486ccd0af45445..d156b1b802de4e78f2187ab7018ce7c46b597415 100644 (file)
@@ -1 +1 @@
-abef05353554e72f4d08aff562b87ff8530e8537a79e58d831205ea8c46eed07
\ No newline at end of file
+ff630b66714b20c09888ead0a45f344d63e0d9a5208867d6266e74f79187076c
\ No newline at end of file
index 67023de1a2d1e31928d4850381971ca3a4616184..9d0a6b4a1958af35d299619c10db8dae5c8d0faf 100644 (file)
@@ -25,6 +25,22 @@ ifcapable !wal {
   return
 }
 
+proc copy_to_test2 {bZeroShm} {
+  forcecopy test.db test.db2
+  forcecopy test.db-wal test.db2-wal
+  if {$bZeroShm} {
+    forcedelete test.db2-shm
+    set fd [open test.db2-shm w]
+    seek $fd [expr [file size test.db-shm]-1]
+    puts -nonewline $fd "\0"
+    close $fd
+  } else {
+    forcecopy test.db-shm test.db2-shm
+  }
+}
+
+foreach bZeroShm {0 1} {
+set TN [expr $bZeroShm+1]
 do_multiclient_test tn {
   
   # Close all connections and delete the database.
@@ -45,7 +61,7 @@ do_multiclient_test tn {
     }
   }
 
-  do_test 1.1 {
+  do_test $TN.1.1 {
     code2 { sqlite3 db2 test.db }
     sql2 { 
       CREATE TABLE t1(x, y);
@@ -56,26 +72,24 @@ do_multiclient_test tn {
     file exists test.db-shm
   } {1}
 
-  do_test 1.2.1 {
-    forcecopy test.db test.db2
-    forcecopy test.db-wal test.db2-wal
-    forcecopy test.db-shm test.db2-shm
+  do_test $TN.1.2.1 {
+    copy_to_test2 $bZeroShm
     code1 {
       sqlite3 db file:test.db2?readonly_shm=1
     }
 
     sql1 { SELECT * FROM t1 }
   } {a b c d}
-  do_test 1.2.2 {
+  do_test $TN.1.2.2 {
     sql1 { SELECT * FROM t1 }
   } {a b c d}
 
-  do_test 1.3.1 {
+  do_test $TN.1.3.1 {
     code3 { sqlite3 db3 test.db2 }
     sql3 { SELECT * FROM t1 }
   } {a b c d}
 
-  do_test 1.3.2 {
+  do_test $TN.1.3.2 {
     sql1 { SELECT * FROM t1 }
   } {a b c d}
 
@@ -83,7 +97,7 @@ do_multiclient_test tn {
   code2 { db2 close }
   code3 { db3 close }
 
-  do_test 2.1 {
+  do_test $TN.2.1 {
     code2 { sqlite3 db2 test.db }
     sql2 { 
       INSERT INTO t1 VALUES('e', 'f');
@@ -92,10 +106,8 @@ do_multiclient_test tn {
     file exists test.db-shm
   } {1}
 
-  do_test 2.2 {
-    forcecopy test.db test.db2
-    forcecopy test.db-wal test.db2-wal
-    forcecopy test.db-shm test.db2-shm
+  do_test $TN.2.2 {
+    copy_to_test2 $bZeroShm
     code1 {
       sqlite3 db file:test.db2?readonly_shm=1
     }
@@ -105,16 +117,16 @@ do_multiclient_test tn {
     }
   } {a b c d e f g h}
 
-  do_test 2.3.1 {
+  do_test $TN.2.3.1 {
     code3 { sqlite3 db3 test.db2 }
     sql3 { SELECT * FROM t1 }
   } {a b c d e f g h}
-  do_test 2.3.2 {
+  do_test $TN.2.3.2 {
     sql3 { INSERT INTO t1 VALUES('i', 'j') }
     code3 { db3 close }
     sql1 { COMMIT } 
   } {}
-  do_test 2.3.3 {
+  do_test $TN.2.3.3 {
     sql1 { SELECT * FROM t1 }
   } {a b c d e f g h i j}
 
@@ -134,10 +146,10 @@ do_multiclient_test tn {
   catch { code1 { db close } }
   catch { code2 { db2 close } }
   catch { code3 { db3 close } }
-  do_test 3.1.0 {
+  do_test $TN.3.1.0 {
     list [file exists test.db-wal] [file exists test.db-shm]
   } {0 0}
-  do_test 3.1.1 {
+  do_test $TN.3.1.1 {
     close [open test.db-wal w]
     close [open test.db-shm w]
     code1 {
@@ -146,20 +158,20 @@ do_multiclient_test tn {
     sql1 { SELECT * FROM t1 }
   } {a b c d e f g h}
 
-  do_test 3.2.0 {
+  do_test $TN.3.2.0 {
     list [file size test.db-wal] [file size test.db-shm]
   } {0 0}
-  do_test 3.2.1 {
+  do_test $TN.3.2.1 {
     code2 { sqlite3 db2 test.db }
     sql2 { INSERT INTO t1 VALUES(1, 2) ; PRAGMA wal_checkpoint=truncate }
     code2 { db2 close }
     sql1 { SELECT * FROM t1 }
   } {a b c d e f g h 1 2}
-  do_test 3.2.2 {
+  do_test $TN.3.2.2 {
     list [file size test.db-wal] [file size test.db-shm]
   } {0 32768}
 
-  do_test 3.3.0 {
+  do_test $TN.3.3.0 {
     code2 { sqlite3 db2 test.db }
     sql2 { 
       INSERT INTO t1 VALUES(3, 4);
@@ -171,11 +183,11 @@ do_multiclient_test tn {
     code1 { db close }
     list [file size test.db-wal] [file size test.db-shm]
   } [list [wal_file_size 4 1024] 32768]
-  do_test 3.3.1 {
+  do_test $TN.3.3.1 {
     code1 { sqlite3 db file:test.db?readonly_shm=1 }
     sql1 { SELECT * FROM t1 }
   } {a b c d e f g h 1 2 3 4 5 6 7 8 9 10}
-  do_test 3.3.2 {
+  do_test $TN.3.3.2 {
     code2 { sqlite3 db2 test.db }
     sql2 { 
       PRAGMA wal_checkpoint; 
@@ -185,7 +197,7 @@ do_multiclient_test tn {
     code2 { db2 close }
     list [file size test.db-wal] [file size test.db-shm]
   } [list [wal_file_size 4 1024] 32768]
-  do_test 3.3.3 {
+  do_test $TN.3.3.3 {
     sql1 { SELECT * FROM t1 }
   } {i ii}
 
@@ -196,7 +208,7 @@ do_multiclient_test tn {
   catch { code2 { db2 close } }
   catch { code3 { db3 close } }
 
-  do_test 4.0 {
+  do_test $TN.4.0 {
     code1 { forcedelete test.db }
     code1 { sqlite3 db test.db }
     sql1 {
@@ -206,19 +218,17 @@ do_multiclient_test tn {
       INSERT INTO t1 VALUES('world');
     }
 
-    forcecopy test.db test.db2
-    forcecopy test.db-wal test.db2-wal
-    forcecopy test.db-shm test.db2-shm
-    
+    copy_to_test2 $bZeroShm
+
     code1 { db close }
   } {}
 
-  do_test 4.1.1 {
+  do_test $TN.4.1.1 {
     code2 { sqlite3 db2 file:test.db2?readonly_shm=1 }
     sql2 { SELECT * FROM t1 }
   } {hello world}
 
-  do_test 4.1.2 {
+  do_test $TN.4.1.2 {
     code3 { sqlite3 db3 test.db2 }
     sql3 {
       INSERT INTO t1 VALUES('!');
@@ -226,7 +236,7 @@ do_multiclient_test tn {
     }
     code3 { db3 close }
   } {}
-  do_test 4.1.3 {
+  do_test $TN.4.1.3 {
     sql2 { SELECT * FROM t1 }
   } {hello world !}
 
@@ -234,7 +244,7 @@ do_multiclient_test tn {
   catch { code2 { db2 close } }
   catch { code3 { db3 close } }
 
-  do_test 4.2.1 {
+  do_test $TN.4.2.1 {
     code1 { sqlite3 db test.db }
     sql1 {
       INSERT INTO t1 VALUES('!');
@@ -251,16 +261,13 @@ do_multiclient_test tn {
         SELECT count(*) FROM t2;
     } 
   } {500}
-  do_test 4.2.2 {
+  do_test $TN.4.2.2 {
     file size test.db-wal
   } {461152}
-  do_test 4.2.4 {
+  do_test $TN.4.2.4 {
     file_control_persist_wal db 1; db close
 
-    forcecopy test.db test.db2
-    forcecopy test.db-wal test.db2-wal
-    forcecopy test.db-shm test.db2-shm
-
+    copy_to_test2 $bZeroShm
     code2 { sqlite3 db2 file:test.db2?readonly_shm=1 }
     sql2 {
       SELECT * FROM t1;
@@ -275,7 +282,7 @@ do_multiclient_test tn {
   catch { code2 { db2 close } }
   catch { code3 { db3 close } }
 
-  do_test 5.0 {
+  do_test $TN.5.0 {
     code1 { forcedelete test.db }
     code1 { sqlite3 db test.db }
     sql1 {
@@ -288,21 +295,19 @@ do_multiclient_test tn {
       INSERT INTO t1 VALUES('hello');
     }
 
-    forcecopy test.db test.db2
-    forcecopy test.db-wal test.db2-wal
-    forcecopy test.db-shm test.db2-shm
+    copy_to_test2 $bZeroShm
     
     code1 { db close }
   } {}
 
-  do_test 5.1 {
+  do_test $TN.5.1 {
     code2 { sqlite3 db2 file:test.db2?readonly_shm=1 }
     sql2 {
       SELECT * FROM t1;
     }
   } {hello world ! world hello}
 
-  do_test 5.2 {
+  do_test $TN.5.2 {
     code1 {
       proc handle_read {op args} {
         if {$op=="xRead" && [file tail [lindex $args 0]]=="test.db2-wal"} {
@@ -325,7 +330,7 @@ do_multiclient_test tn {
     code1 { set ::res2 }
   } {hello world ! world hello}
 
-  do_test 5.3 {
+  do_test $TN.5.3 {
     code1 { db close }
     code1 { tvfs delete }
   } {}
@@ -337,7 +342,7 @@ do_multiclient_test tn {
   catch { code2 { db2 close } }
   catch { code3 { db3 close } }
 
-  do_test 6.1 {
+  do_test $TN.6.1 {
     code1 { forcedelete test.db }
     code1 { sqlite3 db test.db }
     sql1 {
@@ -350,14 +355,12 @@ do_multiclient_test tn {
       INSERT INTO t1 VALUES('hello');
     }
 
-    forcecopy test.db test.db2
-    forcecopy test.db-wal test.db2-wal
-    forcecopy test.db-shm test.db2-shm
+    copy_to_test2 $bZeroShm
     
     code1 { db close }
   } {}
 
-  do_test 6.2 {
+  do_test $TN.6.2 {
     code1 {
       set ::nRem 5
       proc handle_read {op args} {
@@ -380,10 +383,11 @@ do_multiclient_test tn {
     }
   } {hello world ! world hello}
 
-  do_test 6.3 {
+  do_test $TN.6.3 {
     code1 { db close }
     code1 { tvfs delete }
   } {}
 }
+} ;# foreach bZeroShm
 
 finish_test