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

Side by Side Diff: third_party/sqlite/test/corrupt8.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/corrupt7.test ('k') | third_party/sqlite/test/corrupt9.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 July 9
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 pointer map pages.
16 #
17 # $Id: corrupt8.test,v 1.2 2008/07/11 03:34:10 drh 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||!autovacuum {
25 finish_test
26 return
27 }
28
29 # Create a database to work with.
30 #
31 do_test corrupt8-1.1 {
32 execsql {
33 PRAGMA auto_vacuum=1;
34 PRAGMA page_size=1024;
35 CREATE TABLE t1(x);
36 INSERT INTO t1(x) VALUES(1);
37 INSERT INTO t1(x) VALUES(2);
38 INSERT INTO t1(x) SELECT x+2 FROM t1;
39 INSERT INTO t1(x) SELECT x+4 FROM t1;
40 INSERT INTO t1(x) SELECT x+8 FROM t1;
41 INSERT INTO t1(x) SELECT x+16 FROM t1;
42 INSERT INTO t1(x) SELECT x+32 FROM t1;
43 INSERT INTO t1(x) SELECT x+64 FROM t1;
44 INSERT INTO t1(x) SELECT x+128 FROM t1;
45 INSERT INTO t1(x) SELECT x+256 FROM t1;
46 CREATE TABLE t2(a,b);
47 INSERT INTO t2 SELECT x, x*x FROM t1;
48 }
49 expr {[file size test.db]>1024*12}
50 } {1}
51 integrity_check corrupt8-1.2
52
53 # Loop through each ptrmap entry. Corrupt the entry and make sure the
54 # corruption is detected by the integrity_check.
55 #
56 for {set i 1024} {$i<2048} {incr i 5} {
57 set oldval [hexio_read test.db $i 1]
58 if {$oldval==0} break
59 hexio_write test.db $i 00
60 do_test corrupt8-2.$i.0 {
61 db close
62 sqlite3 db test.db
63 set x [db eval {PRAGMA integrity_check}]
64 expr {$x!="ok"}
65 } {1}
66 for {set k 1} {$k<=5} {incr k} {
67 if {$k==$oldval} continue
68 hexio_write test.db $i 0$k
69 do_test corrupt8-2.$i.$k {
70 db close
71 sqlite3 db test.db
72 set x [db eval {PRAGMA integrity_check}]
73 expr {$x!="ok"}
74 } {1}
75 }
76 hexio_write test.db $i 06
77 do_test corrupt8-2.$i.6 {
78 db close
79 sqlite3 db test.db
80 set x [db eval {PRAGMA integrity_check}]
81 expr {$x!="ok"}
82 } {1}
83 hexio_write test.db $i $oldval
84 if {$oldval>2} {
85 set i2 [expr {$i+1+$i%4}]
86 set oldval [hexio_read test.db $i2 1]
87 hexio_write test.db $i2 [format %02x [expr {($oldval+1)&0xff}]]
88 do_test corrupt8-2.$i.7 {
89 db close
90 sqlite3 db test.db
91 set x [db eval {PRAGMA integrity_check}]
92 expr {$x!="ok"}
93 } {1}
94 hexio_write test.db $i2 $oldval
95 }
96 }
97
98
99 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/corrupt7.test ('k') | third_party/sqlite/test/corrupt9.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698