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

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

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/sqlite/src/test/conflict2.test ('k') | third_party/sqlite/src/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
1 # 2004 August 30 1 # 2004 August 30
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. 14 # segfault if it sees a corrupt database file.
15 # 15 #
16 # $Id: corrupt2.test,v 1.20 2009/04/06 17:50:03 danielk1977 Exp $ 16 # $Id: corrupt2.test,v 1.20 2009/04/06 17:50:03 danielk1977 Exp $
17 17
18 set testdir [file dirname $argv0] 18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl 19 source $testdir/tester.tcl
20 set testprefix corrupt2
20 21
21 # 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
22 # manipulated directly using tcl scripts (using the [hexio_write] command). 23 # manipulated directly using tcl scripts (using the [hexio_write] command).
23 # 24 #
24 do_not_use_codec 25 do_not_use_codec
25 26
26 # These tests deal with corrupt database files 27 # These tests deal with corrupt database files
27 # 28 #
28 database_may_be_corrupt 29 database_may_be_corrupt
29 30
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 243
243 sqlite3 db2 corrupt.db 244 sqlite3 db2 corrupt.db
244 db2 eval $::presql 245 db2 eval $::presql
245 db2 eval {SELECT rowid FROM t1} { 246 db2 eval {SELECT rowid FROM t1} {
246 set result [db2 eval {pragma integrity_check}] 247 set result [db2 eval {pragma integrity_check}]
247 break 248 break
248 } 249 }
249 set result 250 set result
250 } {{*** in database main *** 251 } {{*** in database main ***
251 On tree page 2 cell 0: 2nd reference to page 10 252 On tree page 2 cell 0: 2nd reference to page 10
252 On tree page 2 cell 1: Child page depth differs
253 Page 4 is never used}} 253 Page 4 is never used}}
254 254
255 db2 close 255 db2 close
256 256
257 proc corruption_test {args} { 257 proc corruption_test {args} {
258 set A(-corrupt) {} 258 set A(-corrupt) {}
259 set A(-sqlprep) {} 259 set A(-sqlprep) {}
260 set A(-tclprep) {} 260 set A(-tclprep) {}
261 array set A $args 261 array set A $args
262 262
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } -test { 552 } -test {
553 do_test corrupt2-13.2 { 553 do_test corrupt2-13.2 {
554 file size corrupt.db 554 file size corrupt.db
555 } [expr $::sqlite_pending_byte + 1024] 555 } [expr $::sqlite_pending_byte + 1024]
556 do_test corrupt2-13.3 { 556 do_test corrupt2-13.3 {
557 catchsql { DELETE FROM t1 WHERE rowid < 30; } 557 catchsql { DELETE FROM t1 WHERE rowid < 30; }
558 } {1 {database disk image is malformed}} 558 } {1 {database disk image is malformed}}
559 } 559 }
560 } 560 }
561 561
562 #-------------------------------------------------------------------------
563 # Test that PRAGMA integrity_check detects cases where the freelist-count
564 # header field is smaller than the actual number of pages on the freelist.
565 #
566
567 reset_db
568 do_execsql_test 14.0 {
569 PRAGMA auto_vacuum = 0;
570 CREATE TABLE t1(x);
571 INSERT INTO t1 VALUES(randomblob(3500));
572 DELETE FROM t1;
573 }
574
575 do_execsql_test 14.1 {
576 PRAGMA integrity_check;
577 PRAGMA freelist_count;
578 } {ok 3}
579
580 # There are now 3 free pages. Modify the header-field so that it
581 # (incorrectly) says that just 2 are free.
582 do_test 14.2 {
583 db close
584 hexio_write test.db 36 [hexio_render_int32 2]
585 sqlite3 db test.db
586 execsql { PRAGMA freelist_count }
587 } {2}
588
589 do_execsql_test 14.3 {
590 PRAGMA integrity_check;
591 } {{*** in database main ***
592 Main freelist: free-page count in header is too small}}
593
594 # Use 2 of the free pages on the free-list.
595 #
596 do_execsql_test 14.4 {
597 INSERT INTO t1 VALUES(randomblob(2500));
598 PRAGMA freelist_count;
599 } {0}
600
601 do_execsql_test 14.5 {
602 PRAGMA integrity_check;
603 } {{*** in database main ***
604 Page 3 is never used}}
605
606
562 finish_test 607 finish_test
608
609 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/conflict2.test ('k') | third_party/sqlite/src/test/corrupt7.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698