blob: 5d53efe3498a02dd344175d34bc2d0098f23a4a9 [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#
danielk19777eb42c82007-11-05 17:01:08 +00009# $Id: async.test,v 1.13 2007/11/05 17:01:08 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
drh23669402006-01-09 17:29:52 +000017set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19rename finish_test really_finish_test
danielk1977b6be6752007-09-05 11:34:54 +000020proc finish_test {} {
21 catch {db close}
22 catch {db2 close}
23 catch {db3 close}
24}
drh23669402006-01-09 17:29:52 +000025set ISQUICK 1
26
27set INCLUDE {
danielk1977ed10afb2007-09-05 13:56:32 +000028 insert.test
29 insert2.test
30 insert3.test
31 lock.test
32 lock2.test
33 lock3.test
drh23669402006-01-09 17:29:52 +000034 select1.test
35 select2.test
36 select3.test
37 select4.test
drh97bbdc02006-02-13 18:35:06 +000038 trans.test
drh23669402006-01-09 17:29:52 +000039}
drh23669402006-01-09 17:29:52 +000040
41# Enable asynchronous IO.
42sqlite3async_enable 1
drh23669402006-01-09 17:29:52 +000043
44rename do_test really_do_test
45proc do_test {name args} {
46 uplevel really_do_test async_io-$name $args
drh23669402006-01-09 17:29:52 +000047 sqlite3async_start
danielk1977ed10afb2007-09-05 13:56:32 +000048 sqlite3async_halt idle
drh97bbdc02006-02-13 18:35:06 +000049 sqlite3async_wait
danielk19777eb42c82007-11-05 17:01:08 +000050 sqlite3async_halt never
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
danielk19777eb42c82007-11-05 17:01:08 +000066 sqlite3async_halt never
drh23669402006-01-09 17:29:52 +000067}
68
danielk1977750b03e2006-02-14 10:48:39 +000069# Flush the write-queue and disable asynchronous IO. This should ensure
70# all allocated memory is cleaned up.
drh05a82982006-03-19 13:00:25 +000071set sqlite3async_trace 1
danielk1977750b03e2006-02-14 10:48:39 +000072sqlite3async_halt idle
73sqlite3async_start
drh23669402006-01-09 17:29:52 +000074sqlite3async_wait
danielk19777eb42c82007-11-05 17:01:08 +000075sqlite3async_halt never
drh23669402006-01-09 17:29:52 +000076sqlite3async_enable 0
drh05a82982006-03-19 13:00:25 +000077set sqlite3async_trace 0
danielk1977750b03e2006-02-14 10:48:39 +000078
79really_finish_test
drh23669402006-01-09 17:29:52 +000080rename really_do_test do_test
81rename really_finish_test finish_test