dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame^] | 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 | set a_string_counter 1 |
| 26 | proc a_string {n} { |
| 27 | global a_string_counter |
| 28 | incr a_string_counter |
| 29 | string range [string repeat "${a_string_counter}." $n] 1 $n |
| 30 | } |
| 31 | db func a_string a_string |
| 32 | |
| 33 | |
| 34 | # The following tests, pagerfault2-1.*, attempt to provoke OOM errors when |
| 35 | # manipulating the internal "bitvec" structures. Since bitvec structures |
| 36 | # only allocate memory very rarely, this requires fairly large databases. |
| 37 | # |
| 38 | do_test pagerfault2-1-pre1 { |
| 39 | faultsim_delete_and_reopen |
| 40 | db func a_string a_string |
| 41 | execsql { |
| 42 | PRAGMA journal_mode = DELETE; |
| 43 | CREATE TABLE t1(a, b); |
| 44 | INSERT INTO t1 VALUES(a_string(401), a_string(402)); |
| 45 | } |
| 46 | for {set ii 0} {$ii < 14} {incr ii} { |
| 47 | execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 } |
| 48 | } |
| 49 | faultsim_save_and_close |
| 50 | } {} |
| 51 | do_faultsim_test pagerfault2-1.1 -faults oom* -prep { |
| 52 | faultsim_restore_and_reopen |
| 53 | execsql { |
| 54 | BEGIN; |
| 55 | INSERT INTO t1 VALUES(5, 6); |
| 56 | SAVEPOINT abc; |
| 57 | UPDATE t1 SET a = a||'x'; |
| 58 | } |
| 59 | } -body { |
| 60 | execsql { ROLLBACK TO abc } |
| 61 | } -test { |
| 62 | faultsim_test_result {0 {}} |
| 63 | faultsim_integrity_check |
| 64 | } |
| 65 | |
| 66 | finish_test |