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

Side by Side Diff: third_party/sqlite/test/mutex1.test

Issue 3108030: Move bundled copy of sqlite one level deeper to better separate it... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/test/misuse.test ('k') | third_party/sqlite/test/mutex2.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2008 June 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 # $Id: mutex1.test,v 1.20 2009/04/23 14:58:40 danielk1977 Exp $
13
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16
17 ifcapable !mutex {
18 finish_test
19 return
20 }
21 if {[info exists tester_do_binarylog]} {
22 finish_test
23 return
24 }
25
26 sqlite3_reset_auto_extension
27 clear_mutex_counters
28
29 proc mutex_counters {varname} {
30 upvar $varname var
31 set var(total) 0
32 foreach {name value} [read_mutex_counters] {
33 set var($name) $value
34 incr var(total) $value
35 }
36 }
37
38 #-------------------------------------------------------------------------
39 # Tests mutex1-1.* test that sqlite3_config() returns SQLITE_MISUSE if
40 # is called at the wrong time. And that the first time sqlite3_initialize
41 # is called it obtains the 'static_master' mutex 3 times and a recursive
42 # mutex (sqlite3Config.pInitMutex) twice. Subsequent calls are no-ops
43 # that do not require any mutexes.
44 #
45 do_test mutex1-1.0 {
46 install_mutex_counters 1
47 } {SQLITE_MISUSE}
48
49 do_test mutex1-1.1 {
50 db close
51 install_mutex_counters 1
52 } {SQLITE_MISUSE}
53
54 do_test mutex1-1.2 {
55 sqlite3_shutdown
56 install_mutex_counters 1
57 } {SQLITE_OK}
58
59 do_test mutex1-1.3 {
60 install_mutex_counters 0
61 } {SQLITE_OK}
62
63 do_test mutex1-1.4 {
64 install_mutex_counters 1
65 } {SQLITE_OK}
66
67 do_test mutex1-1.5 {
68 mutex_counters counters
69 set counters(total)
70 } {0}
71
72 do_test mutex1-1.6 {
73 sqlite3_initialize
74 } {SQLITE_OK}
75
76 do_test mutex1-1.7 {
77 mutex_counters counters
78 # list $counters(total) $counters(static_master)
79 expr {$counters(total)>0}
80 } {1}
81
82 do_test mutex1-1.8 {
83 clear_mutex_counters
84 sqlite3_initialize
85 } {SQLITE_OK}
86
87 do_test mutex1-1.9 {
88 mutex_counters counters
89 list $counters(total) $counters(static_master)
90 } {0 0}
91
92 #-------------------------------------------------------------------------
93 # Tests mutex1-2.* test the three thread-safety related modes that
94 # can be selected using sqlite3_config:
95 #
96 # * Serialized mode,
97 # * Multi-threaded mode,
98 # * Single-threaded mode.
99 #
100 ifcapable threadsafe&&shared_cache {
101 set enable_shared_cache [sqlite3_enable_shared_cache 1]
102 foreach {mode mutexes} {
103 singlethread {}
104 multithread {fast static_lru static_master static_mem static_open static_pr ng }
105 serialized {fast recursive static_lru static_master static_mem static_open static_prng}
106 } {
107
108 do_test mutex1.2.$mode.1 {
109 catch {db close}
110 sqlite3_shutdown
111 sqlite3_config $mode
112 } SQLITE_OK
113
114 do_test mutex1.2.$mode.2 {
115 sqlite3_initialize
116 clear_mutex_counters
117 sqlite3 db test.db -nomutex 0 -fullmutex 0
118 catchsql { CREATE TABLE abc(a, b, c) }
119 db eval {
120 INSERT INTO abc VALUES(1, 2, 3);
121 }
122 } {}
123
124 do_test mutex1.2.$mode.3 {
125 mutex_counters counters
126
127 set res [list]
128 foreach {key value} [array get counters] {
129 if {$key ne "total" && $value > 0} {
130 lappend res $key
131 }
132 }
133 lsort $res
134 } [lsort $mutexes]
135 }
136 sqlite3_enable_shared_cache $enable_shared_cache
137
138 # Open and use a connection in "nomutex" mode. Test that no recursive
139 # mutexes are obtained.
140 do_test mutex1.3.1 {
141 catch {db close}
142 clear_mutex_counters
143 sqlite3 db test.db -nomutex 1
144 execsql { SELECT * FROM abc }
145 } {1 2 3 1 2 3 1 2 3}
146 do_test mutex1.3.2 {
147 mutex_counters counters
148 set counters(recursive)
149 } {0}
150 }
151
152 # Test the sqlite3_db_mutex() function.
153 #
154 do_test mutex1.4.1 {
155 catch {db close}
156 sqlite3 db test.db
157 enter_db_mutex db
158 db eval {SELECT 1, 2, 3}
159 } {1 2 3}
160 do_test mutex1.4.2 {
161 leave_db_mutex db
162 db eval {SELECT 1, 2, 3}
163 } {1 2 3}
164 do_test mutex1.4.3 {
165 catch {db close}
166 sqlite3 db test.db -nomutex 1
167 enter_db_mutex db
168 db eval {SELECT 1, 2, 3}
169 } {1 2 3}
170 do_test mutex1.4.4 {
171 leave_db_mutex db
172 db eval {SELECT 1, 2, 3}
173 } {1 2 3}
174
175 do_test mutex1-X {
176 catch {db close}
177 sqlite3_shutdown
178 clear_mutex_counters
179 install_mutex_counters 0
180 sqlite3_initialize
181 } {SQLITE_OK}
182
183 autoinstall_test_functions
184 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/misuse.test ('k') | third_party/sqlite/test/mutex2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698