blob: ed2325e3444badc982a56f28edd16b108bd7e7b3 [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#
danielk1977b6be6752007-09-05 11:34:54 +00009# $Id: async.test,v 1.10 2007/09/05 11:34:54 danielk1977 Exp $
drh23669402006-01-09 17:29:52 +000010
11
12if {[catch {sqlite3async_enable}]} {
13 # The async logic is not built into this system
14 return
15}
16
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20rename finish_test 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 {
29 select1.test
30 select2.test
31 select3.test
32 select4.test
33 insert.test
34 insert2.test
35 insert3.test
drh97bbdc02006-02-13 18:35:06 +000036 trans.test
danielk19777c836f02007-09-04 14:31:47 +000037 lock.test
38 lock3.test
danielk19777eda2cd2007-09-04 18:28:43 +000039 lock2.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
45rename do_test really_do_test
46proc do_test {name args} {
47 uplevel really_do_test async_io-$name $args
48 sqlite3async_halt idle
drh23669402006-01-09 17:29:52 +000049 sqlite3async_start
drh97bbdc02006-02-13 18:35:06 +000050 sqlite3async_wait
drh23669402006-01-09 17:29:52 +000051}
52
53foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
54 set tail [file tail $testfile]
55 if {[lsearch -exact $INCLUDE $tail]<0} continue
56 source $testfile
danielk1977b6be6752007-09-05 11:34:54 +000057
58 # Make sure everything is flushed through. This is because [source]ing
59 # the next test file will delete the database file on disk (using
60 # [file delete]). If the asynchronous backend still has the file
61 # open, it will become confused.
62 #
63 sqlite3async_halt idle
64 sqlite3async_start
65 sqlite3async_wait
drh23669402006-01-09 17:29:52 +000066}
67
danielk1977750b03e2006-02-14 10:48:39 +000068# Flush the write-queue and disable asynchronous IO. This should ensure
69# all allocated memory is cleaned up.
drh05a82982006-03-19 13:00:25 +000070set sqlite3async_trace 1
danielk1977750b03e2006-02-14 10:48:39 +000071sqlite3async_halt idle
72sqlite3async_start
drh23669402006-01-09 17:29:52 +000073sqlite3async_wait
74sqlite3async_enable 0
drh05a82982006-03-19 13:00:25 +000075set sqlite3async_trace 0
danielk1977750b03e2006-02-14 10:48:39 +000076
77really_finish_test
drh23669402006-01-09 17:29:52 +000078rename really_do_test do_test
79rename really_finish_test finish_test