xref: /sqlite-3.40.0/test/async.test (revision cd7274ce)
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.13 2007/11/05 17:01:08 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  sqlite3async_halt never
51}
52
53foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
54  set tail [file tail $testfile]
55  if {[lsearch -exact $INCLUDE $tail]<0} continue
56  source $testfile
57
58  # Make sure everything is flushed through. This is because [source]ing
59  # the next test file will delete the database file on disk (using
60  # [file delete]). If the asynchronous backend still has the file
61  # open, it will become confused.
62  #
63  sqlite3async_halt idle
64  sqlite3async_start
65  sqlite3async_wait
66  sqlite3async_halt never
67}
68
69# Flush the write-queue and disable asynchronous IO. This should ensure
70# all allocated memory is cleaned up.
71set sqlite3async_trace 1
72sqlite3async_halt idle
73sqlite3async_start
74sqlite3async_wait
75sqlite3async_halt never
76sqlite3async_enable 0
77set sqlite3async_trace 0
78
79really_finish_test
80rename really_do_test do_test
81rename really_finish_test finish_test
82