1# 2# May you do good and not evil. 3# May you find forgiveness for yourself and forgive others. 4# May you share freely, never taking more than you give. 5# 6#*********************************************************************** 7# This file runs all tests. 8# 9# $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $ 10 11set testdir [file dirname $argv0] 12source $testdir/tester.tcl 13 14if {[info commands sqlite3async_initialize] eq ""} { 15 # The async logic is not built into this system 16 finish_test 17 return 18} 19 20rename finish_test async_really_finish_test 21proc finish_test {} { 22 catch {db close} 23 catch {db2 close} 24 catch {db3 close} 25} 26if {[info exists G(isquick)]} { set ASYNC_SAVE_ISQUICK $G(isquick) } 27set G(isquick) 1 28 29set ASYNC_INCLUDE { 30 insert.test 31 insert2.test 32 insert3.test 33 lock.test 34 lock2.test 35 lock3.test 36 select1.test 37 select2.test 38 select3.test 39 select4.test 40 trans.test 41} 42 43# Enable asynchronous IO. 44sqlite3async_initialize "" 1 45 46# This proc flushes the contents of the async-IO queue through to the 47# underlying VFS. A couple of the test scripts identified in $ASYNC_INCLUDE 48# above contain lines like "catch flush_async_queue" in places where 49# this is required for the tests to work in async mode. 50# 51proc flush_async_queue {} { 52 sqlite3async_control halt idle 53 sqlite3async_start 54 sqlite3async_wait 55 sqlite3async_control halt never 56} 57 58rename do_test async_really_do_test 59proc do_test {name args} { 60 uplevel async_really_do_test async_io-$name $args 61 flush_async_queue 62} 63 64foreach testfile [lsort -dictionary [glob $testdir/*.test]] { 65 set tail [file tail $testfile] 66 if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue 67 source $testfile 68 69 # Make sure everything is flushed through. This is because [source]ing 70 # the next test file will delete the database file on disk (using 71 # [file delete]). If the asynchronous backend still has the file 72 # open, it will become confused. 73 # 74 flush_async_queue 75} 76 77# Flush the write-queue and disable asynchronous IO. This should ensure 78# all allocated memory is cleaned up. 79set sqlite3async_trace 1 80flush_async_queue 81sqlite3async_shutdown 82set sqlite3async_trace 0 83 84rename do_test {} 85rename async_really_do_test do_test 86rename finish_test {} 87rename async_really_finish_test finish_test 88 89if {[info exists ASYNC_SAVE_ISQUICK]} { set G(isquick) $ASYNC_SAVE_ISQUICK } 90finish_test 91