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

Side by Side Diff: third_party/sqlite/test/corrupt6.test

Issue 3108030: Move bundled copy of sqlite one level deeper to better separate it... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
« no previous file with comments | « third_party/sqlite/test/corrupt5.test ('k') | third_party/sqlite/test/corrupt7.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2008 May 6
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
9 #
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
12 #
13 # This file implements tests to make sure SQLite does not crash or
14 # segfault if it sees a corrupt database file. It specifically focuses
15 # on corrupt SerialTypeLen values.
16 #
17 # $Id: corrupt6.test,v 1.2 2008/05/19 15:37:10 shane Exp $
18
19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl
21
22 # We must have the page_size pragma for these tests to work.
23 #
24 ifcapable !pager_pragmas {
25 finish_test
26 return
27 }
28
29 # Create a simple, small database.
30 #
31 do_test corrupt6-1.1 {
32 execsql {
33 PRAGMA auto_vacuum=OFF;
34 PRAGMA page_size=1024;
35 CREATE TABLE t1(x);
36 INSERT INTO t1(x) VALUES('varint32-01234567890123456789012345678901234567890 123456789');
37 INSERT INTO t1(x) VALUES('varint32-01234567890123456789012345678901234567890 123456789');
38 }
39 file size test.db
40 } [expr {1024*2}]
41
42 # Verify that the file format is as we expect. The page size
43 # should be 1024 bytes.
44 #
45 do_test corrupt6-1.2 {
46 hexio_get_int [hexio_read test.db 16 2]
47 } 1024 ;# The page size is 1024
48 do_test corrupt6-1.3 {
49 hexio_get_int [hexio_read test.db 20 1]
50 } 0 ;# Unused bytes per page is 0
51
52 integrity_check corrupt6-1.4
53
54 # Verify SerialTypeLen for first field of two records as we expect.
55 # SerialTypeLen = (len*2+12) = 60*2+12 = 132
56 do_test corrupt6-1.5.1 {
57 hexio_read test.db 1923 2
58 } 8103 ;# First text field size is 81 03 == 131
59 do_test corrupt6-1.5.2 {
60 hexio_read test.db 1987 2
61 } 8103 ;# Second text field size is 81 03 == 131
62
63 # Verify simple query results as expected.
64 do_test corrupt6-1.6 {
65 db close
66 sqlite3 db test.db
67 catchsql {
68 SELECT substr(x,1,8) FROM t1
69 }
70 } [list 0 {varint32 varint32} ]
71 integrity_check corrupt6-1.7
72
73 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
74 # corruption is detected.
75 # Increase SerialTypeLen by 2.
76 do_test corrupt6-1.8.1 {
77 db close
78 hexio_write test.db 1923 8105
79 sqlite3 db test.db
80 catchsql {
81 SELECT substr(x,1,8) FROM t1
82 }
83 } [list 1 {database disk image is malformed}]
84
85 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
86 # corruption is detected.
87 # Decrease SerialTypeLen by 2.
88 do_test corrupt6-1.8.2 {
89 db close
90 hexio_write test.db 1923 8101
91 sqlite3 db test.db
92 catchsql {
93 SELECT substr(x,1,8) FROM t1
94 }
95 } [list 1 {database disk image is malformed}]
96
97 # Put value of record 1 / field 1 SerialTypeLen back.
98 do_test corrupt6-1.8.3 {
99 db close
100 hexio_write test.db 1923 8103
101 sqlite3 db test.db
102 catchsql {
103 SELECT substr(x,1,8) FROM t1
104 }
105 } [list 0 {varint32 varint32} ]
106 integrity_check corrupt6-1.8.4
107
108 # Adjust value of record 2 / field 1 SerialTypeLen and see if the
109 # corruption is detected.
110 # Increase SerialTypeLen by 2.
111 do_test corrupt6-1.9.1 {
112 db close
113 hexio_write test.db 1987 8105
114 sqlite3 db test.db
115 catchsql {
116 SELECT substr(x,1,8) FROM t1
117 }
118 } [list 1 {database disk image is malformed}]
119
120 # Adjust value of record 2 / field 2 SerialTypeLen and see if the
121 # corruption is detected.
122 # Decrease SerialTypeLen by 2.
123 do_test corrupt6-1.9.2 {
124 db close
125 hexio_write test.db 1987 8101
126 sqlite3 db test.db
127 catchsql {
128 SELECT substr(x,1,8) FROM t1
129 }
130 } [list 1 {database disk image is malformed}]
131
132 # Put value of record 1 / field 2 SerialTypeLen back.
133 do_test corrupt6-1.9.3 {
134 db close
135 hexio_write test.db 1987 8103
136 sqlite3 db test.db
137 catchsql {
138 SELECT substr(x,1,8) FROM t1
139 }
140 } [list 0 {varint32 varint32} ]
141 integrity_check corrupt6-1.9.4
142
143 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
144 # corruption is detected.
145 # Set SerialTypeLen to FF 7F (2 bytes)
146 do_test corrupt6-1.10.1 {
147 db close
148 hexio_write test.db 1923 FF7F
149 sqlite3 db test.db
150 catchsql {
151 SELECT substr(x,1,8) FROM t1
152 }
153 } [list 1 {database disk image is malformed}]
154
155 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
156 # corruption is detected.
157 # Set SerialTypeLen to FF FF 7F (3 bytes)
158 do_test corrupt6-1.10.2 {
159 db close
160 hexio_write test.db 1923 FFFF7F
161 sqlite3 db test.db
162 catchsql {
163 SELECT substr(x,1,8) FROM t1
164 }
165 } [list 1 {database disk image is malformed}]
166
167 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
168 # corruption is detected.
169 # Set SerialTypeLen to FF FF FF 7F (4 bytes)
170 do_test corrupt6-1.10.3 {
171 db close
172 hexio_write test.db 1923 FFFFFF7F
173 sqlite3 db test.db
174 catchsql {
175 SELECT substr(x,1,8) FROM t1
176 }
177 } [list 1 {database disk image is malformed}]
178
179 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
180 # corruption is detected.
181 # Set SerialTypeLen to FF FF FF FF 7F (5 bytes)
182 do_test corrupt6-1.10.4 {
183 db close
184 hexio_write test.db 1923 FFFFFFFF7F
185 sqlite3 db test.db
186 catchsql {
187 SELECT substr(x,1,8) FROM t1
188 }
189 } [list 1 {database disk image is malformed}]
190
191 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
192 # corruption is detected.
193 # Set SerialTypeLen to FF FF FF FF FF 7F (6 bytes, and overflows).
194 do_test corrupt6-1.10.5 {
195 db close
196 hexio_write test.db 1923 FFFFFFFFFF7F
197 sqlite3 db test.db
198 catchsql {
199 SELECT substr(x,1,8) FROM t1
200 }
201 } [list 1 {database disk image is malformed}]
202
203 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
204 # corruption is detected.
205 # Set SerialTypeLen to FF FF FF FF FF FF 7F (7 bytes, and overflows).
206 do_test corrupt6-1.10.6 {
207 db close
208 hexio_write test.db 1923 FFFFFFFFFFFF7F
209 sqlite3 db test.db
210 catchsql {
211 SELECT substr(x,1,8) FROM t1
212 }
213 } [list 1 {database disk image is malformed}]
214
215 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
216 # corruption is detected.
217 # Set SerialTypeLen to FF FF FF FF FF FF FF 7F (8 bytes, and overflows).
218 do_test corrupt6-1.10.7 {
219 db close
220 hexio_write test.db 1923 FFFFFFFFFFFFFF7F
221 sqlite3 db test.db
222 catchsql {
223 SELECT substr(x,1,8) FROM t1
224 }
225 } [list 1 {database disk image is malformed}]
226
227 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
228 # corruption is detected.
229 # Set SerialTypeLen to FF FF FF FF FF FF FF FF 7F (9 bytes, and overflows).
230 do_test corrupt6-1.10.8 {
231 db close
232 hexio_write test.db 1923 FFFFFFFFFFFFFFFF7F
233 sqlite3 db test.db
234 catchsql {
235 SELECT substr(x,1,8) FROM t1
236 }
237 } [list 1 {database disk image is malformed}]
238
239 # Adjust value of record 1 / field 1 SerialTypeLen and see if the
240 # corruption is detected.
241 # Set SerialTypeLen to FFFF FF FF FF FF FF FF FF 7F (10 bytes, and overflows).
242 do_test corrupt6-1.10.9 {
243 db close
244 hexio_write test.db 1923 FFFFFFFFFFFFFFFFFF7F
245 sqlite3 db test.db
246 catchsql {
247 SELECT substr(x,1,8) FROM t1
248 }
249 } [list 1 {database disk image is malformed}]
250
251 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/corrupt5.test ('k') | third_party/sqlite/test/corrupt7.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698