Add test cases to pager1.test and pagerfault.test.

FossilOrigin-Name: 4941e437d2638f36ac8510d4a5b4c780afc798bb
This commit is contained in:
dan 2010-06-24 19:16:06 +00:00
parent 314f30db22
commit ec6ffc1a6a
4 changed files with 197 additions and 25 deletions

View File

@ -1,8 +1,5 @@
-----BEGIN PGP SIGNED MESSAGE----- C Add\stest\scases\sto\spager1.test\sand\spagerfault.test.
Hash: SHA1 D 2010-06-24T19:16:06
C Revert\sto\sallowing\sa\scache\sspill\sduring\swrites\sof\smultiple\spages\swithin\sa\nsingle\ssector\sas\slong\sas\sthe\sspill\sdoes\snot\srequire\sa\sjournal\ssync\sand\sa\nnew\sjournal\sheader.
D 2010-06-24T18:36:33
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -537,9 +534,9 @@ F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
F test/pager1.test 2fb769a4f121b4e27525ea7e38d6d0176a0c2a9f F test/pager1.test b7099656ae9162fd192b13fafab0361c2a910022
F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
F test/pagerfault.test 07675504c11afc17aaad80e29eb52280410b32fd F test/pagerfault.test a48c4ed81ab7ebb11a65d97a7332026d19beb2a4
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806 F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
F test/pcache.test 4118a183908ecaed343a06fcef3ba82e87e0129d F test/pcache.test 4118a183908ecaed343a06fcef3ba82e87e0129d
@ -828,14 +825,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P c6db3b303182202a8b03512e448607bce71de914 P 7d83fbae9802a56b2121d0775de54fccd743d971
R f1c7e6ef66554c4040e7c5982474605c R 43cdd6cd887c3657632da5d79f140434
U drh U dan
Z f3f5cfd0105de6cc2c8193ae310c7e35 Z 18163dae6e1dc526dfe07de5a30526c2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFMI6W0oxKgR168RlERAqk4AJ0SrngwAq/5OolSGMdQDkM2Ln5jRQCfZFUX
PXAYzrwwDBWQ+R1Wsf747GA=
=Xijo
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
7d83fbae9802a56b2121d0775de54fccd743d971 4941e437d2638f36ac8510d4a5b4c780afc798bb

View File

