guard against zero block size if provider initialization fails
[sqlcipher.git] / ext / rbu / rbufault4.test
blob551b8b2b6f3a335b4dcc9a3a567bb815cf1ea4f6
1 # 2014 October 22
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 #***********************************************************************
13 if {![info exists testdir]} {
14   set testdir [file join [file dirname [info script]] .. .. test]
16 source $testdir/tester.tcl
17 source $testdir/malloc_common.tcl
18 set ::testprefix rbufault4
20 for {set tn 1} {1} {incr tn} {
21   reset_db
22   do_execsql_test 1.0 {
23     CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
24     CREATE INDEX i1b ON t1(b);
25     CREATE INDEX i1c ON t1(c);
26     INSERT INTO t1 VALUES(1, 2, 3);
27     INSERT INTO t1 VALUES(4, 5, 6);
28   }
30   forcedelete test.db2
31   sqlite3rbu_vacuum rbu test.db test.db2
32   for {set i 0} {$i < $tn} {incr i} { rbu step }
33   set rc [rbu close]
34   if {$rc!="SQLITE_OK"} { 
35     if {$rc!="SQLITE_DONE"} {error $rc}
36     break
37   }
38   faultsim_save
40   do_faultsim_test $tn -faults oom-t* -prep {
41     faultsim_restore
42   } -body {
43     sqlite3rbu_vacuum rbu test.db test.db2
44     while 1 {
45       set rc [rbu step]
46       if {$rc=="SQLITE_DONE"} break
47       if {$rc!="SQLITE_OK"} { error $rc }
48     }
49   } -test {
50     catch {rbu close}
51     faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM}
53     sqlite3rbu_vacuum rbu test.db test.db2
54     while {[rbu step]=="SQLITE_OK"} {}
55     set trc [rbu close]
56     if {$trc!="SQLITE_DONE"} { error "Got $trc instead of SQLITE_DONE!" }
58     set rc [db one {PRAGMA integrity_check}]
59     if {$rc!="ok"} { error "Got $rc instead of ok!" }
60   }
65 finish_test