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