@ -40,6 +40,10 @@ do_not_use_codec
# #
# pager1-9.*: Tests related to the backup API. # pager1-9.*: Tests related to the backup API.
# #
# pager1-10.*: Test that the assumed file-system sector-size is limited to
# 64KB.
#
#
set a_string_counter 1 set a_string_counter 1
proc a_string {n} { proc a_string {n} {
@ -279,6 +283,10 @@ do_execsql_test pager1-3.2.2 {
# #
# pager1.4.5.*: Test that hot-journal rollback stops if it encounters a # pager1.4.5.*: Test that hot-journal rollback stops if it encounters a
# journal-record for which the checksum fails. # journal-record for which the checksum fails.
#
# pager1.4.6.*: Test that when rolling back a hot-journal that contains a
# master journal pointer, the master journal file is deleted
# after all the hot-journals that refer to it are deleted.
# #
do_test pager1.4.1.1 { do_test pager1.4.1.1 {
faultsim_delete_and_reopen faultsim_delete_and_reopen
@ -582,7 +590,7 @@ do_execsql_test pager1.4.5.2 {
SELECT * FROM t2; SELECT * FROM t2;
} {I II 1 2 III IV 3 4} } {I II 1 2 III IV 3 4}
# Now try three tests: # Now try four tests:
# #
# pager1-4.5.3: Restore the file-system. Check that the whole transaction # pager1-4.5.3: Restore the file-system. Check that the whole transaction
# is rolled back. # is rolled back.
@ -623,6 +631,106 @@ do_catchsql_test pager1.4.5.6 {
SELECT * FROM t1; SELECT * FROM t1;
SELECT * FROM t2; SELECT * FROM t2;
} {1 {disk I/O error}} } {1 {disk I/O error}}
db close
# Snapshot the file-system just before multi-file commit. Save the name
# of the master journal file in $::mj_filename.
#
tv script copy_on_mj_delete
tv filter xDelete
proc copy_on_mj_delete {method filename args} {
if {[string match *mj* [file tail $filename]]} {
set ::mj_filename $filename
faultsim_save
}
return SQLITE_OK
}
do_test pager1.4.6.1 {
faultsim_delete_and_reopen
execsql {
ATTACH 'test.db2' AS two;
CREATE TABLE t1(a, b);
CREATE TABLE two.t2(a, b);
INSERT INTO t1 VALUES(1, 't1.1');
INSERT INTO t2 VALUES(1, 't2.1');
BEGIN;
UPDATE t1 SET b = 't1.2';
UPDATE t2 SET b = 't2.2';
COMMIT;
}
tv filter {}
db close
} {}
faultsim_restore_and_reopen
do_execsql_test pager1.4.6.2 { SELECT * FROM t1 } {1 t1.1}
do_test pager1.4.6.3 { file exists $::mj_filename } {1}
do_execsql_test pager1.4.6.4 {
ATTACH 'test.db2' AS two;
SELECT * FROM t2;
} {1 t2.1}
do_test pager1.4.6.5 { file exists $::mj_filename } {0}
faultsim_restore_and_reopen
db close
do_test pager1.4.6.8 {
set ::mj_filename1 $::mj_filename
tv filter xDelete
sqlite3 db test.db2
execsql {
ATTACH 'test.db3' AS three;
CREATE TABLE three.t3(a, b);
INSERT INTO t3 VALUES(1, 't3.1');
BEGIN;
UPDATE t2 SET b = 't2.3';
UPDATE t3 SET b = 't3.3';
COMMIT;
}
expr {$::mj_filename1 != $::mj_filename}
} {1}
faultsim_restore_and_reopen
tv filter {}
# The file-system now contains:
#
# * three databases
# * three hot-journal files
# * two master-journal files.
#
# The hot-journals associated with test.db2 and test.db3 point to
# master journal $::mj_filename. The hot-journal file associated with
# test.db points to master journal $::mj_filename1. So reading from
# test.db should delete $::mj_filename1.
#
do_test pager1.4.6.9 {
lsort [glob test.db*]
} [lsort [list \
test.db test.db2 test.db3 \
test.db-journal test.db2-journal test.db3-journal \
[file tail $::mj_filename] [file tail $::mj_filename1]
]]
# The master-journal $::mj_filename1 contains pointers to test.db and
# test.db2. However the hot-journal associated with test.db2 points to
# a different master-journal. Therefore, reading from test.db only should
# be enough to cause SQLite to delete $::mj_filename1.
#
do_test pager1.4.6.10 { file exists $::mj_filename } {1}
do_test pager1.4.6.11 { file exists $::mj_filename1 } {1}
do_execsql_test pager1.4.6.12 { SELECT * FROM t1 } {1 t1.1}
do_test pager1.4.6.13 { file exists $::mj_filename } {1}
do_test pager1.4.6.14 { file exists $::mj_filename1 } {0}
do_execsql_test pager1.4.6.12 {
ATTACH 'test.db2' AS two;
SELECT * FROM t2;
} {1 t2.1}
do_test pager1.4.6.13 { file exists $::mj_filename } {1}
do_execsql_test pager1.4.6.14 {
ATTACH 'test.db3' AS three;
SELECT * FROM t3;
} {1 t3.1}
do_test pager1.4.6.15 { file exists $::mj_filename } {0}
db close db close
tv delete tv delete
@ -950,6 +1058,74 @@ do_test pager1-9.2.3 {
db one {SELECT md5sum(a, b) FROM ab} db one {SELECT md5sum(a, b) FROM ab}
} [db2 one {SELECT md5sum(a, b) FROM ab}] } [db2 one {SELECT md5sum(a, b) FROM ab}]
do_test pager1-9.2.4 { execsql { SELECT count(*) FROM ab } } {128} do_test pager1-9.2.4 { execsql { SELECT count(*) FROM ab } } {128}
db close
db2 close
#-------------------------------------------------------------------------
# Test that regardless of the value returned by xSectorSize(), the
# minimum effective sector-size is 512 and the maximum 65536 bytes.
#
testvfs tv -default 1
foreach sectorsize {
32 64 128 256 512 1024 2048
4096 8192 16384 32768 65536 131072 262144
} {
tv sectorsize $sectorsize
set eff $sectorsize
if {$sectorsize < 512} { set eff 512 }
if {$sectorsize > 65536} { set eff 65536 }
do_test pager1-10.$sectorsize {
faultsim_delete_and_reopen
execsql {
PRAGMA journal_mode = PERSIST;
PRAGMA page_size = 1024;
CREATE TABLE t1(a, b);
}
file size test.db-journal
} [expr $sectorsize > 65536 ? 65536 : $sectorsize]
}
db close
tv delete
testvfs tv -default 1
faultsim_delete_and_reopen
db func a_string a_string
do_execsql_test pager1-11.1 {
PRAGMA cache_size = 10;
BEGIN;
CREATE TABLE zz(top PRIMARY KEY);
INSERT INTO zz VALUES(a_string(222));
INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
COMMIT;
BEGIN;
UPDATE zz SET top = a_string(345);
} {}
proc lockout {method args} { return SQLITE_IOERR }
tv script lockout
tv filter {xWrite xTruncate xSync}
do_catchsql_test pager1-11.2 { COMMIT } {1 {disk I/O error}}
tv script {}
do_test pager1-11.3 {
sqlite3 db2 test.db
execsql {
PRAGMA journal_mode = TRUNCATE;
PRAGMA integrity_check;
} db2
} {truncate ok}
do_test pager1-11.4 {
db2 close
file size test.db-journal
} {0}
breakpoint
do_execsql_test pager1-11.5 { SELECT count(*) FROM zz } {32}
finish_test finish_test

View File

@ -97,7 +97,7 @@ do_faultsim_test pagerfault-2 -prep {
faultsim_integrity_check faultsim_integrity_check
set res [db eval { SELECT * FROM abc }] set res [db eval { SELECT * FROM abc }]
if {$res != $answer} { error "Database content appears incorrect ($res)" } if {$res != $answer} { error "Database content appears incorrect ($res)" }
} -faults oom-transient }
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# Test fault-injection while rolling back hot-journals that were created # Test fault-injection while rolling back hot-journals that were created
@ -141,7 +141,7 @@ do_test pagerfault-3-pre1 {
db close db close
tstvfs delete tstvfs delete
} {} } {}
do_faultsim_test pagerfault-3 -faults ioerr-persistent -prep { do_faultsim_test pagerfault-3 -prep {
faultsim_restore_and_reopen faultsim_restore_and_reopen
} -body { } -body {
execsql { execsql {
@ -220,7 +220,7 @@ do_faultsim_test pagerfault-5.2 -prep {
faultsim_test_result {0 {}} faultsim_test_result {0 {}}
faultsim_integrity_check faultsim_integrity_check
} }
do_faultsim_test pagerfault-5.3 -prep { do_faultsim_test pagerfault-5.3 -faults oom-transient -prep {
faultsim_restore_and_reopen faultsim_restore_and_reopen
db func a_string a_string db func a_string a_string
file delete -force test2.db test2.db-journal test2.db-wal file delete -force test2.db test2.db-journal test2.db-wal
@ -239,8 +239,14 @@ do_faultsim_test pagerfault-5.3 -prep {
} }
} -test { } -test {
faultsim_test_result {0 {}} faultsim_test_result {0 {}}
faultsim_integrity_check
set res ""
set rc [catch { set res [db one { PRAGMA aux.integrity_check }] }]
if {$rc!=0 || $res != "ok"} {error "integrity-check problem:$rc $res"}
} }
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# Test fault-injection as part of a commit when using # Test fault-injection as part of a commit when using
# journal_mode=TRUNCATE. # journal_mode=TRUNCATE.
@ -339,7 +345,7 @@ do_test pagerfault-7-pre1 {
} }
faultsim_save_and_close faultsim_save_and_close
} {} } {}
do_faultsim_test pagerfault-7 -faults full -prep { do_faultsim_test pagerfault-7 -prep {
faultsim_restore_and_reopen faultsim_restore_and_reopen
execsql { execsql {
PRAGMA cache_size = 10; PRAGMA cache_size = 10;
@ -406,7 +412,7 @@ do_test pagerfault-9-pre1 {
faultsim_save_and_close faultsim_save_and_close
} {} } {}
do_faultsim_test pagerfault-9 -faults oom-transient -prep { do_faultsim_test pagerfault-9 -prep {
faultsim_restore_and_reopen faultsim_restore_and_reopen
execsql { execsql {
BEGIN; BEGIN;