sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / rbu / rbufault3.test
| 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 | |
| 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 |
| 19 | |
| 20 | foreach {fault errlist} { |
| 21 | oom-* { |
| 22 | {1 SQLITE_NOMEM} |
| 23 | {1 SQLITE_IOERR_NOMEM} |
| 24 | {1 {SQLITE_NOMEM - out of memory}} |
| 25 | } |
| 26 | |
| 27 | ioerr-* { |
| 28 | {1 {SQLITE_IOERR - disk I/O error}} |
| 29 | {1 SQLITE_IOERR} |
| 30 | {1 SQLITE_IOERR_WRITE} |
| 31 | {1 SQLITE_IOERR_FSYNC} |
| 32 | {1 SQLITE_IOERR_READ} |
| 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}} |
| 36 | } |
| 37 | |
| 38 | cantopen* { |
| 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}} |
| 42 | {1 SQLITE_CANTOPEN} |
| 43 | } |
| 44 | |
| 45 | } { |
| 46 | |
| 47 | reset_db |
| 48 | do_execsql_test 0 { |
| 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); |
| 54 | } |
| 55 | faultsim_save_and_close |
| 56 | |
| 57 | do_faultsim_test 1 -faults $fault -prep { |
| 58 | faultsim_restore_and_reopen |
| 59 | forcedelete test.db2 |
| 60 | } -body { |
| 61 | sqlite3rbu_vacuum rbu test.db test.db2 |
| 62 | while {[rbu step]=="SQLITE_OK"} {} |
| 63 | rbu close |
| 64 | } -test { |
| 65 | eval [list faultsim_test_result {0 SQLITE_DONE} {*}$::errlist] |
| 66 | } |
| 67 | |
| 68 | do_faultsim_test 2 -faults $fault -prep { |
| 69 | faultsim_restore_and_reopen |
| 70 | forcedelete test.db2 |
| 71 | } -body { |
| 72 | sqlite3rbu_vacuum rbu test.db test.db2 |
| 73 | rbu step |
| 74 | rbu close |
| 75 | } -test { |
| 76 | eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist] |
| 77 | } |
| 78 | |
| 79 | forcedelete test.db2 |
| 80 | sqlite3rbu_vacuum rbu test.db test.db2 |
| 81 | rbu step |
| 82 | rbu close |
| 83 | faultsim_save_and_close |
| 84 | |
| 85 | do_faultsim_test 3 -faults $fault -prep { |
| 86 | faultsim_restore_and_reopen |
| 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 | } |
| 94 | } |
| 95 | |
| 96 | finish_test |