Enhance the command-line completion extension to return the names of
[sqlite.git] / ext / rbu / rbufault3.test
blob4fd202d0b7afe708fda12ff18c8387c8dbea7c51
1 # 2016 April 20
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} {
20   oom-* {
21     {1 SQLITE_NOMEM}
22     {1 SQLITE_IOERR_NOMEM}
23     {1 {SQLITE_NOMEM - out of memory}}
24   }
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   }
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   }
44 } {
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
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   }
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   }
78   forcedelete test.db2
79   sqlite3rbu_vacuum rbu test.db test.db2
80   rbu step
81   rbu close
82   faultsim_save_and_close
84   do_faultsim_test 3 -faults $fault -prep {
85     faultsim_restore_and_reopen
86     forcedelete test.db2
87   } -body {
88     sqlite3rbu_vacuum rbu test.db test.db2
89     rbu step
90     rbu close
91   } -test {
92     eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist]
93   }
97 finish_test