133447e77Sdan# 2009 January 8 233447e77Sdan# 333447e77Sdan# The author disclaims copyright to this source code. In place of 433447e77Sdan# a legal notice, here is a blessing: 533447e77Sdan# 633447e77Sdan# May you do good and not evil. 733447e77Sdan# May you find forgiveness for yourself and forgive others. 833447e77Sdan# May you share freely, never taking more than you give. 933447e77Sdan# 1033447e77Sdan#*********************************************************************** 1133447e77Sdan# 1233447e77Sdan# Test the outcome of a writer crashing within a call to the VFS 1333447e77Sdan# xWrite function. 1433447e77Sdan# 1533447e77Sdan 1633447e77Sdan 1733447e77Sdanset testdir [file dirname $argv0] 1833447e77Sdansource $testdir/tester.tcl 1933447e77Sdanset testprefix writecrash 2033447e77Sdan 2133447e77Sdando_not_use_codec 2233447e77Sdan 23*2fc2f92eSdrh 24*2fc2f92eSdrhif {$tcl_platform(platform)=="windows"} { 25*2fc2f92eSdrh finish_test 26*2fc2f92eSdrh return 27*2fc2f92eSdrh} 28*2fc2f92eSdrh 2933447e77Sdando_execsql_test 1.0 { 3033447e77Sdan CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE); 3133447e77Sdan WITH s(i) AS ( 3233447e77Sdan VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100 3333447e77Sdan ) 3433447e77Sdan INSERT INTO t1 SELECT NULL, randomblob(900) FROM s; 3533447e77Sdan} {} 3633447e77Sdan 3733447e77Sdanset bGo 1 3833447e77Sdanfor {set tn 1} {$bGo} {incr tn} { 3933447e77Sdan 4033447e77Sdandb close 4133447e77Sdansqlite3 db test.db 4233447e77Sdan 4333447e77Sdan do_test 1.$tn.1 { 4433447e77Sdan set res [crash_on_write $tn { 4533447e77Sdan UPDATE t1 SET b = randomblob(899) WHERE (a%3)==0 4633447e77Sdan }] 4733447e77Sdan set bGo 0 4833447e77Sdan if {[string match {1 {child killed:*}} $res]} { 4933447e77Sdan set res {0 {}} 5033447e77Sdan set bGo 1 5133447e77Sdan } 5233447e77Sdan set res 5333447e77Sdan } {0 {}} 5433447e77Sdan 5533447e77Sdan#db close 5633447e77Sdan#sqlite3 db test.db 5733447e77Sdan 5833447e77Sdan do_execsql_test 1.$tn.2 { PRAGMA integrity_check } {ok} 5933447e77Sdan 6033447e77Sdandb close 6133447e77Sdansqlite3 db test.db 6233447e77Sdan 6333447e77Sdan do_execsql_test 1.$tn.3 { PRAGMA integrity_check } {ok} 6433447e77Sdan} 6533447e77Sdan 6633447e77Sdan 6733447e77Sdan 6833447e77Sdanfinish_test 69