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

Unified Diff: third_party/sqlite/sqlite-src-3080704/test/backup4.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
Index: third_party/sqlite/sqlite-src-3080704/test/backup4.test
diff --git a/third_party/sqlite/sqlite-src-3080704/test/backup4.test b/third_party/sqlite/sqlite-src-3080704/test/backup4.test
new file mode 100644
index 0000000000000000000000000000000000000000..417df80e552d502728dc719e0e72d6ea3c01cadb
--- /dev/null
+++ b/third_party/sqlite/sqlite-src-3080704/test/backup4.test
@@ -0,0 +1,103 @@
+# 2012 October 13
+#
+# 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.
+#
+#***********************************************************************
+#
+# The tests in this file verify that if an empty database (zero bytes in
+# size) is used as the source of a backup operation, the final destination
+# database is one page in size.
+#
+# The destination must consist of at least one page as truncating a
+# database file to zero bytes is equivalent to resetting the database
+# schema cookie and change counter. Doing that could cause other clients
+# to become confused and continue using out-of-date cache data.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix backup4
+
+#-------------------------------------------------------------------------
+# At one point this test was failing because [db] was using an out of
+# date schema in test case 1.2.
+#
+do_execsql_test 1.0 {
+ CREATE TABLE t1(x, y, UNIQUE(x, y));
+ INSERT INTO t1 VALUES('one', 'two');
+ SELECT * FROM t1 WHERE x='one';
+ PRAGMA integrity_check;
+} {one two ok}
+
+do_test 1.1 {
+ sqlite3 db1 :memory:
+ db1 backup test.db
+ sqlite3 db1 test.db
+ db1 eval {
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('one', 'two');
+ }
+ db1 close
+} {}
+
+do_execsql_test 1.2 {
+ SELECT * FROM t1 WHERE x='one';
+ PRAGMA integrity_check;
+} {one two ok}
+
+db close
+forcedelete test.db
+forcedelete test.db2
+sqlite3 db test.db
+
+#-------------------------------------------------------------------------
+# Test that if the source is zero bytes, the destination database
+# consists of a single page only.
+#
+do_execsql_test 2.1 {
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+}
+do_test 2.2 { file size test.db } [expr $AUTOVACUUM ? 4096 : 3072]
+
+do_test 2.3 {
+ sqlite3 db1 test.db2
+ db1 backup test.db
+ db1 close
+ file size test.db
+} {1024}
+
+do_test 2.4 { file size test.db2 } 0
+
+db close
+forcedelete test.db
+forcedelete test.db2
+sqlite3 db test.db
+
+#-------------------------------------------------------------------------
+# Test that if the destination has a page-size larger than the implicit
+# page-size of the source, the final destination database still consists
+# of a single page.
+#
+do_execsql_test 3.1 {
+ PRAGMA page_size = 4096;
+ CREATE TABLE t1(a, b);
+ CREATE INDEX i1 ON t1(a, b);
+}
+do_test 3.2 { file size test.db } [expr $AUTOVACUUM ? 16384 : 12288]
+
+do_test 3.3 {
+ sqlite3 db1 test.db2
+ db1 backup test.db
+ db1 close
+ file size test.db
+} {1024}
+
+do_test 3.4 { file size test.db2 } 0
+
+finish_test
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/backup2.test ('k') | third_party/sqlite/sqlite-src-3080704/test/backup_ioerr.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698