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