blob: e90bbac55f12a3ae6037217de860ceecfdb9df0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# 2011 November 16
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains fault-injection test cases for the
# sqlite3_db_cacheflush API.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix cacheflush
source $testdir/malloc_common.tcl
# Run the supplied SQL on a copy of the database currently stored on
# disk in file $dbfile.
proc diskquery {dbfile sql} {
forcecopy $dbfile dq.db
sqlite3 dq dq.db
set res [execsql $sql dq]
dq close
set res
}
do_execsql_test 1.0 {
CREATE TABLE t1(a PRIMARY KEY, b);
CREATE INDEX i1 ON t1(b);
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(3, 4);
INSERT INTO t1 VALUES(5, 6);
INSERT INTO t1 VALUES(7, 8);
}
faultsim_save_and_close
do_faultsim_test 1 -prep {
faultsim_restore_and_reopen
db eval {
BEGIN;
UPDATE t1 SET b=b+1;
}
} -body {
sqlite3_db_cacheflush db
} -test {
faultsim_test_result {0 {}} {1 {disk I/O error}}
catch { db eval COMMIT }
faultsim_integrity_check
}
finish_test
|