From: dan Date: Sat, 19 Nov 2016 17:20:28 +0000 (+0000) Subject: Add another fault-injection test for sqlite3_snapshot_recover(). X-Git-Tag: version-3.16.0~96^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20ba3d7fcb6d8f7e21149b01e181fc1a9532c050;p=thirdparty%2Fsqlite.git Add another fault-injection test for sqlite3_snapshot_recover(). FossilOrigin-Name: 7e040406138669bd67dd6ecae016b3e50dbfaaf8 --- diff --git a/manifest b/manifest index 8f0fbcafe4..c1d99f809d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\ssqlite3_snapshot_recover()\sto\sreturn\nSQLITE_IOERR_SHORT_READ. -D 2016-11-19T16:35:53.322 +C Add\sanother\sfault-injection\stest\sfor\ssqlite3_snapshot_recover(). +D 2016-11-19T17:20:28.983 F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4 @@ -1104,7 +1104,7 @@ F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b F test/snapshot.test 85735bd997a4f6d710140c28fd860519a299649f F test/snapshot2.test aeacd61be9ad4aafdab183e9137eeca87623edad -F test/snapshot_fault.test 566e8a45a2ba71c67bad2077072c85ac54e9dded +F test/snapshot_fault.test 52c5e97ebd218846a8ae2da4d147d3e77d71f963 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 F test/sort.test c2adc635c2564241fefec0b3a68391ef6868fd3b @@ -1535,7 +1535,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 9abeb7980a34cec11a3420e14ad98a4ec0d9c599 -R 7b6eb1e1f049ba4c986979f464295360 +P 525f75fa9fd4a95acc3fb3b0a01dabe2be39b383 +R 540803770026fc0e2bba54ecd3e455de U dan -Z 9f95743e0b02ecca5491496b02c4041a +Z a16f9ea1f945ee0adbd8c25a4885f6d9 diff --git a/manifest.uuid b/manifest.uuid index 51ffaef2ce..cb29e68423 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -525f75fa9fd4a95acc3fb3b0a01dabe2be39b383 \ No newline at end of file +7e040406138669bd67dd6ecae016b3e50dbfaaf8 \ No newline at end of file diff --git a/test/snapshot_fault.test b/test/snapshot_fault.test index f4f45249a4..5c6cf40a6f 100644 --- a/test/snapshot_fault.test +++ b/test/snapshot_fault.test @@ -17,8 +17,6 @@ source $testdir/tester.tcl ifcapable !snapshot {finish_test; return} set testprefix snapshot_fault -if 1 { - #------------------------------------------------------------------------- # Check that an sqlite3_snapshot_open() client cannot be tricked into # reading a corrupt snapshot even if a second client fails while @@ -161,8 +159,6 @@ do_faultsim_test 3.0 -prep { sqlite3_snapshot_free $::snapshot } -} - #------------------------------------------------------------------------- # Test the handling of faults that occur within sqlite3_snapshot_recover(). # @@ -175,14 +171,14 @@ do_execsql_test 4.0 { } {wal} faultsim_save_and_close -do_test 4.1 { +do_test 4.0.1 { faultsim_restore_and_reopen db eval { SELECT * FROM sqlite_master } sqlite3_snapshot_recover db main } {} db close -do_faultsim_test 4 -faults oom* -prep { +do_faultsim_test 4.0 -faults oom* -prep { faultsim_restore_and_reopen db eval { SELECT * FROM sqlite_master } } -body { @@ -191,5 +187,40 @@ do_faultsim_test 4 -faults oom* -prep { faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM} } +# The following test cases contrive to call sqlite3_snapshot_recover() +# before all pages of the *-shm file have been mapped. This tests an +# extra branch of error handling logic in snapshot_recover(). +# +reset_db +do_execsql_test 4.1.0 { + PRAGMA page_size = 512; + PRAGMA journal_mode = wal; + PRAGMA wal_autocheckpoint = 0; + CREATE TABLE t1(zzz); + INSERT INTO t1 VALUES(randomblob( 500 * 9500 )); + PRAGMA user_version = 211; +} {wal 0} + +do_test 4.1.1 { + list [file size test.db-shm] [file size test.db] +} {98304 512} + +faultsim_save_and_close +do_faultsim_test 4.1 -faults shm* -prep { + catch { db2 close } + catch { db close } + faultsim_restore_and_reopen + sqlite3 db2 test.db + db2 eval { SELECT * FROM sqlite_master } + db eval BEGIN + sqlite3_snapshot_get_blob db main + db eval COMMIT +} -body { + sqlite3_snapshot_recover db main +} -test { + faultsim_test_result {0 {}} {1 SQLITE_IOERR} +} + + finish_test