1# 2014 March 25. 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# This file implements regression tests for SQLite library. 12# 13# Specifically, it tests the effects of fault injection on the sorter 14# module (code in vdbesort.c). 15# 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19set testprefix sortfault 20 21 22do_execsql_test 1.0 { 23 PRAGMA cache_size = 5; 24} 25 26foreach {tn mmap_limit nWorker tmpstore threadsmode fakeheap} { 27 1 0 0 file multithread false 28 2 100000 0 file multithread false 29} { 30 catch { db close } 31 sqlite3_shutdown 32 sqlite3_config_worker_threads $nWorker 33 sqlite3_config $threadsmode 34 sqlite3_initialize 35 sorter_test_fakeheap $fakeheap 36 37 set str [string repeat a 1000] 38 39 do_faultsim_test 1.$tn -prep { 40 sqlite3 db test.db 41 sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit 42 execsql { PRAGMA cache_size = 5 } 43 } -body { 44 execsql { 45 WITH r(x,y) AS ( 46 SELECT 1, $::str 47 UNION ALL 48 SELECT x+1, $::str FROM r 49 LIMIT 200 50 ) 51 SELECT count(x), length(y) FROM r GROUP BY (x%5) 52 } 53 } -test { 54 faultsim_test_result {0 {40 1000 40 1000 40 1000 40 1000 40 1000}} 55 } 56} 57 58catch { db close } 59sqlite3_shutdown 60sqlite3_config_worker_threads 0 61set t(0) singlethread 62set t(1) multithread 63set t(2) serialized 64sqlite3_config $t($sqlite_options(threadsafe)) 65sqlite3_initialize 66finish_test 67 68