blob: 2d0d8b3828f655fee2425b11ea6a8536e6e00cdc [file] [log] [blame]
dan213ca0a2011-03-28 19:10:06 +00001# 2011 March 28
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
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15source $testdir/lock_common.tcl
16source $testdir/malloc_common.tcl
17
18if {[llength [info commands test_syscall]]==0} {
19 finish_test
20 return
21}
22
23set testprefix sysfault
24
25set FAULTSIM(vfsfault-transient) [list \
26 -injectinstall vfsfault_install \
27 -injectstart vfsfault_injectstart_t \
28 -injectstop vfsfault_injectstop \
29 -injecterrlist {} \
30 -injectuninstall {test_syscall uninstall} \
31]
32set FAULTSIM(vfsfault-persistent) [list \
33 -injectinstall vfsfault_install \
34 -injectstart vfsfault_injectstart_p \
35 -injectstop vfsfault_injectstop \
36 -injecterrlist {} \
37 -injectuninstall {test_syscall uninstall} \
38]
39
40proc vfsfault_injectstart_t {iFail} { test_syscall fault $iFail 0 }
41proc vfsfault_injectstart_p {iFail} { test_syscall fault $iFail 1 }
42proc vfsfault_injectstop {} { test_syscall fault }
43
44faultsim_save_and_close
45
46proc vfsfault_install {} {
47 test_syscall install {open getcwd}
48}
49
50do_faultsim_test 1 -faults vfsfault-* -prep {
51 faultsim_restore
52} -body {
53 sqlite3 db test.db
54 db eval {
55 CREATE TABLE t1(a, b);
56 INSERT INTO t1 VALUES(1, 2);
57 PRAGMA journal_mode = WAL;
58 INSERT INTO t1 VALUES(3, 4);
59 SELECT * FROM t1;
60 CREATE TEMP TABLE t2(x);
61 INSERT INTO t2 VALUES('y');
62 }
63} -test {
64 faultsim_test_result {0 {wal 1 2 3 4}} \
65 {1 {unable to open database file}} \
66 {1 {attempt to write a readonly database}}
67}
68
69finish_test
70