mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Improve the code coverage of "permutations.test coverage-pager".
FossilOrigin-Name: b095e2cdb61ca8487255687f58fb1024d40f3986
This commit is contained in:
@ -1246,6 +1246,7 @@ do_faultsim_test pagerfault-27 -faults ioerr-persistent -prep {
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_test pagerfault-28-pre {
|
||||
@ -1279,7 +1280,7 @@ do_test pagerfault-28-pre {
|
||||
} {1}
|
||||
faultsim_save_and_close
|
||||
|
||||
do_faultsim_test pagerfault-28 -faults oom* -prep {
|
||||
do_faultsim_test pagerfault-28a -faults oom* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
execsql { PRAGMA mmap_limit=0 }
|
||||
|
||||
@ -1303,5 +1304,185 @@ do_faultsim_test pagerfault-28 -faults oom* -prep {
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
faultsim_restore_and_reopen
|
||||
sqlite3 db2 test.db
|
||||
db2 eval {SELECT count(*) FROM t2}
|
||||
db close
|
||||
|
||||
do_faultsim_test pagerfault-28b -faults oom* -prep {
|
||||
sqlite3 db test.db
|
||||
} -body {
|
||||
execsql { SELECT count(*) FROM t2 }
|
||||
} -test {
|
||||
faultsim_test_result {0 2048}
|
||||
db close
|
||||
}
|
||||
|
||||
db2 close
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Try this:
|
||||
#
|
||||
# 1) Put the pager in ERROR state (error during rollback)
|
||||
#
|
||||
# 2) Next time the connection is used inject errors into all xWrite() and
|
||||
# xUnlock() calls. This causes the hot-journal rollback to fail and
|
||||
# the pager to declare its locking state UNKNOWN.
|
||||
#
|
||||
# 3) Same again.
|
||||
#
|
||||
# 4a) Stop injecting errors. Allow the rollback to succeed. Check that
|
||||
# the database is Ok. Or,
|
||||
#
|
||||
# 4b) Close and reopen the db. Check that the db is Ok.
|
||||
#
|
||||
proc custom_injectinstall {} {
|
||||
testvfs custom -default true
|
||||
custom filter {xWrite xUnlock}
|
||||
}
|
||||
proc custom_injectuninstall {} {
|
||||
catch {db close}
|
||||
catch {db2 close}
|
||||
custom delete
|
||||
}
|
||||
proc custom_injectstart {iFail} {
|
||||
custom ioerr $iFail 1
|
||||
}
|
||||
proc custom_injectstop {} {
|
||||
custom ioerr
|
||||
}
|
||||
set ::FAULTSIM(custom) [list \
|
||||
-injectinstall custom_injectinstall \
|
||||
-injectstart custom_injectstart \
|
||||
-injectstop custom_injectstop \
|
||||
-injecterrlist {{1 {disk I/O error}}} \
|
||||
-injectuninstall custom_injectuninstall \
|
||||
]
|
||||
|
||||
do_test pagerfault-29-pre {
|
||||
faultsim_delete_and_reopen
|
||||
db func a_string a_string
|
||||
execsql {
|
||||
PRAGMA page_size = 1024;
|
||||
PRAGMA cache_size = 5;
|
||||
|
||||
BEGIN;
|
||||
CREATE TABLE t2(a UNIQUE, b UNIQUE);
|
||||
INSERT INTO t2 VALUES( a_string(800), a_string(800) );
|
||||
INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
|
||||
INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
|
||||
INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
|
||||
INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;
|
||||
COMMIT;
|
||||
}
|
||||
expr {[file size test.db] >= 50*1024}
|
||||
} {1}
|
||||
faultsim_save_and_close
|
||||
foreach {tn tt} {
|
||||
29 { catchsql ROLLBACK }
|
||||
30 { db close ; sqlite3 db test.db }
|
||||
} {
|
||||
do_faultsim_test pagerfault-$tn -faults custom -prep {
|
||||
faultsim_restore_and_reopen
|
||||
db func a_string a_string
|
||||
execsql {
|
||||
PRAGMA cache_size = 5;
|
||||
BEGIN;
|
||||
UPDATE t2 SET a = a_string(799);
|
||||
}
|
||||
} -body {
|
||||
catchsql ROLLBACK
|
||||
catchsql ROLLBACK
|
||||
catchsql ROLLBACK
|
||||
} -test {
|
||||
eval $::tt
|
||||
if {"ok" != [db one {PRAGMA integrity_check}]} {
|
||||
error "integrity check failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do_test pagerfault-31-pre {
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_uri 1
|
||||
} {SQLITE_OK}
|
||||
do_faultsim_test pagerfault-31 -faults oom* -body {
|
||||
sqlite3 db {file:one?mode=memory&cache=shared}
|
||||
db eval {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 1} {1 {}}
|
||||
catch { db close }
|
||||
}
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_uri 0
|
||||
|
||||
do_test pagerfault-32-pre {
|
||||
reset_db
|
||||
execsql {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES('one');
|
||||
}
|
||||
} {}
|
||||
faultsim_save_and_close
|
||||
|
||||
do_faultsim_test pagerfault-32 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
db eval { SELECT * FROM t1; }
|
||||
} -body {
|
||||
execsql { SELECT * FROM t1; }
|
||||
} -test {
|
||||
faultsim_test_result {0 one}
|
||||
}
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_uri 0
|
||||
|
||||
do_faultsim_test pagerfault-33a -prep {
|
||||
sqlite3 db :memory:
|
||||
execsql {
|
||||
CREATE TABLE t1(a, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
}
|
||||
} -body {
|
||||
execsql { VACUUM }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
do_faultsim_test pagerfault-33b -prep {
|
||||
sqlite3 db ""
|
||||
execsql {
|
||||
CREATE TABLE t1(a, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
}
|
||||
} -body {
|
||||
execsql { VACUUM }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
|
||||
do_test pagerfault-34-pre {
|
||||
reset_db
|
||||
execsql {
|
||||
CREATE TABLE t1(x PRIMARY KEY);
|
||||
}
|
||||
} {}
|
||||
faultsim_save_and_close
|
||||
do_faultsim_test pagerfault-34 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES( randomblob(4000) );
|
||||
DELETE FROM t1;
|
||||
}
|
||||
} -body {
|
||||
execsql COMMIT
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
Reference in New Issue
Block a user