Improve coverage of btree.c. (CVS 5363)

FossilOrigin-Name: f6d9cb835b8f75545f455328d61ba225e7da9bc4
This commit is contained in:
danielk1977 2008-07-08 10:19:58 +00:00
parent 983e230939
commit 3aa4b67f04
5 changed files with 134 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C Prohibit\sthe\suser\sfrom\schanging\sthe\stemporary\sstorage\smedium\s(pragma\stemp_store)\swhile\sthere\sis\sa\sread\stransaction\sopen\son\sthe\stemporary\sdatabase.\sAdd\stests\sto\sshared.test\sto\scover\sa\sfew\smore\slines\sin\sbtree.c.\s(CVS\s5362)
D 2008-07-08T07:35:52
C Improve\scoverage\sof\sbtree.c.\s(CVS\s5363)
D 2008-07-08T10:19:58
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 325dfac0a0dd1cb4d975f1ace6453157892e6042
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -242,7 +242,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6
F test/colmeta.test 087c42997754b8c648819832241daf724f813322
F test/conflict.test bb29b052c60a1f7eb6382be77902061d1f305318
F test/corrupt.test af069d971853dbe12af936910bfa49d92f7b16e9
F test/corrupt2.test 33c154628676f494bf4e7dd2c976115ed59a632d
F test/corrupt2.test bef3b73ffd7aa678be1e490bf6dd87edac848757
F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32
F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff
F test/corrupt5.test 7796d5bdfe155ed824cee9dff371f49da237cfe0
@ -356,7 +356,7 @@ F test/insert5.test 509017213328147d3acdfa2c441bfd82362dda41
F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1
F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f
F test/io.test 833a1746518ec3005aa7792f9bcb8f01923ff544
F test/ioerr.test 035470704718a2982a8d14e8a46316e6acd667ac
F test/ioerr.test 7ff1f418eae013dd848583c7f8a8cae938532f55
F test/ioerr2.test b9c9a0491a812707762a7c002876553be54d9969
F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd
F test/ioerr4.test fc6eddfec2efc2f1ed217b9eae4c1c1d3516ce86
@ -433,7 +433,7 @@ F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
F test/ptrchng.test 83150cb7b513e33cce90fdc68f4b1817551857c0
F test/quick.test 3dba257b9d4e06e1b0199bc1401052f554ab5f14
F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/rdonly.test b34db316525440d3b42c32e83942c02c37d28ef0
F test/rdonly.test bd054831f8a3078e765a0657e247182486f0cb47
F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
F test/rollback.test 0bd29070ba2f76da939347773fbda53337ebd61c
F test/rowid.test 1c8fc43c60d273e6ea44dfb992db587f3164312c
@ -600,7 +600,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 369118ca2e9da55f44b946559ad38a14efe723e5
R 64f2b20fec791858c79e62a22bfbc726
P 92e0cf9a08a8b337a8f239afb048a0e045485771
R f6b0a753332066ca84b9ccfcacf058f5
U danielk1977
Z 21ef773aee8047e84e0c419b111a78b2
Z 108e75b1f366b17292035348cfaf03b0

View File

@ -1 +1 @@
92e0cf9a08a8b337a8f239afb048a0e045485771
f6d9cb835b8f75545f455328d61ba225e7da9bc4

View File

