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

Side by Side Diff: third_party/sqlite/src/test/corrupt9.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 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
OLDNEW
1 # 2008 July 9 1 # 2008 July 9
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 # This file implements regression tests for SQLite library. 11 # This file implements regression tests for SQLite library.
12 # 12 #
13 # This file implements tests to make sure SQLite does not crash or 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 14 # segfault if it sees a corrupt database file. It specifically focuses
15 # on corruption in the form of duplicate entries on the freelist. 15 # on corruption in the form of duplicate entries on the freelist.
16 # 16 #
17 # $Id: corrupt9.test,v 1.3 2009/06/04 02:47:04 shane Exp $ 17 # $Id: corrupt9.test,v 1.3 2009/06/04 02:47:04 shane Exp $
18 18
19 set testdir [file dirname $argv0] 19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl 20 source $testdir/tester.tcl
21 21
22 # Do not use a codec for tests in this file, as the database file is 22 # Do not use a codec for tests in this file, as the database file is
23 # manipulated directly using tcl scripts (using the [hexio_write] command). 23 # manipulated directly using tcl scripts (using the [hexio_write] command).
24 # 24 #
25 do_not_use_codec 25 do_not_use_codec
26 26
27 # These tests deal with corrupt database files
28 #
29 database_may_be_corrupt
30
27 # We must have the page_size pragma for these tests to work. 31 # We must have the page_size pragma for these tests to work.
28 # 32 #
29 ifcapable !pager_pragmas { 33 ifcapable !pager_pragmas {
30 finish_test 34 finish_test
31 return 35 return
32 } 36 }
33 37
34 # Return the offset to the first (trunk) page of the freelist. Return 38 # Return the offset to the first (trunk) page of the freelist. Return
35 # zero of the freelist is empty. 39 # zero of the freelist is empty.
36 # 40 #
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 DROP INDEX i2; 83 DROP INDEX i2;
80 } 84 }
81 expr {[file size test.db]>1024*24} 85 expr {[file size test.db]>1024*24}
82 } {1} 86 } {1}
83 integrity_check corrupt9-1.2 87 integrity_check corrupt9-1.2
84 88
85 # Corrupt the freelist by adding duplicate entries to the freelist. 89 # Corrupt the freelist by adding duplicate entries to the freelist.
86 # Make sure the corruption is detected. 90 # Make sure the corruption is detected.
87 # 91 #
88 db close 92 db close
89 file copy -force test.db test.db-template 93 forcecopy test.db test.db-template
90 94
91 corrupt_freelist test.db 1 95 corrupt_freelist test.db 1
92 sqlite3 db test.db 96 sqlite3 db test.db
93 do_test corrupt9-2.1 { 97 do_test corrupt9-2.1 {
94 set x [db eval {PRAGMA integrity_check}] 98 set x [db eval {PRAGMA integrity_check}]
95 expr {$x!="ok"} 99 expr {$x!="ok"}
96 } {1} 100 } {1}
97 do_test corrupt9-2.2 { 101 do_test corrupt9-2.2 {
98 catchsql { 102 catchsql {
99 CREATE INDEX i2 ON t2(b,a); 103 CREATE INDEX i2 ON t2(b,a);
100 REINDEX; 104 REINDEX;
101 } 105 }
102 } {1 {database disk image is malformed}} 106 } {1 {database disk image is malformed}}
103 107
104 108
105 db close 109 db close
106 file copy -force test.db-template test.db 110 forcecopy test.db-template test.db
107 corrupt_freelist test.db 2 111 corrupt_freelist test.db 2
108 sqlite3 db test.db 112 sqlite3 db test.db
109 do_test corrupt9-3.1 { 113 do_test corrupt9-3.1 {
110 set x [db eval {PRAGMA integrity_check}] 114 set x [db eval {PRAGMA integrity_check}]
111 expr {$x!="ok"} 115 expr {$x!="ok"}
112 } {1} 116 } {1}
113 do_test corrupt9-3.2 { 117 do_test corrupt9-3.2 {
114 catchsql { 118 catchsql {
115 CREATE INDEX i2 ON t2(b,a); 119 CREATE INDEX i2 ON t2(b,a);
116 REINDEX; 120 REINDEX;
117 } 121 }
118 } {1 {database disk image is malformed}} 122 } {1 {database disk image is malformed}}
119 123
120 db close 124 db close
121 file copy -force test.db-template test.db 125 forcecopy test.db-template test.db
122 corrupt_freelist test.db 3 126 corrupt_freelist test.db 3
123 sqlite3 db test.db 127 sqlite3 db test.db
124 do_test corrupt9-4.1 { 128 do_test corrupt9-4.1 {
125 set x [db eval {PRAGMA integrity_check}] 129 set x [db eval {PRAGMA integrity_check}]
126 expr {$x!="ok"} 130 expr {$x!="ok"}
127 } {1} 131 } {1}
128 do_test corrupt9-4.2 { 132 do_test corrupt9-4.2 {
129 catchsql { 133 catchsql {
130 CREATE INDEX i2 ON t2(b,a); 134 CREATE INDEX i2 ON t2(b,a);
131 REINDEX; 135 REINDEX;
132 } 136 }
133 } {1 {database disk image is malformed}} 137 } {1 {database disk image is malformed}}
134 138
135 139
136 finish_test 140 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698