Debian Codegraph @

ext/rbu/rbufault4.test

raw
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 rbufault4
17
18 for {set tn 1} {1} {incr tn} {
19 reset_db
20 do_execsql_test 1.0 {
21 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
22 CREATE INDEX i1b ON t1(b);
23 CREATE INDEX i1c ON t1(c);
24 INSERT INTO t1 VALUES(1, 2, 3);
25 INSERT INTO t1 VALUES(4, 5, 6);
26 }
27 db close
28
29 forcedelete test.db2
30 sqlite3rbu_vacuum rbu test.db test.db2
31 for {set i 0} {$i < $tn} {incr i} { rbu step }
32 set rc [rbu close]
33 if {$rc!="SQLITE_OK"} {
34 if {$rc!="SQLITE_DONE"} {error $rc}
35 break
36 }
37 faultsim_save
38
39 do_faultsim_test $tn -faults oom-t* -prep {
40 faultsim_restore
41 } -body {
42 sqlite3rbu_vacuum rbu test.db test.db2
43 while 1 {
44 set rc [rbu step]
45 if {$rc=="SQLITE_DONE"} break
46 if {$rc!="SQLITE_OK"} { error $rc }
47 }
48 } -test {
49 catch {rbu close}
50 faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM}
51
52 sqlite3rbu_vacuum rbu test.db test.db2
53 while {[rbu step]=="SQLITE_OK"} {}
54 set trc [rbu close]
55 if {$trc!="SQLITE_DONE"} { error "Got $trc instead of SQLITE_DONE!" }
56
57 sqlite3 db test.db
58 set rc [db one {PRAGMA integrity_check}]
59 if {$rc!="ok"} { error "Got $rc instead of ok!" }
60 db close
61 }
62 }
63
64
65
66 finish_test