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

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

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/sqlite/src/test/memdb.test ('k') | third_party/sqlite/src/test/memsubsys2.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 14
15 set testdir [file dirname $argv0] 15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl 16 source $testdir/tester.tcl
17 sqlite3_reset_auto_extension 17 sqlite3_reset_auto_extension
18 18
19 # This test assumes that no page-cache or scratch buffers are installed 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 20 # by default when a new database connection is opened. As a result, it
21 # will not work with the "memsubsys1" permutation. 21 # will not work with the "memsubsys1" permutation.
22 # 22 #
23 if {[permutation] == "memsubsys1"} { 23 if {[permutation] == "memsubsys1"} {
24 finish_test 24 finish_test
25 return 25 return
26 } 26 }
27 27
28 test_set_config_pagecache 0 0
29
28 # This procedure constructs a new database in test.db. It fills 30 # This procedure constructs a new database in test.db. It fills
29 # this database with many small records (enough to force multiple 31 # this database with many small records (enough to force multiple
30 # rebalance operations in the btree-layer and to require a large 32 # rebalance operations in the btree-layer and to require a large
31 # page cache), verifies correct results, then returns. 33 # page cache), verifies correct results, then returns.
32 # 34 #
33 proc build_test_db {testname pragmas} { 35 proc build_test_db {testname pragmas} {
34 catch {db close} 36 catch {db close}
35 forcedelete test.db test.db-journal 37 forcedelete test.db test.db-journal
36 sqlite3 db test.db 38 sqlite3 db test.db
37 sqlite3_db_config_lookaside db 0 0 0 39 sqlite3_db_config_lookaside db 0 0 0
(...skipping 30 matching lines...) Expand all
68 sqlite3_status SQLITE_STATUS_PARSER_STACK 1 70 sqlite3_status SQLITE_STATUS_PARSER_STACK 1
69 } 71 }
70 72
71 set xtra_size 290 73 set xtra_size 290
72 74
73 # Test 1: Both PAGECACHE and SCRATCH are shut down. 75 # Test 1: Both PAGECACHE and SCRATCH are shut down.
74 # 76 #
75 db close 77 db close
76 sqlite3_shutdown 78 sqlite3_shutdown
77 sqlite3_config_lookaside 0 0 79 sqlite3_config_lookaside 0 0
80 sqlite3_config_pagecache 0 0
78 sqlite3_initialize 81 sqlite3_initialize
79 reset_highwater_marks 82 reset_highwater_marks
80 build_test_db memsubsys1-1 {PRAGMA page_size=1024} 83 build_test_db memsubsys1-1 {PRAGMA page_size=1024}
81 do_test memsubsys1-1.3 { 84 do_test memsubsys1-1.3 {
82 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 85 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
83 } 0 86 } 0
84 do_test memsubsys1-1.4 { 87 do_test memsubsys1-1.4 {
85 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 88 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
86 } 0 89 } 0
87 set max_pagecache [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2] 90 set max_pagecache [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
(...skipping 20 matching lines...) Expand all
108 do_test memsubsys1-2.5 { 111 do_test memsubsys1-2.5 {
109 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 112 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
110 } 0 113 } 0
111 114
112 # Test 3: Activate PAGECACHE with 20 pages but use the wrong page size 115 # Test 3: Activate PAGECACHE with 20 pages but use the wrong page size
113 # so that PAGECACHE is not used. 116 # so that PAGECACHE is not used.
114 # 117 #
115 db close 118 db close
116 sqlite3_shutdown 119 sqlite3_shutdown
117 sqlite3_config_pagecache [expr 512+$xtra_size] 20 120 sqlite3_config_pagecache [expr 512+$xtra_size] 20
121 sqlite3_config singlethread
118 sqlite3_initialize 122 sqlite3_initialize
119 reset_highwater_marks 123 reset_highwater_marks
120 build_test_db memsubsys1-3.1 {PRAGMA page_size=1024} 124 build_test_db memsubsys1-3.1 {PRAGMA page_size=1024}
121 #show_memstats
122 do_test memsubsys1-3.1.3 { 125 do_test memsubsys1-3.1.3 {
123 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 126 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
124 } 0 127 } 0
125 do_test memsubsys1-3.1.4 { 128 do_test memsubsys1-3.1.4 {
126 set overflow [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2] 129 set overflow [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
127 # Note: The measured PAGECACHE_OVERFLOW is amount malloc() returns, not what 130 # Note: The measured PAGECACHE_OVERFLOW is amount malloc() returns, not what
128 # was requested. System malloc() implementations might (arbitrarily) return 131 # was requested. System malloc() implementations might (arbitrarily) return
129 # slightly different oversize buffers, which can result in slightly different 132 # slightly different oversize buffers, which can result in slightly different
130 # PAGECACHE_OVERFLOW sizes between consecutive runs. So we cannot do an 133 # PAGECACHE_OVERFLOW sizes between consecutive runs. So we cannot do an
131 # exact comparison. Simply verify that the amount is within 5%. 134 # exact comparison. Simply verify that the amount is within 5%.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2] 172 set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
170 } 0 173 } 0
171 do_test memsubsys1-4.5 { 174 do_test memsubsys1-4.5 {
172 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2] 175 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
173 expr {$maxreq<7000} 176 expr {$maxreq<7000}
174 } 1 177 } 1
175 do_test memsubsys1-4.6 { 178 do_test memsubsys1-4.6 {
176 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 179 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
177 } 1 180 } 1
178 181
179 # Test 5: Activate both PAGECACHE and SCRATCH. But make the page size 182 # Test 5: Activate both PAGECACHE and SCRATCH. But make the page size is
180 # such that the SCRATCH allocations are too small. 183 # such that the SCRATCH allocations are too small.
181 # 184 #
182 db close 185 db close
183 sqlite3_shutdown 186 sqlite3_shutdown
184 sqlite3_config_pagecache [expr 4096+$xtra_size] 24 187 sqlite3_config_pagecache [expr 4096+$xtra_size] 24
185 sqlite3_config_scratch 6000 2 188 sqlite3_config_scratch 4000 2
186 sqlite3_initialize 189 sqlite3_initialize
187 reset_highwater_marks 190 reset_highwater_marks
188 build_test_db memsubsys1-5 {PRAGMA page_size=4096} 191 build_test_db memsubsys1-5 {PRAGMA page_size=4096}
189 #show_memstats 192 #show_memstats
190 do_test memsubsys1-5.3 { 193 do_test memsubsys1-5.3 {
191 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 194 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
192 } 24 195 } {/^2[34]$/}
193 do_test memsubsys1-5.4 { 196 do_test memsubsys1-5.4 {
194 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2] 197 set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
195 expr {$maxreq>4096} 198 expr {$maxreq>4096}
196 } 1 199 } 1
197 do_test memsubsys1-5.5 { 200 do_test memsubsys1-5.5 {
198 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 201 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
199 } 0 202 } 0
200 do_test memsubsys1-5.6 { 203 do_test memsubsys1-5.6 {
201 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2] 204 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
202 expr {$s_ovfl>6000} 205 expr {$s_ovfl>6000}
203 } 1 206 } 1
204 207
205 # Test 6: Activate both PAGECACHE and SCRATCH with a 4k page size. 208 # Test 6: Activate both PAGECACHE and SCRATCH with a 4k page size.
206 # Make it so that SCRATCH is large enough 209 # Make it so that SCRATCH is large enough
207 # 210 #
208 db close 211 db close
209 sqlite3_shutdown 212 sqlite3_shutdown
210 sqlite3_config_pagecache [expr 4096+$xtra_size] 24 213 sqlite3_config_pagecache [expr 4096+$xtra_size] 24
211 sqlite3_config_scratch 25300 1 214 sqlite3_config_scratch 25300 1
212 sqlite3_initialize 215 sqlite3_initialize
213 reset_highwater_marks 216 reset_highwater_marks
214 build_test_db memsubsys1-6 {PRAGMA page_size=4096} 217 build_test_db memsubsys1-6 {PRAGMA page_size=4096}
215 #show_memstats 218 #show_memstats
216 do_test memsubsys1-6.3 { 219 do_test memsubsys1-6.3 {
217 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2] 220 set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
218 } 24 221 } {/^2[34]$/}
219 #do_test memsubsys1-6.4 { 222 #do_test memsubsys1-6.4 {
220 # set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2] 223 # set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
221 # expr {$maxreq>4096 && $maxreq<=(4096+$xtra_size)} 224 # expr {$maxreq>4096 && $maxreq<=(4096+$xtra_size)}
222 #} 1 225 #} 1
223 do_test memsubsys1-6.5 { 226 do_test memsubsys1-6.5 {
224 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2] 227 set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
225 } 1 228 } 1
226 do_test memsubsys1-6.6 { 229 do_test memsubsys1-6.6 {
227 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2] 230 set s_ovfl [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 0] 2]
228 } 0 231 } 0
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 INSERT INTO t1 SELECT * FROM t1; 305 INSERT INTO t1 SELECT * FROM t1;
303 INSERT INTO t1 SELECT * FROM t1; 306 INSERT INTO t1 SELECT * FROM t1;
304 SELECT rowid FROM t1; 307 SELECT rowid FROM t1;
305 } 308 }
306 } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} 309 } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
307 310
308 311
309 db close 312 db close
310 sqlite3_shutdown 313 sqlite3_shutdown
311 sqlite3_config_memstatus 1 314 sqlite3_config_memstatus 1
312 sqlite3_config_pagecache 0 0
313 sqlite3_config_scratch 0 0 315 sqlite3_config_scratch 0 0
314 sqlite3_config_lookaside 100 500 316 sqlite3_config_lookaside 100 500
317 sqlite3_config serialized
315 sqlite3_initialize 318 sqlite3_initialize
316 autoinstall_test_functions 319 autoinstall_test_functions
320
321 test_restore_config_pagecache
317 finish_test 322 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/memdb.test ('k') | third_party/sqlite/src/test/memsubsys2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698