summaryrefslogtreecommitdiff
path: root/test/mmapfault.test
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2014-10-16 22:51:43 -0400
committerHans-Christoph Steiner <hans@eds.org>2014-10-16 22:51:43 -0400
commit9f67c0520ea0d5f11a190197cdf746c512db4ce4 (patch)
treec88a33f01f20a3d13a09594f114fffacebd0d1a4 /test/mmapfault.test
parentee20336e9c78d2e3782c8d096b9ab4f6ca8ce95f (diff)
parent569c6676a6ddb0ff73821d7693b5e18ddef809b9 (diff)
Merge tag 'upstream/3.2.0'
Upstream version 3.2.0 # gpg: Signature made Thu 16 Oct 2014 10:51:39 PM EDT using RSA key ID 374BBE81 # gpg: Good signature from "Hans-Christoph Steiner <hans@guardianproject.info>" # gpg: aka "Hans-Christoph Steiner <hans@eds.org>" # gpg: aka "Hans-Christoph Steiner <hans@at.or.at>" # gpg: aka "[jpeg image of size 5408]"
Diffstat (limited to 'test/mmapfault.test')
-rw-r--r--test/mmapfault.test76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/mmapfault.test b/test/mmapfault.test
new file mode 100644
index 0000000..10c5e25
--- /dev/null
+++ b/test/mmapfault.test
@@ -0,0 +1,76 @@
+# 2013-05-23
+#
+# 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
+ifcapable !mmap {
+ finish_test
+ return
+}
+set testprefix mmapfault
+
+set a_string_counter 1
+proc a_string {n} {
+ global a_string_counter
+ incr a_string_counter
+ string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
+do_test 1-pre {
+ execsql {
+ CREATE TABLE t1(a UNIQUE, b UNIQUE);
+ INSERT INTO t1 VALUES(a_string(200), a_string(300));
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ }
+ faultsim_save_and_close
+} {}
+
+
+do_faultsim_test 1 -prep {
+ faultsim_restore_and_reopen
+ db func a_string a_string
+ execsql {
+ PRAGMA mmap_size = 1000000;
+ PRAGMA cache_size = 5;
+ BEGIN;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+ }
+} -body {
+ execsql { INSERT INTO t1 VALUES(a_string(200), a_string(300)) }
+} -test {
+ faultsim_test_result {0 {}}
+
+ if {[sqlite3_get_autocommit db]} {
+ sqlite3 db2 test.db
+ set nRow [db2 one {SELECT count(*) FROM t1}]
+ if {$nRow!=4} { error "Database content appears incorrect (1)" }
+ db2 close
+ }
+
+ execsql { INSERT INTO t1 VALUES(a_string(201), a_string(301)) }
+ set nRow [db one {SELECT count(*) FROM t1}]
+ if {$nRow!=5 && $nRow!=66 && $nRow!=65} {
+ error "Database content appears incorrect (2) ($nRow)"
+ }
+
+ catch { execsql COMMIT }
+}
+
+
+
+finish_test