Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: third_party/sqlite/src/test/tempfault.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/tempdb2.test ('k') | third_party/sqlite/src/test/temptable2.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/tempfault.test
diff --git a/third_party/sqlite/src/test/tempfault.test b/third_party/sqlite/src/test/tempfault.test
new file mode 100644
index 0000000000000000000000000000000000000000..4eae116a72e12e056adeaf0caf9e2aeef27c16b2
--- /dev/null
+++ b/third_party/sqlite/src/test/tempfault.test
@@ -0,0 +1,134 @@
+# 2016 April 11
+#
+# 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 contains tests for fault-injection when SQLite is used with
+# a temp file database.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+set testprefix tempfault
+
+# sqlite3_memdebug_vfs_oom_test 0
+
+do_faultsim_test 1 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ }
+} -body {
+ execsql { INSERT INTO t1 VALUES(5, 6) }
+} -test {
+ faultsim_test_result {0 {}}
+ set rc [catch { execsql { SELECT * FROM t1 } } msg]
+ if {$rc==0 && $msg != "1 2 3 4 5 6" && $msg != "1 2 3 4"} {
+ error "data mismatch 1: $msg"
+ }
+ if {$testrc==0 && $msg != "1 2 3 4 5 6"} {
+ error "data mismatch 2: $msg"
+ }
+ faultsim_integrity_check
+}
+
+do_faultsim_test 2 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+} -body {
+ execsql { UPDATE t1 SET a = randomblob(99) }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check db
+}
+
+catch { db close }
+do_faultsim_test 2.1 -faults * -prep {
+ if {[info commands db]==""} {
+ sqlite3 db ""
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+ }
+} -body {
+ execsql { UPDATE t1 SET a = randomblob(99) }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check db
+}
+
+do_faultsim_test 3 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<50)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+} -body {
+ execsql {
+ BEGIN;
+ UPDATE t1 SET a = randomblob(99);
+ SAVEPOINT abc;
+ UPDATE t1 SET a = randomblob(98) WHERE (rowid%10)==0;
+ ROLLBACK TO abc;
+ UPDATE t1 SET a = randomblob(97) WHERE (rowid%5)==0;
+ ROLLBACK TO abc;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+ faultsim_integrity_check db
+}
+
+do_faultsim_test 4 -faults * -prep {
+ sqlite3 db ""
+ db eval {
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(b, a);
+ WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<50)
+ INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+ }
+} -body {
+ execsql {
+ BEGIN;
+ UPDATE t1 SET a = randomblob(99);
+ SAVEPOINT abc;
+ UPDATE t1 SET a = randomblob(98) WHERE (rowid%10)==0;
+ ROLLBACK TO abc;
+ UPDATE t1 SET a = randomblob(97) WHERE (rowid%5)==0;
+ ROLLBACK TO abc;
+ COMMIT;
+ }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+sqlite3_memdebug_vfs_oom_test 1
+finish_test
« no previous file with comments | « third_party/sqlite/src/test/tempdb2.test ('k') | third_party/sqlite/src/test/temptable2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698