xref: /sqlite-3.40.0/test/async.test (revision dda70fe3)
1#
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#
9# $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $
10
11set testdir [file dirname $argv0]
12source $testdir/tester.tcl
13
14if {[info commands sqlite3async_initialize] eq ""} {
15  # The async logic is not built into this system
16  finish_test
17  return
18}
19
20rename finish_test async_really_finish_test
21proc finish_test {} {
22  catch {db close}
23  catch {db2 close}
24  catch {db3 close}
25}
26if {[info exists ISQUICK]} { set ASYNC_SAVE_ISQUICK $ISQUICK }
27set ISQUICK 1
28
29set ASYNC_INCLUDE {
30  insert.test
31  insert2.test
32  insert3.test
33  lock.test
34  lock2.test
35  lock3.test
36  select1.test
37  select2.test
38  select3.test
39  select4.test
40  trans.test
41}
42
43# Enable asynchronous IO.
44sqlite3async_initialize "" 1
45
46rename do_test async_really_do_test
47proc do_test {name args} {
48  uplevel async_really_do_test async_io-$name $args
49  sqlite3async_start
50  sqlite3async_control halt idle
51  sqlite3async_wait
52  sqlite3async_control halt never
53}
54
55foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
56  set tail [file tail $testfile]
57  if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue
58  source $testfile
59
60  # Make sure everything is flushed through. This is because [source]ing
61  # the next test file will delete the database file on disk (using
62  # [file delete]). If the asynchronous backend still has the file
63  # open, it will become confused.
64  #
65  sqlite3async_control halt idle
66  sqlite3async_start
67  sqlite3async_wait
68  sqlite3async_control halt never
69}
70
71# Flush the write-queue and disable asynchronous IO. This should ensure
72# all allocated memory is cleaned up.
73set sqlite3async_trace 1
74sqlite3async_control halt idle
75sqlite3async_start
76sqlite3async_wait
77sqlite3async_control halt never
78sqlite3async_shutdown
79set sqlite3async_trace 0
80
81rename do_test {}
82rename async_really_do_test do_test
83rename finish_test {}
84rename async_really_finish_test finish_test
85
86if {[info exists ASYNC_SAVE_ISQUICK]} { set ISQUICK $ASYNC_SAVE_ISQUICK }
87finish_test
88