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

Side by Side Diff: third_party/sqlite/src/ext/rtree/rtree3.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
OLDNEW
1 # 2008 Feb 19 1 # 2008 Feb 19
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 # The focus of this file is testing that the r-tree correctly handles 12 # The focus of this file is testing that the r-tree correctly handles
13 # out-of-memory conditions. 13 # out-of-memory conditions.
14 # 14 #
15 # $Id: rtree3.test,v 1.2 2008/06/23 15:55:52 danielk1977 Exp $
16 #
17 15
18 if {![info exists testdir]} { 16 if {![info exists testdir]} {
19 set testdir [file join [file dirname $argv0] .. .. test] 17 set testdir [file join [file dirname [info script]] .. .. test]
20 } 18 }
21 source $testdir/tester.tcl 19 source $testdir/tester.tcl
22 20 source $testdir/malloc_common.tcl
23 ifcapable !rtree { 21 ifcapable !rtree {
24 finish_test 22 finish_test
25 return 23 return
26 } 24 }
27 25
28 # Only run these tests if memory debugging is turned on. 26 # Test summary:
29 # 27 #
30 source $testdir/malloc_common.tcl 28 # rtree3-1: Test OOM in simple CREATE TABLE, INSERT, DELETE and SELECT
31 if {!$MEMDEBUG} { 29 # commands on an almost empty table.
32 puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..." 30 #
33 finish_test 31 # rtree3-2: Test OOM in a DROP TABLE command.
34 return 32 #
33 # rtree3-3a: Test OOM during a transaction to insert 100 pseudo-random rows.
34 #
35 # rtree3-3b: Test OOM during a transaction deleting all entries in the
36 # database constructed in [rtree3-3a] in pseudo-random order.
37 #
38 # rtree3-4a: OOM during "SELECT count(*) FROM ..." on a big table.
39 #
40 # rtree3-4b: OOM while deleting rows from a big table.
41 #
42 # rtree3-5: Test OOM while inserting rows into a big table.
43 #
44 # rtree3-6: Test OOM while deleting all rows of a table, one at a time.
45 #
46 # rtree3-7: OOM during an ALTER TABLE RENAME TABLE command.
47 #
48 # rtree3-8: Test OOM while registering the r-tree module with sqlite.
49 #
50
51 do_faultsim_test rtree3-1 -faults oom* -prep {
52 faultsim_delete_and_reopen
53 } -body {
54 execsql {
55 BEGIN TRANSACTION;
56 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
57 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);
58 INSERT INTO rt VALUES(NULL, 13, 15, 17, 19);
59 DELETE FROM rt WHERE ii = 1;
60 SELECT * FROM rt;
61 SELECT ii FROM rt WHERE ii = 2;
62 COMMIT;
63 }
35 } 64 }
36 65
37 do_malloc_test rtree3-1 -sqlbody { 66 do_test rtree3-2.prep {
38 BEGIN TRANSACTION; 67 faultsim_delete_and_reopen
39 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); 68 execsql {
40 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9); 69 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
41 INSERT INTO rt VALUES(NULL, 13, 15, 17, 19); 70 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);
42 DELETE FROM rt WHERE ii = 1; 71 }
43 SELECT * FROM rt; 72 faultsim_save_and_close
44 SELECT ii FROM rt WHERE ii = 2; 73 } {}
45 COMMIT; 74 do_faultsim_test rtree3-2 -faults oom* -prep {
46 } 75 faultsim_restore_and_reopen
47 do_malloc_test rtree3-2 -sqlprep { 76 } -body {
48 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); 77 execsql { DROP TABLE rt }
49 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9); 78 }
50 } -sqlbody {
51 DROP TABLE rt;
52 }
53 79
80 do_malloc_test rtree3-3.prep {
81 faultsim_delete_and_reopen
82 execsql {
83 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
84 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);
85 }
86 faultsim_save_and_close
87 } {}
54 88
55 do_malloc_test rtree3-3 -sqlprep { 89 do_faultsim_test rtree3-3a -faults oom* -prep {
56 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); 90 faultsim_restore_and_reopen
57 INSERT INTO rt VALUES(NULL, 3, 5, 7, 9); 91 } -body {
58 } -tclbody {
59 db eval BEGIN 92 db eval BEGIN
60 for {set ii 0} {$ii < 100} {incr ii} { 93 for {set ii 0} {$ii < 100} {incr ii} {
61 set f [expr rand()] 94 set f [expr rand()]
62 db eval {INSERT INTO rt VALUES(NULL, $f*10.0, $f*10.0, $f*15.0, $f*15.0)} 95 db eval {INSERT INTO rt VALUES(NULL, $f*10.0, $f*10.0, $f*15.0, $f*15.0)}
63 } 96 }
64 db eval COMMIT 97 db eval COMMIT
98 }
99 faultsim_save_and_close
100
101 do_faultsim_test rtree3-3b -faults oom* -prep {
102 faultsim_restore_and_reopen
103 } -body {
65 db eval BEGIN 104 db eval BEGIN
66 for {set ii 0} {$ii < 100} {incr ii} { 105 for {set ii 0} {$ii < 100} {incr ii} {
67 set f [expr rand()] 106 set f [expr rand()]
68 db eval { DELETE FROM rt WHERE x1<($f*10.0) AND x1>($f*10.5) } 107 db eval { DELETE FROM rt WHERE x1<($f*10.0) AND x1>($f*10.5) }
69 } 108 }
70 db eval COMMIT 109 db eval COMMIT
71 } 110 }
72 111
112 do_test rtree3-4.prep {
113 faultsim_delete_and_reopen
114 execsql {
115 BEGIN;
116 PRAGMA page_size = 512;
117 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
118 }
119 for {set i 0} {$i < 1500} {incr i} {
120 execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }
121 }
122 execsql { COMMIT }
123 faultsim_save_and_close
124 } {}
125
126 do_faultsim_test rtree3-4a -faults oom-* -prep {
127 faultsim_restore_and_reopen
128 } -body {
129 db eval { SELECT count(*) FROM rt }
130 } -test {
131 faultsim_test_result {0 1500}
132 }
133
134 do_faultsim_test rtree3-4b -faults oom-transient -prep {
135 faultsim_restore_and_reopen
136 } -body {
137 db eval { DELETE FROM rt WHERE ii BETWEEN 1 AND 100 }
138 } -test {
139 faultsim_test_result {0 {}}
140 }
141
142 do_test rtree3-5.prep {
143 faultsim_delete_and_reopen
144 execsql {
145 BEGIN;
146 PRAGMA page_size = 512;
147 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
148 }
149 for {set i 0} {$i < 100} {incr i} {
150 execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }
151 }
152 execsql { COMMIT }
153 faultsim_save_and_close
154 } {}
155 do_faultsim_test rtree3-5 -faults oom-* -prep {
156 faultsim_restore_and_reopen
157 } -body {
158 for {set i 100} {$i < 110} {incr i} {
159 execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }
160 }
161 } -test {
162 faultsim_test_result {0 {}}
163 }
164
165 do_test rtree3-6.prep {
166 faultsim_delete_and_reopen
167 execsql {
168 BEGIN;
169 PRAGMA page_size = 512;
170 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
171 }
172 for {set i 0} {$i < 50} {incr i} {
173 execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }
174 }
175 execsql { COMMIT }
176 faultsim_save_and_close
177 } {}
178 do_faultsim_test rtree3-6 -faults oom-* -prep {
179 faultsim_restore_and_reopen
180 } -body {
181 execsql BEGIN
182 for {set i 0} {$i < 50} {incr i} {
183 execsql { DELETE FROM rt WHERE ii=$i }
184 }
185 execsql COMMIT
186 } -test {
187 faultsim_test_result {0 {}}
188 }
189
190 do_test rtree3-7.prep {
191 faultsim_delete_and_reopen
192 execsql { CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2) }
193 faultsim_save_and_close
194 } {}
195 do_faultsim_test rtree3-7 -faults oom-* -prep {
196 faultsim_restore_and_reopen
197 } -body {
198 execsql { ALTER TABLE rt RENAME TO rt2 }
199 } -test {
200 faultsim_test_result {0 {}}
201 }
202
203 do_faultsim_test rtree3-8 -faults oom-* -prep {
204 catch { db close }
205 } -body {
206 sqlite3 db test.db
207 }
208
209 do_faultsim_test rtree3-9 -faults oom-* -prep {
210 sqlite3 db :memory:
211 } -body {
212 set rc [register_cube_geom db]
213 if {$rc != "SQLITE_OK"} { error $rc }
214 } -test {
215 faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
216 }
217
218 do_test rtree3-10.prep {
219 faultsim_delete_and_reopen
220 execsql {
221 CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2, z1, z2);
222 INSERT INTO rt VALUES(1, 10, 10, 10, 11, 11, 11);
223 INSERT INTO rt VALUES(2, 5, 6, 6, 7, 7, 8);
224 }
225 faultsim_save_and_close
226 } {}
227 do_faultsim_test rtree3-10 -faults oom-* -prep {
228 faultsim_restore_and_reopen
229 register_cube_geom db
230 execsql { SELECT * FROM rt }
231 } -body {
232 execsql { SELECT ii FROM rt WHERE ii MATCH cube(4.5, 5.5, 6.5, 1, 1, 1) }
233 } -test {
234 faultsim_test_result {0 2}
235 }
236
73 finish_test 237 finish_test
74
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/rtree/rtree2.test ('k') | third_party/sqlite/src/ext/rtree/rtree4.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698