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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/corrupt4.test

Issue 2363173002: [sqlite] Remove obsolete reference version 3.8.7.4. (Closed)
Patch Set: Created 4 years, 2 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
(Empty)
1 # 2007 Sept 7
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: corrupt4.test,v 1.1 2007/09/07 14:32:07 drh Exp $
17
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20
21 # Do not use a codec for tests in this file, as the database file is
22 # manipulated directly using tcl scripts (using the [hexio_write] command).
23 #
24 do_not_use_codec
25
26 # These tests deal with corrupt database files
27 #
28 database_may_be_corrupt
29
30 # We must have the page_size pragma for these tests to work.
31 #
32 ifcapable !pager_pragmas {
33 finish_test
34 return
35 }
36
37 # Create a database with a freelist containing at least two pages.
38 #
39 do_test corrupt4-1.1 {
40 set bigstring [string repeat 0123456789 200]
41 execsql {
42 PRAGMA auto_vacuum=OFF;
43 PRAGMA page_size=1024;
44 CREATE TABLE t1(x);
45 INSERT INTO t1 VALUES($bigstring);
46 CREATE TABLE t2(y);
47 INSERT INTO t2 VALUES(1);
48 DROP TABLE t1;
49 }
50 file size test.db
51 } [expr {1024*4}]
52
53 # Verify that there are two pages on the freelist.
54 #
55 do_test corrupt4-1.2 {
56 execsql {PRAGMA freelist_count}
57 } {2}
58
59 # Get the page number for the trunk of the freelist.
60 #
61 set trunkpgno [hexio_get_int [hexio_read test.db 32 4]]
62 set baseaddr [expr {($trunkpgno-1)*1024}]
63
64 # Verify that the trunk of the freelist has exactly one
65 # leaf.
66 #
67 do_test corrupt4-1.3 {
68 hexio_get_int [hexio_read test.db [expr {$::baseaddr+4}] 4]
69 } {1}
70
71 # Insert a negative number as the number of leaves on the trunk.
72 # Then try to add a new element to the freelist.
73 #
74 do_test corrupt4-1.4 {
75 hexio_write test.db [expr {$::baseaddr+4}] [hexio_render_int32 -100000000]
76 db close
77 sqlite3 db test.db
78 catchsql {
79 DROP TABLE t2
80 }
81 } {1 {database disk image is malformed}}
82
83 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/corrupt3.test ('k') | third_party/sqlite/sqlite-src-3080704/test/corrupt5.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698