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