OLD | NEW |
1 # 2010 March 10 | 1 # 2010 March 10 |
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 # Tests for the sqlite3_db_status() function | 12 # Tests for the sqlite3_db_status() function |
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 set testprefix dbstatus |
17 | 18 |
18 ifcapable !compound { | 19 ifcapable !compound { |
19 finish_test | 20 finish_test |
20 return | 21 return |
21 } | 22 } |
22 | 23 |
23 # Memory statistics must be enabled for this test. | 24 # Memory statistics must be enabled for this test. |
24 db close | 25 db close |
25 sqlite3_shutdown | 26 sqlite3_shutdown |
26 sqlite3_config_memstatus 1 | 27 sqlite3_config_memstatus 1 |
| 28 sqlite3_config_uri 1 |
27 sqlite3_initialize | 29 sqlite3_initialize |
28 sqlite3 db test.db | 30 sqlite3 db test.db |
29 | 31 |
30 | 32 |
31 # Make sure sqlite3_db_config() and sqlite3_db_status are working. | 33 # Make sure sqlite3_db_config() and sqlite3_db_status are working. |
32 # | 34 # |
33 unset -nocomplain PAGESZ | 35 unset -nocomplain PAGESZ |
34 unset -nocomplain BASESZ | 36 unset -nocomplain BASESZ |
35 do_test dbstatus-1.1 { | 37 do_test dbstatus-1.1 { |
36 db close | 38 db close |
(...skipping 23 matching lines...) Expand all Loading... |
60 [lindex [sqlite3_db_status $db SQLITE_DBSTATUS_LOOKASIDE_USED 0] 1] | 62 [lindex [sqlite3_db_status $db SQLITE_DBSTATUS_LOOKASIDE_USED 0] 1] |
61 } | 63 } |
62 } | 64 } |
63 | 65 |
64 ifcapable stat4||stat3 { | 66 ifcapable stat4||stat3 { |
65 set STAT3 1 | 67 set STAT3 1 |
66 } else { | 68 } else { |
67 set STAT3 0 | 69 set STAT3 0 |
68 } | 70 } |
69 | 71 |
70 ifcapable malloc_usable_size { | |
71 finish_test | |
72 return | |
73 } | |
74 | |
75 #--------------------------------------------------------------------------- | 72 #--------------------------------------------------------------------------- |
76 # Run the dbstatus-2 and dbstatus-3 tests with several of different | 73 # Run the dbstatus-2 and dbstatus-3 tests with several of different |
77 # lookaside buffer sizes. | 74 # lookaside buffer sizes. |
78 # | 75 # |
79 foreach ::lookaside_buffer_size {0 64 120} { | 76 foreach ::lookaside_buffer_size {0 64 120} { |
| 77 ifcapable malloc_usable_size break |
80 | 78 |
81 # Do not run any of these tests if there is SQL configured to run | 79 # Do not run any of these tests if there is SQL configured to run |
82 # as part of the [sqlite3] command. This prevents the script from | 80 # as part of the [sqlite3] command. This prevents the script from |
83 # configuring the size of the lookaside buffer after [sqlite3] has | 81 # configuring the size of the lookaside buffer after [sqlite3] has |
84 # returned. | 82 # returned. |
85 if {[presql] != ""} break | 83 if {[presql] != ""} break |
86 | 84 |
87 #------------------------------------------------------------------------- | 85 #------------------------------------------------------------------------- |
88 # Tests for SQLITE_DBSTATUS_SCHEMA_USED. | 86 # Tests for SQLITE_DBSTATUS_SCHEMA_USED. |
89 # | 87 # |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 do_test dbstatus-3.$tn.bx { expr $nStmt1<=$nFree } {1} | 368 do_test dbstatus-3.$tn.bx { expr $nStmt1<=$nFree } {1} |
371 } else { | 369 } else { |
372 do_test dbstatus-3.$tn.b { expr $nStmt1==$nFree } {1} | 370 do_test dbstatus-3.$tn.b { expr $nStmt1==$nFree } {1} |
373 } | 371 } |
374 | 372 |
375 do_test dbstatus-3.$tn.c { list $nAlloc1 $nStmt1 } [list $nAlloc3 $nStmt3] | 373 do_test dbstatus-3.$tn.c { list $nAlloc1 $nStmt1 } [list $nAlloc3 $nStmt3] |
376 do_test dbstatus-3.$tn.d { list $nAlloc2 $nStmt2 } [list $nAlloc4 $nStmt4] | 374 do_test dbstatus-3.$tn.d { list $nAlloc2 $nStmt2 } [list $nAlloc4 $nStmt4] |
377 } | 375 } |
378 } | 376 } |
379 | 377 |
| 378 #------------------------------------------------------------------------- |
| 379 # The following tests focus on DBSTATUS_CACHE_USED_SHARED |
| 380 # |
| 381 ifcapable shared_cache { |
| 382 if {[permutation]=="memsys3" |
| 383 || [permutation]=="memsys5" |
| 384 || $::tcl_platform(os)=="Linux"} { |
| 385 proc do_cacheused_test {tn db res} { |
| 386 set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] |
| 387 set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] |
| 388 set cu [lindex $cu 1] |
| 389 set pcu [lindex $pcu 1] |
| 390 uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"] |
| 391 } |
| 392 reset_db |
| 393 sqlite3 db file:test.db?cache=shared |
| 394 |
| 395 do_execsql_test 4.0 { |
| 396 PRAGMA auto_vacuum=NONE; |
| 397 CREATE TABLE t1(a, b, c); |
| 398 INSERT INTO t1 VALUES(1, 2, 3); |
| 399 } |
| 400 do_cacheused_test 4.0.1 db { 4568 4568 } |
| 401 do_execsql_test 4.1 { |
| 402 CREATE TEMP TABLE tt(a, b, c); |
| 403 INSERT INTO tt VALUES(1, 2, 3); |
| 404 } |
| 405 do_cacheused_test 4.1.1 db { 9000 9000 } |
| 406 |
| 407 sqlite3 db2 file:test.db?cache=shared |
| 408 do_cacheused_test 4.2.1 db2 { 4568 2284 } |
| 409 do_cacheused_test 4.2.2 db { 9000 6716 } |
| 410 db close |
| 411 do_cacheused_test 4.2.3 db2 { 4568 4568 } |
| 412 sqlite3 db file:test.db?cache=shared |
| 413 do_cacheused_test 4.2.4 db2 { 4568 2284 } |
| 414 db2 close |
| 415 } |
| 416 } |
| 417 |
380 finish_test | 418 finish_test |
OLD | NEW |