blob: 835d39c766e915e777f1468d161c0a43bab96f80 [file] [log] [blame]
drh23669402006-01-09 17:29:52 +00001#
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#
drhdda70fe2009-06-05 17:09:11 +00009# $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $
drh23669402006-01-09 17:29:52 +000010
drh23669402006-01-09 17:29:52 +000011set testdir [file dirname $argv0]
12source $testdir/tester.tcl
danielk19774ff62022008-09-15 14:47:21 +000013
danielk19776f050aa2009-04-25 08:39:14 +000014if {[info commands sqlite3async_initialize] eq ""} {
danielk19774ff62022008-09-15 14:47:21 +000015 # The async logic is not built into this system
16 finish_test
17 return
18}
19
drh3e078c72009-04-10 20:55:13 +000020rename finish_test async_really_finish_test
danielk1977b6be6752007-09-05 11:34:54 +000021proc finish_test {} {
22 catch {db close}
23 catch {db2 close}
24 catch {db3 close}
25}
danielk19771c501792009-04-11 10:25:03 +000026if {[info exists ISQUICK]} { set ASYNC_SAVE_ISQUICK $ISQUICK }
drh23669402006-01-09 17:29:52 +000027set ISQUICK 1
28
danielk19771c501792009-04-11 10:25:03 +000029set ASYNC_INCLUDE {
danielk1977ed10afb2007-09-05 13:56:32 +000030 insert.test
31 insert2.test
32 insert3.test
33 lock.test
34 lock2.test
35 lock3.test
drh23669402006-01-09 17:29:52 +000036 select1.test
37 select2.test
38 select3.test
39 select4.test
drh97bbdc02006-02-13 18:35:06 +000040 trans.test
drh23669402006-01-09 17:29:52 +000041}
drh23669402006-01-09 17:29:52 +000042
43# Enable asynchronous IO.
danielk19776f050aa2009-04-25 08:39:14 +000044sqlite3async_initialize "" 1
drh23669402006-01-09 17:29:52 +000045
drhfe53f2e2009-04-10 18:21:29 +000046rename do_test async_really_do_test
drh23669402006-01-09 17:29:52 +000047proc do_test {name args} {
drhfe53f2e2009-04-10 18:21:29 +000048 uplevel async_really_do_test async_io-$name $args
drh23669402006-01-09 17:29:52 +000049 sqlite3async_start
danielk19776f050aa2009-04-25 08:39:14 +000050 sqlite3async_control halt idle
drh97bbdc02006-02-13 18:35:06 +000051 sqlite3async_wait
danielk19776f050aa2009-04-25 08:39:14 +000052 sqlite3async_control halt never
drh23669402006-01-09 17:29:52 +000053}
54
55foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
56 set tail [file tail $testfile]
danielk19771c501792009-04-11 10:25:03 +000057 if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
drh23669402006-01-09 17:29:52 +000058 source $testfile
danielk1977b6be6752007-09-05 11:34:54 +000059
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 #
danielk19776f050aa2009-04-25 08:39:14 +000065 sqlite3async_control halt idle
danielk1977b6be6752007-09-05 11:34:54 +000066 sqlite3async_start
67 sqlite3async_wait
danielk19776f050aa2009-04-25 08:39:14 +000068 sqlite3async_control halt never
drh23669402006-01-09 17:29:52 +000069}
70
danielk1977750b03e2006-02-14 10:48:39 +000071# Flush the write-queue and disable asynchronous IO. This should ensure
72# all allocated memory is cleaned up.
drh05a82982006-03-19 13:00:25 +000073set sqlite3async_trace 1
danielk19776f050aa2009-04-25 08:39:14 +000074sqlite3async_control halt idle
danielk1977750b03e2006-02-14 10:48:39 +000075sqlite3async_start
drh23669402006-01-09 17:29:52 +000076sqlite3async_wait
danielk19776f050aa2009-04-25 08:39:14 +000077sqlite3async_control halt never
78sqlite3async_shutdown
drh05a82982006-03-19 13:00:25 +000079set sqlite3async_trace 0
danielk1977750b03e2006-02-14 10:48:39 +000080
drhfe53f2e2009-04-10 18:21:29 +000081rename do_test {}
82rename async_really_do_test do_test
83rename finish_test {}
drh3e078c72009-04-10 20:55:13 +000084rename async_really_finish_test finish_test
danielk19771c501792009-04-11 10:25:03 +000085
86if {[info exists ASYNC_SAVE_ISQUICK]} { set ISQUICK $ASYNC_SAVE_ISQUICK }
87finish_test