From: dan Date: Mon, 10 Dec 2018 15:51:05 +0000 (+0000) Subject: Add extra tests to shmlock.test (direct testing of xShmLock methods). X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d5430f85ed3c6181f792a392afce83fb4c89eec;p=thirdparty%2Fsqlite.git Add extra tests to shmlock.test (direct testing of xShmLock methods). FossilOrigin-Name: d2c785f94cc6b704ce29147399e2c473fd0f4ff377f1379bd29178bf6d127c1a --- diff --git a/manifest b/manifest index 30cc81f0ed..16143f8169 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rework\sthe\sSQLITE_MUTEXFREE_SHMLOCK\scode\sto\sreduce\scontention. -D 2018-12-10T15:24:29.922 +C Add\sextra\stests\sto\sshmlock.test\s(direct\stesting\sof\sxShmLock\smethods). +D 2018-12-10T15:51:05.281 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 68d0ba0f0b533d5bc84c78c13a6ce84ee81183a67014caa47a969e67f028fa1c @@ -1285,7 +1285,7 @@ F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f F test/shell8.test 96be02ea0c21f05b24c1883d7b711a1fa8525a68ab7b636aacf6057876941013 -F test/shmlock.test 2d8d2401fb001414a817d61b2c4983215d546c71d48da517a0a5015422997628 +F test/shmlock.test 3d1868f0386923c0592a235f2dd87ae52286b217bc695fbfd9d39a828e7be374 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1783,7 +1783,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 a8c5fd86ce1d9b5815f82106f2e44797b743bbb3c44aee5f835ce8d278caf8f7 -R 2c73dae6f22740de28ff76884e3353b6 +P d9157dd176a2d18c6e02a2a0c7e16cef2da43bf44be9765e0363f34aebad23e9 +R 24f7a75900edcf030e0982b0e1c98eeb U dan -Z 57d8b49adf3b9b02554cff5dcd73ea2d +Z d8fb14bd354e885b5baff90283e91e8d diff --git a/manifest.uuid b/manifest.uuid index 8342dba98b..abbf850327 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d9157dd176a2d18c6e02a2a0c7e16cef2da43bf44be9765e0363f34aebad23e9 \ No newline at end of file +d2c785f94cc6b704ce29147399e2c473fd0f4ff377f1379bd29178bf6d127c1a \ No newline at end of file diff --git a/test/shmlock.test b/test/shmlock.test index ac79ac44d3..6910758b82 100644 --- a/test/shmlock.test +++ b/test/shmlock.test @@ -104,8 +104,70 @@ if {[permutation]=="unix-excl"} { } {SQLITE_OK} vfs_shmlock db255 main exclusive unlock 4 1 + + for {set i 0} {$i < 256} {incr i} { + db$i close + } +} + +sqlite3 db0 test.db +sqlite3 db1 test.db +do_test 3.1 { execsql { SELECT * FROM t1 } db0 } {1 2} +do_test 3.2 { execsql { SELECT * FROM t1 } db1 } {1 2} + +set L(0) {n n n n n n n n} +set L(1) {n n n n n n n n} +proc random_lock_test {idx} { + global L + set iSlot [expr int(rand()*8)] + if {[expr int(rand()*2)]} { + # Unlock operation + if {[lindex $L($idx) $iSlot]!="n"} { + vfs_shmlock db$idx main [lindex $L($idx) $iSlot] unlock $iSlot 1 + lset L($idx) $iSlot n + } + } else { + # Lock operation + if {[lindex $L($idx) $iSlot]=="n"} { + set locktype [lindex {e s} [expr int(rand()*2)]] + set n 1 + if {$locktype=="e"} { + for {set l $iSlot} {$l<8 && [lindex $L($idx) $l]=="n"} {incr l} {} + set n [expr int(rand()*($l-$iSlot))+1] + # puts "iSlot=$iSlot l=$l L=$L($idx)" + # puts "$iSlot $n" + } + set res [vfs_shmlock db$idx main $locktype lock $iSlot $n] + + set bBusy 0 + for {set i $iSlot} {$i<($iSlot+$n)} {incr i} { + set other [lindex $L([expr ($idx+1)%2]) $i] + if {($other!="n" && $locktype=="e")||($other=="e" && $locktype=="s")} { + if {$res != "SQLITE_BUSY"} { error "BUSY not detected" } + set bBusy 1 + break + } + } + + if {$bBusy==0} { + if {$res != "SQLITE_OK"} { error "BUSY false-positive" } + for {set i $iSlot} {$i<($iSlot+$n)} {incr i} { + lset L($idx) $i $locktype + } + } + } + } +} + +set nStep 100000 +for {set i 0} {$i < $nStep} {incr i} { + random_lock_test 0 + random_lock_test 1 } +db0 close +db1 close + finish_test