1# 2016 April 20 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# This file contains fault injection tests for RBU vacuum operations. 13# 14 15source [file join [file dirname [info script]] rbu_common.tcl] 16source $testdir/malloc_common.tcl 17set ::testprefix rbufault3 18 19foreach {fault errlist} { 20 oom-* { 21 {1 SQLITE_NOMEM} 22 {1 SQLITE_IOERR_NOMEM} 23 {1 {SQLITE_NOMEM - out of memory}} 24 } 25 26 ioerr-* { 27 {1 {SQLITE_IOERR - disk I/O error}} 28 {1 SQLITE_IOERR} 29 {1 SQLITE_IOERR_WRITE} 30 {1 SQLITE_IOERR_FSYNC} 31 {1 SQLITE_IOERR_READ} 32 {1 {SQLITE_IOERR - unable to open database: test.db2}} 33 {1 {SQLITE_ERROR - unable to open database: test.db2}} 34 {1 {SQLITE_ERROR - SQL logic error}} 35 } 36 37 cantopen* { 38 {1 {SQLITE_CANTOPEN - unable to open database: test.db2}} 39 {1 {SQLITE_CANTOPEN - unable to open database: test.db2}} 40 {1 {SQLITE_CANTOPEN - unable to open database file}} 41 {1 SQLITE_CANTOPEN} 42 } 43 44} { 45 46 reset_db 47 do_execsql_test 0 { 48 CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y)); 49 INSERT INTO target VALUES(1, 2, 3); 50 INSERT INTO target VALUES(4, 5, 6); 51 INSERT INTO target VALUES(7, 8, 9); 52 CREATE INDEX i1 ON target(z); 53 } 54 faultsim_save_and_close 55 56 do_faultsim_test 1 -faults $fault -prep { 57 faultsim_restore_and_reopen 58 forcedelete test.db2 59 } -body { 60 sqlite3rbu_vacuum rbu test.db test.db2 61 while {[rbu step]=="SQLITE_OK"} {} 62 rbu close 63 } -test { 64 eval [list faultsim_test_result {0 SQLITE_DONE} {*}$::errlist] 65 } 66 67 do_faultsim_test 2 -faults $fault -prep { 68 faultsim_restore_and_reopen 69 forcedelete test.db2 70 } -body { 71 sqlite3rbu_vacuum rbu test.db test.db2 72 rbu step 73 rbu close 74 } -test { 75 eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist] 76 } 77 78 forcedelete test.db2 79 sqlite3rbu_vacuum rbu test.db test.db2 80 rbu step 81 rbu close 82 faultsim_save_and_close 83 84 do_faultsim_test 3 -faults $fault -prep { 85 faultsim_restore_and_reopen 86 } -body { 87 sqlite3rbu_vacuum rbu test.db test.db2 88 rbu step 89 rbu close 90 } -test { 91 eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist] 92 } 93} 94 95finish_test 96