@ -13,7 +13,7 @@
# This file implements tests to make sure SQLite does not crash or
# segfault if it sees a corrupt database file.
#
# $Id: corrupt2.test,v 1.8 2008/07/07 17:55:29 danielk1977 Exp $
# $Id: corrupt2.test,v 1.9 2008/07/08 10:19:58 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -177,7 +177,7 @@ do_test corrupt2-4.1 {
} db2
} {1 {database disk image is malformed}}
do_test corrupt2-4.1 {
do_test corrupt2-5.1 {
file delete -force corrupt.db
file delete -force corrupt.db-journal
sqlite3 db2 corrupt.db
@ -227,4 +227,93 @@ Page 4 is never used}}
db2 close
proc corruption_test {args} {
array set A $args
catch {db close}
file delete -force corrupt.db
file delete -force corrupt.db-journal
sqlite3 db corrupt.db
db eval $A(-sqlprep)
db close
eval $A(-corrupt)
sqlite3 db corrupt.db
eval $A(-test)
}
ifcapable autovacuum {
# The tests within this block - corrupt2-6.* - aim to test corruption
# detection within an incremental-vacuum. When an incremental-vacuum
# step is executed, the last non-free page of the database file is
# moved into a free space in the body of the file. After doing so,
# the page reference in the parent page must be updated to refer
# to the new location. These tests test the outcome of corrupting
# that page reference before performing the incremental vacuum.
#
# The last page in the database page is the second page
# in an overflow chain.
#
corruption_test -sqlprep {
PRAGMA auto_vacuum = incremental;
PRAGMA page_size = 1024;
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, randomblob(2500));
INSERT INTO t1 VALUES(2, randomblob(2500));
DELETE FROM t1 WHERE a = 1;
} -corrupt {
hexio_write corrupt.db [expr 1024*5] 00000008
} -test {
do_test corrupt2-6.1 {
catchsql { pragma incremental_vacuum = 1 }
} {1 {database disk image is malformed}}
}
# The last page in the database page is a non-root b-tree page.
#
corruption_test -sqlprep {
PRAGMA auto_vacuum = incremental;
PRAGMA page_size = 1024;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
INSERT INTO t1 VALUES(1, randomblob(2500));
INSERT INTO t1 VALUES(2, randomblob(50));
INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;
DELETE FROM t1 WHERE a = 1;
} -corrupt {
hexio_write corrupt.db [expr 1024*2 + 8] 00000009
} -test {
do_test corrupt2-6.2 {
catchsql { pragma incremental_vacuum = 1 }
} {1 {database disk image is malformed}}
}
# Set up a pointer-map entry so that the last page of the database
# file appears to be a b-tree root page. This should be detected
# as corruption.
#
corruption_test -sqlprep {
PRAGMA auto_vacuum = incremental;
PRAGMA page_size = 1024;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
INSERT INTO t1 VALUES(1, randomblob(2500));
INSERT INTO t1 VALUES(2, randomblob(2500));
INSERT INTO t1 VALUES(3, randomblob(2500));
DELETE FROM t1 WHERE a = 1;
} -corrupt {
set nPage [expr [file size corrupt.db] / 1024]
hexio_write corrupt.db [expr 1024 + ($nPage-3)*5] 010000000
} -test {
do_test corrupt2-6.3 {
catchsql { pragma incremental_vacuum = 1 }
} {1 {database disk image is malformed}}
}
}
finish_test

View File

@ -15,7 +15,7 @@
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr.test,v 1.37 2008/06/07 08:58:23 danielk1977 Exp $
# $Id: ioerr.test,v 1.38 2008/07/08 10:19:58 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -288,4 +288,23 @@ ifcapable memorymanage {
}
}
ifcapable pager_pragmas&&autovacuum {
do_ioerr_test ioerr-12 -ckrefcount true -erc 1 -sqlprep {
PRAGMA page_size = 512;
PRAGMA auto_vacuum = incremental;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES( randomblob(1 * (512-4)) );
INSERT INTO t1 VALUES( randomblob(110 * (512-4)) );
INSERT INTO t1 VALUES( randomblob(2 * (512-4)) );
INSERT INTO t1 VALUES( randomblob(110 * (512-4)) );
INSERT INTO t1 VALUES( randomblob(3 * (512-4)) );
DELETE FROM t1 WHERE rowid = 3;
PRAGMA incremental_vacuum = 2;
DELETE FROM t1 WHERE rowid = 1;
} -sqlbody {
PRAGMA incremental_vacuum = 1;
}
}
finish_test

View File

@ -13,7 +13,7 @@
# This file implements tests to make sure SQLite treats a database
# as readonly if its write version is set to high.
#
# $Id: rdonly.test,v 1.1 2007/04/24 17:27:52 drh Exp $
# $Id: rdonly.test,v 1.2 2008/07/08 10:19:58 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -62,4 +62,17 @@ do_test rdonly-1.5 {
}
} {0 {1 2}}
# Now, after connection [db] has loaded the database schema, modify the
# write-version of the file (and the change-counter, so that the
# write-version is reloaded). This way, SQLite does not discover that
# the database is read-only until after it is locked.
#
do_test rdonly-1.6 {
hexio_write test.db 18 02 ; # write-version
hexio_write test.db 24 11223344 ; # change-counter
catchsql {
INSERT INTO t1 VALUES(2);
}
} {1 {attempt to write a readonly database}}
finish_test