OLD | NEW |
1 # 2008 August 01 | 1 # 2008 August 01 |
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 lookaside memory allocator. | 12 # Tests for the lookaside memory allocator. |
13 # | 13 # |
14 # $Id: lookaside.test,v 1.10 2009/04/09 01:23:49 drh Exp $ | 14 # $Id: lookaside.test,v 1.10 2009/04/09 01:23:49 drh Exp $ |
15 | 15 |
16 set testdir [file dirname $argv0] | 16 set testdir [file dirname $argv0] |
17 source $testdir/tester.tcl | 17 source $testdir/tester.tcl |
18 | 18 |
19 ifcapable !lookaside { | 19 ifcapable !lookaside { |
20 finish_test | 20 finish_test |
21 return | 21 return |
22 } | 22 } |
23 | 23 |
| 24 # The tests in this file configure the lookaside allocator after a |
| 25 # connection is opened. This will not work if there is any "presql" |
| 26 # configured (SQL run within the [sqlite3] wrapper in tester.tcl). |
| 27 if {[info exists ::G(perm:presql)]} { |
| 28 finish_test |
| 29 return |
| 30 } |
| 31 |
24 catch {db close} | 32 catch {db close} |
25 sqlite3_shutdown | 33 sqlite3_shutdown |
26 sqlite3_config_pagecache 0 0 | 34 sqlite3_config_pagecache 0 0 |
27 sqlite3_config_scratch 0 0 | 35 sqlite3_config_scratch 0 0 |
28 sqlite3_initialize | 36 sqlite3_initialize |
29 autoinstall_test_functions | 37 autoinstall_test_functions |
30 sqlite3 db test.db | 38 sqlite3 db test.db |
31 | 39 |
32 # Make sure sqlite3_db_config() and sqlite3_db_status are working. | 40 # Make sure sqlite3_db_config() and sqlite3_db_status are working. |
33 # | 41 # |
34 do_test lookaside-1.1 { | 42 do_test lookaside-1.1 { |
35 catch {sqlite3_config_error db} | 43 catch {sqlite3_config_error db} |
36 } {0} | 44 } {0} |
| 45 |
37 do_test lookaside-1.2 { | 46 do_test lookaside-1.2 { |
38 sqlite3_db_config_lookaside db 1 18 18 | 47 sqlite3_db_config_lookaside db 1 18 18 |
39 } {0} | 48 } {0} |
40 do_test lookaside-1.3 { | 49 do_test lookaside-1.3.1 { |
41 sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0 | 50 sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0 |
42 } {0 0 0} | 51 } {0 0 0} |
| 52 do_test lookaside-1.3.2 { |
| 53 sqlite3_db_status db DBSTATUS_LOOKASIDE_HIT 0 |
| 54 } {0 0 0} |
| 55 do_test lookaside-1.3.3 { |
| 56 sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_SIZE 0 |
| 57 } {0 0 0} |
| 58 do_test lookaside-1.3.4 { |
| 59 sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_FULL 0 |
| 60 } {0 0 0} |
| 61 |
43 do_test lookaside-1.4 { | 62 do_test lookaside-1.4 { |
44 db eval {CREATE TABLE t1(w,x,y,z);} | 63 db eval {CREATE TABLE t1(w,x,y,z);} |
45 foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break | 64 foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break |
46 expr {$x==0 && $y<$z && $z==18} | 65 set p [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_HIT 0] 2] |
| 66 set q [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_SIZE 0] 2] |
| 67 set r [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_FULL 0] 2] |
| 68 expr {$x==0 && $y<$z && $z==18 && $p>0 && $q>0 && $r>0} |
47 } {0} | 69 } {0} |
48 do_test lookaside-1.5 { | 70 do_test lookaside-1.5 { |
49 foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break | 71 foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break |
50 expr {$x==0 && $y<$z && $z==18} | 72 expr {$x==0 && $y<$z && $z==18} |
51 } {0} | 73 } {0} |
52 do_test lookaside-1.6 { | 74 do_test lookaside-1.6 { |
53 foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break | 75 foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break |
54 expr {$x==0 && $y==$z && $y<18} | 76 expr {$x==0 && $y==$z && $y<18} |
55 } {1} | 77 } {1} |
56 do_test lookaside-1.7 { | 78 do_test lookaside-1.7 { |
57 db cache flush | 79 db cache flush |
58 foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break | 80 foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break |
59 expr {$x==0 && $y==0 && $z<18} | 81 expr {$x==0 && $y==0 && $z<18} |
60 } {1} | 82 } {1} |
61 do_test lookaside-1.8 { | 83 do_test lookaside-1.8 { |
62 db cache flush | 84 db cache flush |
63 foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 1] break | 85 foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break |
64 expr {$x==0 && $y==0 && $z<18} | 86 expr {$x==0 && $y==0 && $z<18} |
65 } {1} | 87 } {1} |
66 do_test lookaside-1.9 { | 88 do_test lookaside-1.9 { |
67 db cache flush | 89 db cache flush |
68 sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0 | 90 sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0 |
69 } {0 0 0} | 91 } {0 0 0} |
70 | 92 |
71 do_test lookaside-2.1 { | 93 do_test lookaside-2.1 { |
72 sqlite3_db_config_lookaside db 0 100 1000 | 94 sqlite3_db_config_lookaside db 0 100 1000 |
73 } {0} | 95 } {0} |
74 do_test lookaside-2.2 { | 96 do_test lookaside-2.2 { |
75 db eval {CREATE TABLE t2(x);} | 97 db eval {CREATE TABLE t2(x);} |
76 foreach {x y z} [sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0] break | 98 foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break |
77 expr {$x==0 && $y<$z && $z>10 && $z<100} | 99 expr {$x==0 && $y<$z && $z>10 && $z<100} |
78 } {1} | 100 } {1} |
79 do_test lookaside-2.3 { | 101 do_test lookaside-2.3 { |
80 sqlite3_db_config_lookaside db 0 50 50 | 102 sqlite3_db_config_lookaside db 0 50 50 |
81 } {5} ;# SQLITE_BUSY | 103 } {5} ;# SQLITE_BUSY |
82 do_test lookaside-2.4 { | 104 do_test lookaside-2.4 { |
83 db cache flush | 105 db cache flush |
84 sqlite3_db_config_lookaside db 0 50 50 | 106 sqlite3_db_config_lookaside db 0 50 50 |
85 } {0} ;# SQLITE_OK | 107 } {0} ;# SQLITE_OK |
86 do_test lookaside-2.5 { | 108 do_test lookaside-2.5 { |
(...skipping 14 matching lines...) Expand all Loading... |
101 # | 123 # |
102 do_test lookaside-4.1 { | 124 do_test lookaside-4.1 { |
103 db close | 125 db close |
104 sqlite3_shutdown | 126 sqlite3_shutdown |
105 catch sqlite3_config_error | 127 catch sqlite3_config_error |
106 } {0} | 128 } {0} |
107 sqlite3_initialize | 129 sqlite3_initialize |
108 autoinstall_test_functions | 130 autoinstall_test_functions |
109 | 131 |
110 finish_test | 132 finish_test |
OLD | NEW |