sqlite/test/pagerfault2.test

67 lines
1.8 KiB
Plaintext

# 2010 June 15
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The tests in this file test the pager modules response to various
# fault conditions (OOM, IO error, disk full etc.). They are similar
# to those in file pagerfault1.test.
#
# More specifically, the tests in this file are those deemed too slow to
# run as part of pagerfault1.test.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/malloc_common.tcl
set a_string_counter 1
proc a_string {n} {
global a_string_counter
incr a_string_counter
string range [string repeat "${a_string_counter}." $n] 1 $n
}
db func a_string a_string
# The following tests, pagerfault2-1.*, attempt to provoke OOM errors when
# manipulating the internal "bitvec" structures. Since bitvec structures
# only allocate memory very rarely, this requires fairly large databases.
#
do_test pagerfault2-1-pre1 {
faultsim_delete_and_reopen
db func a_string a_string
execsql {
PRAGMA journal_mode = DELETE;
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(a_string(401), a_string(402));
}
for {set ii 0} {$ii < 14} {incr ii} {
execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }
}
faultsim_save_and_close
} {}
do_faultsim_test pagerfault2-1.1 -faults oom* -prep {
faultsim_restore_and_reopen
execsql {
BEGIN;
INSERT INTO t1 VALUES(5, 6);
SAVEPOINT abc;
UPDATE t1 SET a = a||'x';
}
} -body {
execsql { ROLLBACK TO abc }
} -test {
faultsim_test_result {0 {}}
faultsim_integrity_check
}
finish_test