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 source $testdir/malloc_common.tcl
17 set ::testprefix rbufault3
19 foreach {fault errlist} {
22 {1 SQLITE_IOERR_NOMEM}
23 {1 {SQLITE_NOMEM - out of memory}}
27 {1 {SQLITE_IOERR - disk I/O error}}
29 {1 SQLITE_IOERR_WRITE}
30 {1 SQLITE_IOERR_FSYNC}
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}}
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}}
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);
54 faultsim_save_and_close
56 do_faultsim_test 1 -faults $fault -prep {
57 faultsim_restore_and_reopen
60 sqlite3rbu_vacuum rbu test.db test.db2
61 while {[rbu step]=="SQLITE_OK"} {}
64 eval [list faultsim_test_result {0 SQLITE_DONE} {*}$::errlist]
67 do_faultsim_test 2 -faults $fault -prep {
68 faultsim_restore_and_reopen
71 sqlite3rbu_vacuum rbu test.db test.db2
75 eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist]
79 sqlite3rbu_vacuum rbu test.db test.db2
82 faultsim_save_and_close
84 do_faultsim_test 3 -faults $fault -prep {
85 faultsim_restore_and_reopen
88 sqlite3rbu_vacuum rbu test.db test.db2
92 eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist]