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 | |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 25 | sqlite3_memdebug_vfs_oom_test 0 |
| 26 | |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 27 | set a_string_counter 1 |
| 28 | proc a_string {n} { |
| 29 | global a_string_counter |
| 30 | incr a_string_counter |
| 31 | string range [string repeat "${a_string_counter}." $n] 1 $n |
| 32 | } |
| 33 | db func a_string a_string |
| 34 | |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 35 | do_test pagerfault2-1-pre1 { |
| 36 | faultsim_delete_and_reopen |
| 37 | db func a_string a_string |
| 38 | execsql { |
dan | f43d7fc | 2010-07-03 10:00:00 +0000 | [diff] [blame^] | 39 | PRAGMA auto_vacuum = 0; |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 40 | PRAGMA journal_mode = DELETE; |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 41 | PRAGMA page_size = 1024; |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 42 | CREATE TABLE t1(a, b); |
| 43 | INSERT INTO t1 VALUES(a_string(401), a_string(402)); |
| 44 | } |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 45 | for {set ii 0} {$ii < 13} {incr ii} { |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 46 | execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 } |
| 47 | } |
| 48 | faultsim_save_and_close |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 49 | file size test.db |
| 50 | } [expr 1024 * 8268] |
| 51 | |
| 52 | do_faultsim_test pagerfault2-1 -faults oom-transient -prep { |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 53 | faultsim_restore_and_reopen |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 54 | sqlite3_db_config_lookaside db 0 256 4096 |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 55 | execsql { |
| 56 | BEGIN; |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 57 | SELECT * FROM t1; |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 58 | INSERT INTO t1 VALUES(5, 6); |
| 59 | SAVEPOINT abc; |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 60 | UPDATE t1 SET a = a||'x' WHERE rowid<3700; |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 61 | } |
| 62 | } -body { |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 63 | execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 } |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 64 | execsql { ROLLBACK TO abc } |
| 65 | } -test { |
| 66 | faultsim_test_result {0 {}} |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 67 | } |
| 68 | |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 69 | do_test pagerfault2-2-pre1 { |
| 70 | faultsim_restore_and_reopen |
| 71 | execsql { DELETE FROM t1 } |
| 72 | faultsim_save_and_close |
| 73 | } {} |
| 74 | |
| 75 | do_faultsim_test pagerfault2-2 -faults oom-transient -prep { |
| 76 | faultsim_restore_and_reopen |
| 77 | sqlite3_db_config_lookaside db 0 256 4096 |
| 78 | db func a_string a_string |
| 79 | |
| 80 | execsql { |
| 81 | PRAGMA cache_size = 20; |
| 82 | BEGIN; |
| 83 | INSERT INTO t1 VALUES(a_string(401), a_string(402)); |
| 84 | SAVEPOINT abc; |
| 85 | } |
| 86 | } -body { |
| 87 | execsql { INSERT INTO t1 VALUES (a_string(2000000), a_string(2500000)) } |
| 88 | } -test { |
| 89 | faultsim_test_result {0 {}} |
| 90 | } |
| 91 | |
| 92 | sqlite3_memdebug_vfs_oom_test 1 |
dan | 273f3f0 | 2010-06-26 15:42:33 +0000 | [diff] [blame] | 93 | finish_test |
dan | c396d4a | 2010-07-02 11:27:43 +0000 | [diff] [blame] | 94 | |