2006-01-09 17:29:52 +00:00
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file runs all tests.
#
2009-06-05 17:09:11 +00:00
# $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $
2006-01-09 17:29:52 +00:00
2008-09-15 14:47:21 +00:00
set testdir [file dirname $argv0]
source $testdir/tester.tcl
2006-01-09 17:29:52 +00:00
2009-04-25 08:39:14 +00:00
if {[info commands sqlite3async_initialize] eq ""} {
2006-01-09 17:29:52 +00:00
# The async logic is not built into this system
2008-09-15 14:47:21 +00:00
finish_test
2006-01-09 17:29:52 +00:00
return
}
2009-04-10 20:55:13 +00:00
rename finish_test async_really_finish_test
2007-09-05 11:34:54 +00:00
proc finish_test {} {
catch {db close}
catch {db2 close}
catch {db3 close}
}
2010-06-07 17:47:26 +00:00
if {[info exists G(isquick)]} { set ASYNC_SAVE_ISQUICK $G(isquick) }
set G(isquick) 1
2006-01-09 17:29:52 +00:00
2009-04-11 10:25:03 +00:00
set ASYNC_INCLUDE {
2006-01-09 17:29:52 +00:00
insert.test
insert2.test
insert3.test
2007-09-04 14:31:47 +00:00
lock.test
2007-09-04 18:28:43 +00:00
lock2.test
2007-09-05 13:56:32 +00:00
lock3.test
select1.test
select2.test
select3.test
select4.test
trans.test
2006-01-09 17:29:52 +00:00
}
# Enable asynchronous IO.
2009-04-25 08:39:14 +00:00
sqlite3async_initialize "" 1
2006-01-09 17:29:52 +00:00
2010-07-13 07:38:51 +00:00
# This proc flushes the contents of the async-IO queue through to the
# underlying VFS. A couple of the test scripts identified in $ASYNC_INCLUDE
# above contain lines like "catch flush_async_queue" in places where
# this is required for the tests to work in async mode.
#
proc flush_async_queue {} {
2009-04-25 08:39:14 +00:00
sqlite3async_control halt idle
2010-07-13 07:38:51 +00:00
sqlite3async_start
2006-02-13 18:35:06 +00:00
sqlite3async_wait
2009-04-25 08:39:14 +00:00
sqlite3async_control halt never
2006-01-09 17:29:52 +00:00
}
2010-07-13 07:38:51 +00:00
rename do_test async_really_do_test
proc do_test {name args} {
uplevel async_really_do_test async_io-$name $args
flush_async_queue
}
2006-01-09 17:29:52 +00:00
foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
set tail [file tail $testfile]
2009-04-11 10:25:03 +00:00
if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
2006-01-09 17:29:52 +00:00
source $testfile
2007-09-05 11:34:54 +00:00
# Make sure everything is flushed through. This is because [source]ing
# the next test file will delete the database file on disk (using
2011-08-02 00:57:34 +00:00
# [delete_file]). If the asynchronous backend still has the file
2007-09-05 11:34:54 +00:00
# open, it will become confused.
#
2010-07-13 07:38:51 +00:00
flush_async_queue
2006-01-09 17:29:52 +00:00
}
2006-02-14 10:48:39 +00:00
# Flush the write-queue and disable asynchronous IO. This should ensure
# all allocated memory is cleaned up.
2006-03-19 13:00:25 +00:00
set sqlite3async_trace 1
2010-07-13 07:38:51 +00:00
flush_async_queue
2009-04-25 08:39:14 +00:00
sqlite3async_shutdown
2006-03-19 13:00:25 +00:00
set sqlite3async_trace 0
2006-02-14 10:48:39 +00:00
2009-04-10 18:21:29 +00:00
rename do_test {}
rename async_really_do_test do_test
rename finish_test {}
2009-04-10 20:55:13 +00:00
rename async_really_finish_test finish_test
2009-04-11 10:25:03 +00:00
2010-06-07 17:47:26 +00:00
if {[info exists ASYNC_SAVE_ISQUICK]} { set G(isquick) $ASYNC_SAVE_ISQUICK }
2009-04-11 10:25:03 +00:00
finish_test