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

Side by Side Diff: third_party/sqlite/src/test/memsubsys1.test

Issue 5626002: Update sqlite to 3.7.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/third_party/sqlite/src
Patch Set: Remove misc change. Created 10 years 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/src/test/memleak.test ('k') | third_party/sqlite/src/test/minmax3.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2008 June 18 1 # 2008 June 18
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # 11 #
12 # This file contains tests of the memory allocation subsystem 12 # This file contains tests of the memory allocation subsystem
13 # 13 #
14 # $Id: memsubsys1.test,v 1.17 2009/07/18 14:36:24 danielk1977 Exp $
15 14
16 set testdir [file dirname $argv0] 15 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl 16 source $testdir/tester.tcl
18 sqlite3_reset_auto_extension 17 sqlite3_reset_auto_extension
19 18
19 # This test assumes that no page-cache or scratch buffers are installed
20 # by default when a new database connection is opened. As a result, it
21 # will not work with the "memsubsys1" permutation.
22 #
23 if {[permutation] == "memsubsys1"} {
24 finish_test
25 return
26 }
27
20 # This procedure constructs a new database in test.db. It fills 28 # This procedure constructs a new database in test.db. It fills
21 # this database with many small records (enough to force multiple 29 # this database with many small records (enough to force multiple
22 # rebalance operations in the btree-layer and to require a large 30 # rebalance operations in the btree-layer and to require a large
23 # page cache), verifies correct results, then returns. 31 # page cache), verifies correct results, then returns.
24 # 32 #
25 proc build_test_db {testname pragmas} { 33 proc build_test_db {testname pragmas} {
26 catch {db close} 34 catch {db close}
27 file delete -force test.db test.db-journal 35 file delete -force test.db test.db-journal
28 sqlite3 db test.db 36 sqlite3 db test.db
29 sqlite3_db_config_lookaside db 0 0 0 37 sqlite3_db_config_lookaside db 0 0 0
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 # 91 #
84 db close 92 db close
85 sqlite3_shutdown 93 sqlite3_shutdown
86 sqlite3_config_pagecache [expr 1024+$xtra_size] 20 94 sqlite3_config_pagecache [expr 1024+$xtra_size] 20
87 sqlite3_initialize 95 sqlite3_initialize
88 reset_highwater_marks 96 reset_highwater_marks
89 build_test_db memsubsys1-2 {PRAGMA page_size=1024} 97 build_test_db memsubsys1-2 {PRAGMA page_size=1024}
90 #show_memstats 98 #show_memstats
91 do_test memsubsys1-2.3 { 99 do_test memsubsys1-2.3 {
92 set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2] 100 set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
93 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 101 } [expr ($AUTOVACUUM+$TEMP_STORE>=2)*1024]
94 expr {
95 ($pg_used*1024 + $pg_ovfl) < $max_pagecache &&
96 ($pg_used*(1024+$xtra_size) + $pg_ovfl) >= $max_pagecache
97 }
98 } 1
99 do_test memsubsys1-2.4 { 102 do_test memsubsys1-2.4 {
100 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 103 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
101 } 19 104 } 20
102 do_test memsubsys1-2.5 { 105 do_test memsubsys1-2.5 {
103 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 106 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
104 } 0 107 } 0
105 108
106 # Test 3: Activate PAGECACHE with 20 pages but use the wrong page size 109 # Test 3: Activate PAGECACHE with 20 pages but use the wrong page size
107 # so that PAGECACHE is not used. 110 # so that PAGECACHE is not used.
108 # 111 #
109 db close 112 db close
110 sqlite3_shutdown 113 sqlite3_shutdown
111 sqlite3_config_pagecache [expr 512+$xtra_size] 20 114 sqlite3_config_pagecache [expr 512+$xtra_size] 20
(...skipping 15 matching lines...) Expand all
127 sqlite3_config_pagecache [expr 2048+$xtra_size] 20 130 sqlite3_config_pagecache [expr 2048+$xtra_size] 20
128 sqlite3_initialize 131 sqlite3_initialize
129 reset_highwater_marks 132 reset_highwater_marks
130 build_test_db memsubsys1-3.2 {PRAGMA page_size=2048} 133 build_test_db memsubsys1-3.2 {PRAGMA page_size=2048}
131 #show_memstats 134 #show_memstats
132 do_test memsubsys1-3.2.3 { 135 do_test memsubsys1-3.2.3 {
133 db eval {PRAGMA page_size} 136 db eval {PRAGMA page_size}
134 } 2048 137 } 2048
135 do_test memsubsys1-3.2.4 { 138 do_test memsubsys1-3.2.4 {
136 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 139 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
137 } 19 140 } 20
138 do_test memsubsys1-3.2.5 { 141 do_test memsubsys1-3.2.5 {
139 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 142 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
140 } 0 143 } 0
141 144
142 # Test 4: Activate both PAGECACHE and SCRATCH. 145 # Test 4: Activate both PAGECACHE and SCRATCH.
143 # 146 #
144 db close 147 db close
145 sqlite3_shutdown 148 sqlite3_shutdown
146 sqlite3_config_pagecache [expr 1024+$xtra_size] 50 149 sqlite3_config_pagecache [expr 1024+$xtra_size] 50
147 sqlite3_config_scratch 6000 2 150 sqlite3_config_scratch 6000 2
148 sqlite3_initialize 151 sqlite3_initialize
149 reset_highwater_marks 152 reset_highwater_marks
150 build_test_db memsubsys1-4 {PRAGMA page_size=1024} 153 build_test_db memsubsys1-4 {PRAGMA page_size=1024}
151 #show_memstats 154 #show_memstats
152 do_test memsubsys1-4.3 { 155 do_test memsubsys1-4.3 {
153 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 156 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
154 } 49 157 expr {$pg_used>=45 && $pg_used<=50}
158 } 1
155 do_test memsubsys1-4.4 { 159 do_test memsubsys1-4.4 {
156 set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2] 160 set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
157 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 161 } 0
158 expr {
159 ($pg_used*1024 + $pg_ovfl) < $max_pagecache &&
160 ($pg_used*(1024+$xtra_size) + $pg_ovfl) >= $max_pagecache
161 }
162 } 1
163 do_test memsubsys1-4.5 { 162 do_test memsubsys1-4.5 {
164 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2] 163 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
165 expr {$maxreq<7000} 164 expr {$maxreq<7000}
166 } 1 165 } 1
167 do_test memsubsys1-4.6 { 166 do_test memsubsys1-4.6 {
168 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 167 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
169 } 1 168 } 1
170 169
171 # Test 5: Activate both PAGECACHE and SCRATCH. But make the page size 170 # Test 5: Activate both PAGECACHE and SCRATCH. But make the page size
172 # such that the SCRATCH allocations are too small. 171 # such that the SCRATCH allocations are too small.
173 # 172 #
174 db close 173 db close
175 sqlite3_shutdown 174 sqlite3_shutdown
176 sqlite3_config_pagecache [expr 4096+$xtra_size] 24 175 sqlite3_config_pagecache [expr 4096+$xtra_size] 24
177 sqlite3_config_scratch 6000 2 176 sqlite3_config_scratch 6000 2
178 sqlite3_initialize 177 sqlite3_initialize
179 reset_highwater_marks 178 reset_highwater_marks
180 build_test_db memsubsys1-5 {PRAGMA page_size=4096} 179 build_test_db memsubsys1-5 {PRAGMA page_size=4096}
181 #show_memstats 180 #show_memstats
182 do_test memsubsys1-5.3 { 181 do_test memsubsys1-5.3 {
183 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 182 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
184 } 23 183 } 24
185 do_test memsubsys1-5.4 { 184 do_test memsubsys1-5.4 {
186 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2] 185 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
187 expr {$maxreq>4096} 186 expr {$maxreq>4096}
188 } 1 187 } 1
189 do_test memsubsys1-5.5 { 188 do_test memsubsys1-5.5 {
190 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 189 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
191 } 0 190 } 0
192 do_test memsubsys1-5.6 { 191 do_test memsubsys1-5.6 {
193 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2] 192 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
194 expr {$s_ovfl>6000} 193 expr {$s_ovfl>6000}
195 } 1 194 } 1
196 195
197 # Test 6: Activate both PAGECACHE and SCRATCH with a 4k page size. 196 # Test 6: Activate both PAGECACHE and SCRATCH with a 4k page size.
198 # Make it so that SCRATCH is large enough 197 # Make it so that SCRATCH is large enough
199 # 198 #
200 db close 199 db close
201 sqlite3_shutdown 200 sqlite3_shutdown
202 sqlite3_config_pagecache [expr 4096+$xtra_size] 24 201 sqlite3_config_pagecache [expr 4096+$xtra_size] 24
203 sqlite3_config_scratch 25300 1 202 sqlite3_config_scratch 25300 1
204 sqlite3_initialize 203 sqlite3_initialize
205 reset_highwater_marks 204 reset_highwater_marks
206 build_test_db memsubsys1-6 {PRAGMA page_size=4096} 205 build_test_db memsubsys1-6 {PRAGMA page_size=4096}
207 #show_memstats 206 #show_memstats
208 do_test memsubsys1-6.3 { 207 do_test memsubsys1-6.3 {
209 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 208 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
210 } 23 209 } 24
211 do_test memsubsys1-6.4 { 210 #do_test memsubsys1-6.4 {
212 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2] 211 # set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
213 expr {$maxreq>4096 && $maxreq<=(4096+$xtra_size)} 212 # expr {$maxreq>4096 && $maxreq<=(4096+$xtra_size)}
214 } 1 213 #} 1
215 do_test memsubsys1-6.5 { 214 do_test memsubsys1-6.5 {
216 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 215 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
217 } 1 216 } 1
218 do_test memsubsys1-6.6 { 217 do_test memsubsys1-6.6 {
219 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2] 218 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
220 } 0 219 } 0
221 220
222 # Test 7: Activate both PAGECACHE and SCRATCH with a 4k page size. 221 # Test 7: Activate both PAGECACHE and SCRATCH with a 4k page size.
223 # Set cache_size small so that no PAGECACHE overflow occurs. Verify 222 # Set cache_size small so that no PAGECACHE overflow occurs. Verify
224 # that maximum allocation size is small. 223 # that maximum allocation size is small.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 299
301 db close 300 db close
302 sqlite3_shutdown 301 sqlite3_shutdown
303 sqlite3_config_memstatus 1 302 sqlite3_config_memstatus 1
304 sqlite3_config_pagecache 0 0 303 sqlite3_config_pagecache 0 0
305 sqlite3_config_scratch 0 0 304 sqlite3_config_scratch 0 0
306 sqlite3_config_lookaside 100 500 305 sqlite3_config_lookaside 100 500
307 sqlite3_initialize 306 sqlite3_initialize
308 autoinstall_test_functions 307 autoinstall_test_functions
309 finish_test 308 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/memleak.test ('k') | third_party/sqlite/src/test/minmax3.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698