downgrade memory unlock failures to info level and fix function name in log output
[sqlcipher.git] / test / ioerr6.test
blobd1847b2877b71e439be717d2987b3e332795b3b9
1 # 2012 December 18
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 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 source $testdir/malloc_common.tcl
16 set ::testprefix ioerr6
18 ifcapable !atomicwrite {
19   puts "skipping tests - not compiled with SQLITE_ENABLE_ATOMIC_WRITE..."
20   finish_test
21   return
24 if {[permutation]=="inmemory_journal"} {
25   # These tests will not work with in-memory journals (as persistent VFS
26   # errors commencing after a transaction has started to write to the db
27   # cannot be recovered from).
28   finish_test
29   return
32 faultsim_save_and_close
34 do_test 1.1 {
35   testvfs shmfault -default true
36   shmfault devchar atomic
37   sqlite3 db test.db
38   execsql {
39     CREATE TABLE t1(a, b);
40     CREATE INDEX i1 ON t1(a, b);
41     INSERT INTO t1 VALUES(1, 2);
42     INSERT INTO t1 VALUES(2, 4);
43     INSERT INTO t1 VALUES(3, 6);
44     INSERT INTO t1 VALUES(4, 8);
45   }
47   # Cause the first call to xWrite() to fail with SQLITE_FULL.
48   shmfault full 2 1
49   catchsql { INSERT INTO t1 VALUES(5, 10) }
50 } {1 {database or disk is full}}
52 do_test 1.2 {
53   execsql { PRAGMA integrity_check }
54 } {ok}
56 db close
57 shmfault delete
59 do_faultsim_test 2 -faults full* -prep {
60   shmfault devchar atomic
61   faultsim_restore
62   sqlite3 db test.db
63 } -body {
64   db eval {
65     CREATE TABLE t1(x PRIMARY KEY);
66     INSERT INTO t1 VALUES('abc');
67   }
68 } -test {
69   set res [db one { PRAGMA integrity_check }]
70   if {$res != "ok"} {
71     error "integrity check: $res"
72   }
75 do_faultsim_test 3 -faults full* -prep {
76   shmfault devchar atomic
77   faultsim_restore
78   sqlite3 db test.db
79 } -body {
80   db eval {
81     CREATE TABLE t1(x);
82     CREATE TABLE t2(x);
83   }
84 } -test {
85   db eval { CREATE TABLE t3(x) }
86   if {[db one { PRAGMA integrity_check }] != "ok"} {
87     error "integrity check failed"
88   }
91 finish_test