blob: e1bc08642e50a2fc409b3ecdab14aa74b88ab1b1 [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}
dan430e74c2010-06-07 17:47:26 +000026if {[info exists G(isquick)]} { set ASYNC_SAVE_ISQUICK $G(isquick) }
27set G(isquick) 1
drh23669402006-01-09 17:29:52 +000028
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
dan0cf408f2010-07-13 07:38:51 +000046# This proc flushes the contents of the async-IO queue through to the
47# underlying VFS. A couple of the test scripts identified in $ASYNC_INCLUDE
48# above contain lines like "catch flush_async_queue" in places where
49# this is required for the tests to work in async mode.
50#
51proc flush_async_queue {} {
52 sqlite3async_control halt idle
53 sqlite3async_start
54 sqlite3async_wait
55 sqlite3async_control halt never
56}
57
drhfe53f2e2009-04-10 18:21:29 +000058rename do_test async_really_do_test
drh23669402006-01-09 17:29:52 +000059proc do_test {name args} {
drhfe53f2e2009-04-10 18:21:29 +000060 uplevel async_really_do_test async_io-$name $args
dan0cf408f2010-07-13 07:38:51 +000061 flush_async_queue
drh23669402006-01-09 17:29:52 +000062}
63
64foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
65 set tail [file tail $testfile]
danielk19771c501792009-04-11 10:25:03 +000066 if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
drh23669402006-01-09 17:29:52 +000067 source $testfile
danielk1977b6be6752007-09-05 11:34:54 +000068
69 # Make sure everything is flushed through. This is because [source]ing
70 # the next test file will delete the database file on disk (using
mistachkinfda06be2011-08-02 00:57:34 +000071 # [delete_file]). If the asynchronous backend still has the file
danielk1977b6be6752007-09-05 11:34:54 +000072 # open, it will become confused.
73 #
dan0cf408f2010-07-13 07:38:51 +000074 flush_async_queue
drh23669402006-01-09 17:29:52 +000075}
76
danielk1977750b03e2006-02-14 10:48:39 +000077# Flush the write-queue and disable asynchronous IO. This should ensure
78# all allocated memory is cleaned up.
drh05a82982006-03-19 13:00:25 +000079set sqlite3async_trace 1
dan0cf408f2010-07-13 07:38:51 +000080flush_async_queue
danielk19776f050aa2009-04-25 08:39:14 +000081sqlite3async_shutdown
drh05a82982006-03-19 13:00:25 +000082set sqlite3async_trace 0
danielk1977750b03e2006-02-14 10:48:39 +000083
drhfe53f2e2009-04-10 18:21:29 +000084rename do_test {}
85rename async_really_do_test do_test
86rename finish_test {}
drh3e078c72009-04-10 20:55:13 +000087rename async_really_finish_test finish_test
danielk19771c501792009-04-11 10:25:03 +000088
dan430e74c2010-06-07 17:47:26 +000089if {[info exists ASYNC_SAVE_ISQUICK]} { set G(isquick) $ASYNC_SAVE_ISQUICK }
danielk19771c501792009-04-11 10:25:03 +000090finish_test