3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # This file contains fault injection tests for RBU vacuum operations.
15 source [file join [file dirname [info script]] rbu_common.tcl]
16 if_no_rbu_support { finish_test ; return }
17 source $testdir/malloc_common.tcl
18 set ::testprefix rbufault3
20 foreach {fault errlist} {
23 {1 SQLITE_IOERR_NOMEM}
24 {1 {SQLITE_NOMEM - out of memory}}
28 {1 {SQLITE_IOERR - disk I/O error}}
30 {1 SQLITE_IOERR_WRITE}
31 {1 SQLITE_IOERR_FSYNC}
33 {1 {SQLITE_IOERR - unable to open database: test.db2}}
34 {1 {SQLITE_ERROR - unable to open database: test.db2}}
35 {1 {SQLITE_ERROR - SQL logic error}}
39 {1 {SQLITE_CANTOPEN - unable to open database: test.db2}}
40 {1 {SQLITE_CANTOPEN - unable to open database: test.db2}}
41 {1 {SQLITE_CANTOPEN - unable to open database file}}
49 CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y));
50 INSERT INTO target VALUES(1, 2, 3);
51 INSERT INTO target VALUES(4, 5, 6);
52 INSERT INTO target VALUES(7, 8, 9);
53 CREATE INDEX i1 ON target(z);
55 faultsim_save_and_close
57 do_faultsim_test 1 -faults $fault -prep {
58 faultsim_restore_and_reopen
61 sqlite3rbu_vacuum rbu test.db test.db2
62 while {[rbu step]=="SQLITE_OK"} {}
65 eval [list faultsim_test_result {0 SQLITE_DONE} {*}$::errlist]
68 do_faultsim_test 2 -faults $fault -prep {
69 faultsim_restore_and_reopen
72 sqlite3rbu_vacuum rbu test.db test.db2
76 eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist]
80 sqlite3rbu_vacuum rbu test.db test.db2
83 faultsim_save_and_close
85 do_faultsim_test 3 -faults $fault -prep {
86 faultsim_restore_and_reopen
88 sqlite3rbu_vacuum rbu test.db test.db2
92 eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist]