1# 2014 October 22 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 13if {![info exists testdir]} { 14 set testdir [file join [file dirname [info script]] .. .. test] 15} 16source $testdir/tester.tcl 17source $testdir/malloc_common.tcl 18set ::testprefix rbufault4 19 20for {set tn 1} {1} {incr tn} { 21 reset_db 22 do_execsql_test 1.0 { 23 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); 24 CREATE INDEX i1b ON t1(b); 25 CREATE INDEX i1c ON t1(c); 26 INSERT INTO t1 VALUES(1, 2, 3); 27 INSERT INTO t1 VALUES(4, 5, 6); 28 } 29 30 forcedelete test.db2 31 sqlite3rbu_vacuum rbu test.db test.db2 32 for {set i 0} {$i < $tn} {incr i} { rbu step } 33 set rc [rbu close] 34 if {$rc!="SQLITE_OK"} { 35 if {$rc!="SQLITE_DONE"} {error $rc} 36 break 37 } 38 faultsim_save 39 40 do_faultsim_test $tn -faults oom-t* -prep { 41 faultsim_restore 42 } -body { 43 sqlite3rbu_vacuum rbu test.db test.db2 44 while 1 { 45 set rc [rbu step] 46 if {$rc=="SQLITE_DONE"} break 47 if {$rc!="SQLITE_OK"} { error $rc } 48 } 49 } -test { 50 catch {rbu close} 51 faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM} 52 53 sqlite3rbu_vacuum rbu test.db test.db2 54 while {[rbu step]=="SQLITE_OK"} {} 55 set trc [rbu close] 56 if {$trc!="SQLITE_DONE"} { error "Got $trc instead of SQLITE_DONE!" } 57 58 set rc [db one {PRAGMA integrity_check}] 59 if {$rc!="ok"} { error "Got $rc instead of ok!" } 60 } 61} 62 63 64 65finish_test 66 67