gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/walrofault.test (about) 1 # 2011 May 09 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 # This file contains tests for using WAL databases in read-only mode. 13 # 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 source $testdir/malloc_common.tcl 18 set ::testprefix walro2 19 20 # And only if the build is WAL-capable. 21 # 22 ifcapable !wal { 23 finish_test 24 return 25 } 26 27 db close 28 sqlite3_shutdown 29 sqlite3_config_uri 1 30 sqlite3 db test.db 31 32 do_execsql_test 1.0 { 33 CREATE TABLE t1(b); 34 PRAGMA journal_mode = wal; 35 INSERT INTO t1 VALUES('hello'); 36 INSERT INTO t1 VALUES('world'); 37 INSERT INTO t1 VALUES('!'); 38 INSERT INTO t1 VALUES('world'); 39 INSERT INTO t1 VALUES('hello'); 40 PRAGMA cache_size = 10; 41 BEGIN; 42 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<30 ) 43 INSERT INTO t1(b) SELECT randomblob(800) FROM s; 44 } {wal} 45 file_control_persist_wal db 1; db close 46 faultsim_save_and_close 47 48 do_faultsim_test 1 -faults oom* -prep { 49 catch { db close } 50 faultsim_restore 51 sqlite3 db file:test.db?readonly_shm=1 52 } -body { 53 execsql { SELECT * FROM t1 } 54 } -test { 55 faultsim_test_result {0 {hello world ! world hello}} 56 } 57 58 59 60 finish_test