1: # 2010 June 15
2: #
3: # The author disclaims copyright to this source code. In place of
4: # a legal notice, here is a blessing:
5: #
6: # May you do good and not evil.
7: # May you find forgiveness for yourself and forgive others.
8: # May you share freely, never taking more than you give.
9: #
10: #***********************************************************************
11: #
12: # The tests in this file test the pager modules response to various
13: # fault conditions (OOM, IO error, disk full etc.). They are similar
14: # to those in file pagerfault1.test.
15: #
16: # More specifically, the tests in this file are those deemed too slow to
17: # run as part of pagerfault1.test.
18: #
19:
20: set testdir [file dirname $argv0]
21: source $testdir/tester.tcl
22: source $testdir/lock_common.tcl
23: source $testdir/malloc_common.tcl
24:
25: if {[permutation] == "inmemory_journal"} {
26: finish_test
27: return
28: }
29:
30: sqlite3_memdebug_vfs_oom_test 0
31:
32: set a_string_counter 1
33: proc a_string {n} {
34: global a_string_counter
35: incr a_string_counter
36: string range [string repeat "${a_string_counter}." $n] 1 $n
37: }
38: db func a_string a_string
39:
40: do_test pagerfault2-1-pre1 {
41: faultsim_delete_and_reopen
42: db func a_string a_string
43: execsql {
44: PRAGMA auto_vacuum = 0;
45: PRAGMA journal_mode = DELETE;
46: PRAGMA page_size = 1024;
47: CREATE TABLE t1(a, b);
48: INSERT INTO t1 VALUES(a_string(401), a_string(402));
49: }
50: for {set ii 0} {$ii < 13} {incr ii} {
51: execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }
52: }
53: faultsim_save_and_close
54: file size test.db
55: } [expr 1024 * 8268]
56:
57: do_faultsim_test pagerfault2-1 -faults oom-transient -prep {
58: faultsim_restore_and_reopen
59: sqlite3_db_config_lookaside db 0 256 4096
60: execsql {
61: BEGIN;
62: SELECT * FROM t1;
63: INSERT INTO t1 VALUES(5, 6);
64: SAVEPOINT abc;
65: UPDATE t1 SET a = a||'x' WHERE rowid<3700;
66: }
67: } -body {
68: execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 }
69: execsql { ROLLBACK TO abc }
70: } -test {
71: faultsim_test_result {0 {}}
72: }
73:
74: do_test pagerfault2-2-pre1 {
75: faultsim_restore_and_reopen
76: execsql { DELETE FROM t1 }
77: faultsim_save_and_close
78: } {}
79:
80: do_faultsim_test pagerfault2-2 -faults oom-transient -prep {
81: faultsim_restore_and_reopen
82: sqlite3_db_config_lookaside db 0 256 4096
83: db func a_string a_string
84:
85: execsql {
86: PRAGMA cache_size = 20;
87: BEGIN;
88: INSERT INTO t1 VALUES(a_string(401), a_string(402));
89: SAVEPOINT abc;
90: }
91: } -body {
92: execsql { INSERT INTO t1 VALUES (a_string(2000000), a_string(2500000)) }
93: } -test {
94: faultsim_test_result {0 {}}
95: }
96:
97: sqlite3_memdebug_vfs_oom_test 1
98: finish_test
99:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>