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

Side by Side Diff: third_party/sqlite/sqlite-src-3170000/test/walblock.test

Issue 2747283002: [sql] Import reference version of SQLite 3.17.. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
1 # 2015 Mar 17
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
9 #
10 #***********************************************************************
11 #
12
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 source $testdir/lock_common.tcl
16 source $testdir/wal_common.tcl
17
18 finish_test; return; # Feature currently not implemented.
19 ifcapable !wal {finish_test ; return }
20 if {$::tcl_platform(platform)!="unix"} { finish_test ; return }
21 set testprefix walblock
22
23 catch { db close }
24 testvfs tvfs -fullshm 1
25 foreach f [glob test.db*] { forcedelete $f }
26
27 sqlite3 db test.db -vfs tvfs
28 do_execsql_test 1.1.0 {
29 CREATE TABLE t1(x, y);
30 INSERT INTO t1 VALUES(1, 2);
31 INSERT INTO t1 VALUES(3, 4);
32 INSERT INTO t1 VALUES(5, 6);
33 PRAGMA journal_mode = wal;
34 INSERT INTO t1 VALUES(7, 8);
35 } {wal}
36
37 do_test 1.1.1 {
38 lsort [glob test.db*]
39 } {test.db test.db-shm test.db-wal}
40
41 do_test 1.1.2 {
42 set C [launch_testfixture]
43 testfixture $C {
44 sqlite3 db test.db
45 db eval { SELECT * FROM t1 }
46 }
47 } {1 2 3 4 5 6 7 8}
48
49 do_test 1.1.3 {
50 set ::out [list]
51 testfixture $C {
52 db eval { SELECT * FROM t1 }
53 } [list set ::out]
54 set ::out
55 } {}
56
57 do_test 1.1.4 {
58 vwait ::out
59 set ::out
60 } {1 2 3 4 5 6 7 8}
61
62 #
63 # Test that if a read client cannot read the wal-index header because a
64 # write client is in the middle of updating it, the reader blocks until
65 # the writer finishes.
66 #
67 # 1. Open a write transaction using client [db] in this process.
68 #
69 # 2. Attempt to commit the write transaction. Intercept the xShmBarrier()
70 # call made by the writer between updating the two copies of the
71 # wal-index header.
72 #
73 # 3. Within the xShmBarrier() callback, make an asynchronous request to
74 # the other process to read from the database. It should block, as it
75 # cannot get read the wal-index header.
76 #
77 # 4. Still in xShmBarrier(), wait for 5 seconds. Check that the other
78 # process has not answered the request.
79 #
80 # 5: Finish committing the transaction. Then wait for 0.5 seconds more.
81 # Ensure that the second process has by this stage read the database
82 # and that the snapshot it read included the transaction committed in
83 # step (4).
84 #
85 do_execsql_test 1.2.1 {
86 BEGIN;
87 INSERT INTO t1 VALUES(9, 10);
88 } {}
89
90 tvfs script barrier_callback
91 tvfs filter xShmBarrier
92 proc barrier_callback {method args} {
93 set ::out ""
94 testfixture $::C { db eval { SELECT * FROM t1 } } {set ::out}
95
96 do_test "1.2.2.(blocking 10 seconds)" {
97 set ::continue 0
98 after 10000 {set ::continue 1}
99 vwait ::continue
100 set ::out
101 } {}
102 }
103
104 execsql COMMIT
105
106 do_test "1.2.3.(blocking 0.5 seconds)" {
107 set ::continue 0
108 after 500 {set ::continue 1}
109 vwait ::continue
110 set ::out
111 } {1 2 3 4 5 6 7 8 9 10}
112
113
114 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3170000/test/walbig.test ('k') | third_party/sqlite/sqlite-src-3170000/test/walcksum.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698