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

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

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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/types.test ('k') | third_party/sqlite/src/test/unordered.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/unixexcl.test
diff --git a/third_party/sqlite/src/test/unixexcl.test b/third_party/sqlite/src/test/unixexcl.test
new file mode 100644
index 0000000000000000000000000000000000000000..057ae0af14fe3e56dba29f4b1d2467b092f6790a
--- /dev/null
+++ b/third_party/sqlite/src/test/unixexcl.test
@@ -0,0 +1,83 @@
+# 2011 March 30
+#
+# 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 the "unix-excl" VFS module (part of
+# os_unix.c).
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/malloc_common.tcl
+
+if {$::tcl_platform(platform)!="unix" || [info commands test_syscall]==""} {
+ finish_test
+ return
+}
+set testprefix unixexcl
+
+
+
+# Test that when using VFS "unix-excl", the first time the database is read
+# a process-wide exclusive lock is taken on it. This means other connections
+# within the process may still access the db normally, but connections from
+# outside the process cannot.
+#
+do_multiclient_test tn {
+ do_test unixexcl-1.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('hello', 'world');
+ }
+ } {}
+ do_test unixexcl-1.$tn.2 { sql2 { SELECT * FROM t1 } } {hello world}
+ do_test unixexcl-1.$tn.3 {
+ code1 {
+ db close
+ sqlite3 db test.db -vfs unix-excl
+ db eval { SELECT * FROM t1 }
+ }
+ } {hello world}
+ if {$tn==1} {
+ do_test unixexcl-1.$tn.4.multiproc {
+ csql2 { SELECT * FROM t1 }
+ } {1 {database is locked}}
+ } else {
+ do_test unixexcl-1.$tn.4.singleproc {
+ csql2 { SELECT * FROM t1 }
+ } {0 {hello world}}
+ }
+}
+
+# Test that when using VFS "unix-excl", if a file is opened in read-only mode
+# the behaviour is the same as if VFS "unix" were used.
+#
+do_multiclient_test tn {
+ do_test unixexcl-2.$tn.1 {
+ sql1 {
+ CREATE TABLE t1(a, b);
+ INSERT INTO t1 VALUES('hello', 'world');
+ }
+ } {}
+ do_test unixexcl-2.$tn.2 { sql2 { SELECT * FROM t1 } } {hello world}
+ do_test unixexcl-2.$tn.3 {
+ code1 {
+ db close
+ sqlite3 db test.db -readonly yes -vfs unix-excl
+ db eval { SELECT * FROM t1 }
+ }
+ } {hello world}
+ do_test unixexcl-2.$tn.4 {
+ csql2 { SELECT * FROM t1 }
+ } {0 {hello world}}
+}
+
+finish_test
« no previous file with comments | « third_party/sqlite/src/test/types.test ('k') | third_party/sqlite/src/test/unordered.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698