drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 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 | # |
drh | dda70fe | 2009-06-05 17:09:11 +0000 | [diff] [blame^] | 9 | # $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $ |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 10 | |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 11 | set testdir [file dirname $argv0] |
| 12 | source $testdir/tester.tcl |
danielk1977 | 4ff6202 | 2008-09-15 14:47:21 +0000 | [diff] [blame] | 13 | |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 14 | if {[info commands sqlite3async_initialize] eq ""} { |
danielk1977 | 4ff6202 | 2008-09-15 14:47:21 +0000 | [diff] [blame] | 15 | # The async logic is not built into this system |
| 16 | finish_test |
| 17 | return |
| 18 | } |
| 19 | |
drh | 3e078c7 | 2009-04-10 20:55:13 +0000 | [diff] [blame] | 20 | rename finish_test async_really_finish_test |
danielk1977 | b6be675 | 2007-09-05 11:34:54 +0000 | [diff] [blame] | 21 | proc finish_test {} { |
| 22 | catch {db close} |
| 23 | catch {db2 close} |
| 24 | catch {db3 close} |
| 25 | } |
danielk1977 | 1c50179 | 2009-04-11 10:25:03 +0000 | [diff] [blame] | 26 | if {[info exists ISQUICK]} { set ASYNC_SAVE_ISQUICK $ISQUICK } |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 27 | set ISQUICK 1 |
| 28 | |
danielk1977 | 1c50179 | 2009-04-11 10:25:03 +0000 | [diff] [blame] | 29 | set ASYNC_INCLUDE { |
danielk1977 | ed10afb | 2007-09-05 13:56:32 +0000 | [diff] [blame] | 30 | insert.test |
| 31 | insert2.test |
| 32 | insert3.test |
| 33 | lock.test |
| 34 | lock2.test |
| 35 | lock3.test |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 36 | select1.test |
| 37 | select2.test |
| 38 | select3.test |
| 39 | select4.test |
drh | 97bbdc0 | 2006-02-13 18:35:06 +0000 | [diff] [blame] | 40 | trans.test |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 41 | } |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 42 | |
| 43 | # Enable asynchronous IO. |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 44 | sqlite3async_initialize "" 1 |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 45 | |
drh | fe53f2e | 2009-04-10 18:21:29 +0000 | [diff] [blame] | 46 | rename do_test async_really_do_test |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 47 | proc do_test {name args} { |
drh | fe53f2e | 2009-04-10 18:21:29 +0000 | [diff] [blame] | 48 | uplevel async_really_do_test async_io-$name $args |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 49 | sqlite3async_start |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 50 | sqlite3async_control halt idle |
drh | 97bbdc0 | 2006-02-13 18:35:06 +0000 | [diff] [blame] | 51 | sqlite3async_wait |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 52 | sqlite3async_control halt never |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | foreach testfile [lsort -dictionary [glob $testdir/*.test]] { |
| 56 | set tail [file tail $testfile] |
danielk1977 | 1c50179 | 2009-04-11 10:25:03 +0000 | [diff] [blame] | 57 | if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 58 | source $testfile |
danielk1977 | b6be675 | 2007-09-05 11:34:54 +0000 | [diff] [blame] | 59 | |
| 60 | # Make sure everything is flushed through. This is because [source]ing |
| 61 | # the next test file will delete the database file on disk (using |
| 62 | # [file delete]). If the asynchronous backend still has the file |
| 63 | # open, it will become confused. |
| 64 | # |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 65 | sqlite3async_control halt idle |
danielk1977 | b6be675 | 2007-09-05 11:34:54 +0000 | [diff] [blame] | 66 | sqlite3async_start |
| 67 | sqlite3async_wait |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 68 | sqlite3async_control halt never |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 69 | } |
| 70 | |
danielk1977 | 750b03e | 2006-02-14 10:48:39 +0000 | [diff] [blame] | 71 | # Flush the write-queue and disable asynchronous IO. This should ensure |
| 72 | # all allocated memory is cleaned up. |
drh | 05a8298 | 2006-03-19 13:00:25 +0000 | [diff] [blame] | 73 | set sqlite3async_trace 1 |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 74 | sqlite3async_control halt idle |
danielk1977 | 750b03e | 2006-02-14 10:48:39 +0000 | [diff] [blame] | 75 | sqlite3async_start |
drh | 2366940 | 2006-01-09 17:29:52 +0000 | [diff] [blame] | 76 | sqlite3async_wait |
danielk1977 | 6f050aa | 2009-04-25 08:39:14 +0000 | [diff] [blame] | 77 | sqlite3async_control halt never |
| 78 | sqlite3async_shutdown |
drh | 05a8298 | 2006-03-19 13:00:25 +0000 | [diff] [blame] | 79 | set sqlite3async_trace 0 |
danielk1977 | 750b03e | 2006-02-14 10:48:39 +0000 | [diff] [blame] | 80 | |
drh | fe53f2e | 2009-04-10 18:21:29 +0000 | [diff] [blame] | 81 | rename do_test {} |
| 82 | rename async_really_do_test do_test |
| 83 | rename finish_test {} |
drh | 3e078c7 | 2009-04-10 20:55:13 +0000 | [diff] [blame] | 84 | rename async_really_finish_test finish_test |
danielk1977 | 1c50179 | 2009-04-11 10:25:03 +0000 | [diff] [blame] | 85 | |
| 86 | if {[info exists ASYNC_SAVE_ISQUICK]} { set ISQUICK $ASYNC_SAVE_ISQUICK } |
| 87 | finish_test |