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 / rbufault2.test
| 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 | |
| 13 | source [file join [file dirname [info script]] rbu_common.tcl] |
| 14 | if_no_rbu_support { finish_test ; return } |
| 15 | source $testdir/malloc_common.tcl |
| 16 | set ::testprefix rbufault2 |
| 17 | |
| 18 | forcedelete rbu.db |
| 19 | do_execsql_test 1.0 { |
| 20 | CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y)); |
| 21 | INSERT INTO target VALUES(1, 2, 3); |
| 22 | INSERT INTO target VALUES(4, 5, 6); |
| 23 | |
| 24 | ATTACH 'rbu.db' AS rbu; |
| 25 | CREATE TABLE rbu.data_target(x, y, z, rbu_control); |
| 26 | INSERT INTO data_target VALUES(7, 8, 9, 0); |
| 27 | INSERT INTO data_target VALUES(1, 11, 12, 0); |
| 28 | DETACH rbu; |
| 29 | } |
| 30 | db close |
| 31 | |
| 32 | forcecopy test.db test.db-bak |
| 33 | forcecopy rbu.db rbu.db-bak |
| 34 | |
| 35 | do_faultsim_test 1 -faults oom* -prep { |
| 36 | forcecopy test.db-bak test.db |
| 37 | forcecopy rbu.db-bak rbu.db |
| 38 | forcedelete test.db-oal test.db-wal rbu.db-journal |
| 39 | sqlite3rbu rbu test.db rbu.db |
| 40 | } -body { |
| 41 | while {[rbu step]=="SQLITE_OK"} { } |
| 42 | rbu close |
| 43 | } -test { |
| 44 | faultsim_test_result \ |
| 45 | {1 {SQLITE_CONSTRAINT - UNIQUE constraint failed: target.x}} \ |
| 46 | {1 SQLITE_CONSTRAINT} \ |
| 47 | {1 SQLITE_NOMEM} \ |
| 48 | {1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}} \ |
| 49 | {1 {SQLITE_NOMEM - out of memory}} |
| 50 | } |
| 51 | |
| 52 | |
| 53 | sqlite3rbu_create_vfs -default rbu "" |
| 54 | sqlite3 db test.db |
| 55 | set ::vfsname [file_control_vfsname db] |
| 56 | do_faultsim_test 2 -faults oom* -prep { |
| 57 | } -body { |
| 58 | file_control_vfsname db |
| 59 | } |
| 60 | db close |
| 61 | sqlite3rbu_destroy_vfs rbu |
| 62 | |
| 63 | |
| 64 | finish_test |