From: dan Date: Fri, 18 Nov 2016 18:22:05 +0000 (+0000) Subject: Add tests for snapshot interfaces. X-Git-Tag: version-3.16.0~96^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93006cdd853eb84752c0803928afdd25ce4cdb53;p=thirdparty%2Fsqlite.git Add tests for snapshot interfaces. FossilOrigin-Name: 1f7ee7af7b620262ae663d65889b6a87415d4a34 --- diff --git a/manifest b/manifest index c5597fb646..066a12a0ba 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sexisting\ssnapshot\stests\sto\sserialize/deserialize\ssnapshots.\sNo\snew\ntests. -D 2016-11-18T14:38:41.852 +C Add\stests\sfor\ssnapshot\sinterfaces. +D 2016-11-18T18:22:05.618 F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4 @@ -1103,6 +1103,7 @@ F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b F test/snapshot.test bb34cc38828bf2e86a49207995fa7dfacd303832 +F test/snapshot2.test 30bd95f6fefa8be7f29421e27745cac90b66c74d F test/snapshot_fault.test 062ff0438a074978d45e9f9a92e7ad459b74ee73 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 @@ -1534,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 b6a81fa1fc1fb78a65894129851a4ec3986640de -R 17ac6d49deba8d40db4fa5f6ce7fc2ca +P 16b9bf92741e4c62874cffd7c6a61763c5054c7a +R aa1ba4f87ce4a1d41c6deb879752303b U dan -Z cee5f11eb9093786088be3369dcd2153 +Z ee11b90501c467e7c32bf0deb14250e6 diff --git a/manifest.uuid b/manifest.uuid index 6af23f5732..891d62480c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -16b9bf92741e4c62874cffd7c6a61763c5054c7a \ No newline at end of file +1f7ee7af7b620262ae663d65889b6a87415d4a34 \ No newline at end of file diff --git a/test/snapshot2.test b/test/snapshot2.test new file mode 100644 index 0000000000..aa5d385893 --- /dev/null +++ b/test/snapshot2.test @@ -0,0 +1,82 @@ +# 2016 November 18 +# +# 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. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The focus +# of this file is the sqlite3_snapshot_xxx() APIs. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +ifcapable !snapshot {finish_test; return} +set testprefix snapshot2 + +# This test does not work with the inmemory_journal permutation. The reason +# is that each connection opened as part of this permutation executes +# "PRAGMA journal_mode=memory", which fails if the database is in wal mode +# and there are one or more existing connections. +if {[permutation]=="inmemory_journal"} { + finish_test + return +} + +#------------------------------------------------------------------------- +# Check that it is not possible to obtain a snapshot immediately after +# a wal mode database with an empty wal file is opened. But it is after +# the file has been written, even by some other connection. +# +do_execsql_test 1.0 { + PRAGMA journal_mode = wal; + CREATE TABLE t1(a, b, c); + INSERT INTO t1 VALUES(1, 2, 3); + INSERT INTO t1 VALUES(4, 5, 6); +} {wal} + +db close +do_test 1.1.1 { list [file exists test.db] [file exists test.db-wal] } {1 0} + +sqlite3 db test.db +do_execsql_test 1.1.2 { SELECT * FROM t1 } {1 2 3 4 5 6} + +do_test 1.1.3 { + execsql BEGIN + list [catch { sqlite3_snapshot_get_blob db main } msg] $msg +} {1 SQLITE_ERROR} +execsql COMMIT + +do_test 1.1.4 { + execsql { INSERT INTO t1 VALUES(7, 8, 9) } + execsql BEGIN + string length [sqlite3_snapshot_get_blob db main] +} 48 +execsql COMMIT + +db close +do_test 1.2.1 { list [file exists test.db] [file exists test.db-wal] } {1 0} + +sqlite3 db test.db +do_execsql_test 1.2.2 { SELECT * FROM t1 } {1 2 3 4 5 6 7 8 9} + +do_test 1.2.3 { + execsql BEGIN + list [catch { sqlite3_snapshot_get_blob db main } msg] $msg +} {1 SQLITE_ERROR} +execsql COMMIT + +do_test 1.2.4 { + sqlite3 db2 test.db + execsql { INSERT INTO t1 VALUES(10, 11, 12) } db2 + execsql BEGIN + string length [sqlite3_snapshot_get_blob db main] +} 48 +execsql COMMIT +db2 close + + +finish_test