sqlcipher/test/async.test

88 lines
2.1 KiB
Plaintext
Raw Normal View History

2008-07-30 09:15:43 -04: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-08-11 16:01:51 -04:00
# $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $
2008-07-30 09:15:43 -04:00
2009-02-20 15:33:35 -05:00
set testdir [file dirname $argv0]
source $testdir/tester.tcl
2008-07-30 09:15:43 -04:00
2009-05-08 05:27:02 -04:00
if {[info commands sqlite3async_initialize] eq ""} {
2008-07-30 09:15:43 -04:00
# The async logic is not built into this system
2009-02-20 15:33:35 -05:00
finish_test
2008-07-30 09:15:43 -04:00
return
}
2009-04-21 10:39:00 -04:00
rename finish_test async_really_finish_test
2008-07-30 09:15:43 -04:00
proc finish_test {} {
catch {db close}
catch {db2 close}
catch {db3 close}
}
2009-04-21 10:39:00 -04:00
if {[info exists ISQUICK]} { set ASYNC_SAVE_ISQUICK $ISQUICK }
2008-07-30 09:15:43 -04:00
set ISQUICK 1
2009-04-21 10:39:00 -04:00
set ASYNC_INCLUDE {
2008-07-30 09:15:43 -04:00
insert.test
insert2.test
insert3.test
lock.test
lock2.test
lock3.test
select1.test
select2.test
select3.test
select4.test
trans.test
}
# Enable asynchronous IO.
2009-05-08 05:27:02 -04:00
sqlite3async_initialize "" 1
2008-07-30 09:15:43 -04:00
2009-04-21 10:39:00 -04:00
rename do_test async_really_do_test
2008-07-30 09:15:43 -04:00
proc do_test {name args} {
2009-04-21 10:39:00 -04:00
uplevel async_really_do_test async_io-$name $args
2008-07-30 09:15:43 -04:00
sqlite3async_start
2009-05-08 05:27:02 -04:00
sqlite3async_control halt idle
2008-07-30 09:15:43 -04:00
sqlite3async_wait
2009-05-08 05:27:02 -04:00
sqlite3async_control halt never
2008-07-30 09:15:43 -04:00
}
foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
set tail [file tail $testfile]
2009-04-21 10:39:00 -04:00
if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
2008-07-30 09:15:43 -04:00
source $testfile
# Make sure everything is flushed through. This is because [source]ing
# the next test file will delete the database file on disk (using
# [file delete]). If the asynchronous backend still has the file
# open, it will become confused.
#
2009-05-08 05:27:02 -04:00
sqlite3async_control halt idle
2008-07-30 09:15:43 -04:00
sqlite3async_start
sqlite3async_wait
2009-05-08 05:27:02 -04:00
sqlite3async_control halt never
2008-07-30 09:15:43 -04:00
}
# Flush the write-queue and disable asynchronous IO. This should ensure
# all allocated memory is cleaned up.
set sqlite3async_trace 1
2009-05-08 05:27:02 -04:00
sqlite3async_control halt idle
2008-07-30 09:15:43 -04:00
sqlite3async_start
sqlite3async_wait
2009-05-08 05:27:02 -04:00
sqlite3async_control halt never
sqlite3async_shutdown
2008-07-30 09:15:43 -04:00
set sqlite3async_trace 0
2009-04-21 10:39:00 -04:00
rename do_test {}
rename async_really_do_test do_test
rename finish_test {}
rename async_really_finish_test finish_test
if {[info exists ASYNC_SAVE_ISQUICK]} { set ISQUICK $ASYNC_SAVE_ISQUICK }
finish_test