blob: 5e075e15f53613f28b7c82d5233e4c3a0b6d7b35 [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#
drh3e078c72009-04-10 20:55:13 +00009# $Id: async.test,v 1.18 2009/04/10 20:55:14 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
14if {[catch {sqlite3async_enable}]} {
15 # 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}
drh23669402006-01-09 17:29:52 +000026set ISQUICK 1
27
28set INCLUDE {
danielk1977ed10afb2007-09-05 13:56:32 +000029 insert.test
30 insert2.test
31 insert3.test
32 lock.test
33 lock2.test
34 lock3.test
drh23669402006-01-09 17:29:52 +000035 select1.test
36 select2.test
37 select3.test
38 select4.test
drh97bbdc02006-02-13 18:35:06 +000039 trans.test
drh23669402006-01-09 17:29:52 +000040}
drh23669402006-01-09 17:29:52 +000041
42# Enable asynchronous IO.
43sqlite3async_enable 1
drh23669402006-01-09 17:29:52 +000044
drhfe53f2e2009-04-10 18:21:29 +000045rename do_test async_really_do_test
drh23669402006-01-09 17:29:52 +000046proc do_test {name args} {
drhfe53f2e2009-04-10 18:21:29 +000047 uplevel async_really_do_test async_io-$name $args
drh23669402006-01-09 17:29:52 +000048 sqlite3async_start
danielk1977ed10afb2007-09-05 13:56:32 +000049 sqlite3async_halt idle
drh97bbdc02006-02-13 18:35:06 +000050 sqlite3async_wait
danielk19777eb42c82007-11-05 17:01:08 +000051 sqlite3async_halt never
drh23669402006-01-09 17:29:52 +000052}
53
54foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
55 set tail [file tail $testfile]
56 if {[lsearch -exact $INCLUDE $tail]<0} continue
57 source $testfile
danielk1977b6be6752007-09-05 11:34:54 +000058
59 # Make sure everything is flushed through. This is because [source]ing
60 # the next test file will delete the database file on disk (using
61 # [file delete]). If the asynchronous backend still has the file
62 # open, it will become confused.
63 #
64 sqlite3async_halt idle
65 sqlite3async_start
66 sqlite3async_wait
danielk19777eb42c82007-11-05 17:01:08 +000067 sqlite3async_halt never
drh23669402006-01-09 17:29:52 +000068}
69
danielk1977750b03e2006-02-14 10:48:39 +000070# Flush the write-queue and disable asynchronous IO. This should ensure
71# all allocated memory is cleaned up.
drh05a82982006-03-19 13:00:25 +000072set sqlite3async_trace 1
danielk1977750b03e2006-02-14 10:48:39 +000073sqlite3async_halt idle
74sqlite3async_start
drh23669402006-01-09 17:29:52 +000075sqlite3async_wait
danielk19777eb42c82007-11-05 17:01:08 +000076sqlite3async_halt never
drh23669402006-01-09 17:29:52 +000077sqlite3async_enable 0
drh05a82982006-03-19 13:00:25 +000078set sqlite3async_trace 0
danielk1977750b03e2006-02-14 10:48:39 +000079
80really_finish_test
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