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

Side by Side Diff: third_party/sqlite/test/corrupt3.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/corrupt2.test ('k') | third_party/sqlite/test/corrupt4.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 # 2007 April 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.
15 #
16 # $Id: corrupt3.test,v 1.2 2007/04/06 21:42:22 drh Exp $
17
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20
21 # We must have the page_size pragma for these tests to work.
22 #
23 ifcapable !pager_pragmas {
24 finish_test
25 return
26 }
27
28 # Create a database with an overflow page.
29 #
30 do_test corrupt3-1.1 {
31 set bigstring [string repeat 0123456789 200]
32 execsql {
33 PRAGMA auto_vacuum=OFF;
34 PRAGMA page_size=1024;
35 CREATE TABLE t1(x);
36 INSERT INTO t1 VALUES($bigstring);
37 }
38 file size test.db
39 } [expr {1024*3}]
40
41 # Verify that the file format is as we expect. The page size
42 # should be 1024 bytes. The only record should have a single
43 # overflow page. The overflow page is page 3. The pointer to
44 # the overflow page is on the last 4 bytes of page 2.
45 #
46 do_test corrupt3-1.2 {
47 hexio_get_int [hexio_read test.db 16 2]
48 } 1024 ;# The page size is 1024
49 do_test corrupt3-1.3 {
50 hexio_get_int [hexio_read test.db 20 1]
51 } 0 ;# Unused bytes per page is 0
52 do_test corrupt3-1.4 {
53 hexio_get_int [hexio_read test.db 2044 4]
54 } 3 ;# Overflow page is 3
55 do_test corrupt3-1.5 {
56 hexio_get_int [hexio_read test.db 2048 4]
57 } 0 ;# First chained overflow is 0
58
59 integrity_check corrupt3-1.6
60
61 # Make the overflow chain loop back on itself. See if the
62 # corruption is detected. (Actually, the last pointer in
63 # an overflow chain is ignored, so this is not an error.)
64 #
65 do_test corrupt3-1.7 {
66 db close
67 hexio_write test.db 2048 [hexio_render_int32 3]
68 sqlite3 db test.db
69 catchsql {
70 SELECT x FROM t1
71 }
72 } [list 0 $bigstring]
73 integrity_check corrupt3-1.8
74
75 # Change the pointer for the first page of the overflow
76 # change to be a non-existant page.
77 #
78 do_test corrupt3-1.9 {
79 db close
80 hexio_write test.db 2044 [hexio_render_int32 4]
81 sqlite3 db test.db
82 catchsql {
83 SELECT substr(x,1,10) FROM t1
84 }
85 } [list 0 0123456789]
86 do_test corrupt3-1.10 {
87 catchsql {
88 PRAGMA integrity_check
89 }
90 } {0 {{*** in database main ***
91 On tree page 2 cell 0: invalid page number 4
92 Page 3 is never used}}}
93 do_test corrupt3-1.11 {
94 db close
95 hexio_write test.db 2044 [hexio_render_int32 0]
96 sqlite3 db test.db
97 catchsql {
98 SELECT substr(x,1,10) FROM t1
99 }
100 } [list 1 {database disk image is malformed}]
101 do_test corrupt3-1.12 {
102 catchsql {
103 PRAGMA integrity_check
104 }
105 } {0 {{*** in database main ***
106 On tree page 2 cell 0: 1 of 1 pages missing from overflow list starting at 0
107 Page 3 is never used}}}
108
109 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/corrupt2.test ('k') | third_party/sqlite/test/corrupt4.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698