Annotation of embedaddon/sqlite3/test/async4.test, revision 1.1.1.1
1.1 misho 1: # 2009 April 25
2: #
3: # The author disclaims copyright to this source code. In place of
4: # a legal notice, here is a blessing:
5: #
6: # May you do good and not evil.
7: # May you find forgiveness for yourself and forgive others.
8: # May you share freely, never taking more than you give.
9: #
10: #***********************************************************************
11: #
12: # $Id: async4.test,v 1.4 2009/06/05 17:09:12 drh Exp $
13:
14: set testdir [file dirname $argv0]
15: source $testdir/tester.tcl
16:
17: # Do not use a codec for tests in this file, as the database file is
18: # manipulated directly using tcl scripts (using the [hexio_write] command).
19: #
20: do_not_use_codec
21:
22: # These tests only work for Tcl version 8.5 and later on Windows (for now)
23: #
24: if {$tcl_platform(platform)=="windows"} {
25: scan $::tcl_version %f vx
26: if {$vx<8.5} {
27: finish_test
28: return
29: }
30: }
31:
32: if {[info commands sqlite3async_initialize] eq ""} {
33: # The async logic is not built into this system
34: finish_test
35: return
36: }
37: db close
38:
39: # Test layout:
40: #
41: # async4.1.*: Test the lockfiles parameter.
42: # async4.2.*: Test the delay parameter.
43:
44: do_test async4.1.1 {
45: sqlite3async_initialize {} 0
46: sqlite3async_control lockfiles
47: } {1}
48: do_test async4.1.2 {
49: sqlite3async_control lockfiles false
50: } {0}
51: do_test async4.1.3 {
52: sqlite3async_control lockfiles
53: } {0}
54: do_test async4.1.4 {
55: sqlite3async_control lockfiles true
56: } {1}
57:
58: do_test async4.1.5 {
59: sqlite3 db test.db -vfs sqlite3async
60: execsql { CREATE TABLE t1(a, b, c) }
61: } {}
62: do_test async4.1.6 {
63: list [file exists test.db] [file size test.db]
64: } {1 0}
65: do_test async4.1.7 {
66: sqlite3 db2 test.db
67: catchsql { CREATE TABLE t2(a, b, c) } db2
68: } {1 {database is locked}}
69: do_test async4.1.8 {
70: sqlite3async_control halt idle
71: sqlite3async_start
72: sqlite3async_wait
73: } {}
74: do_test async4.1.9 {
75: catchsql { CREATE TABLE t2(a, b, c) } db2
76: } {0 {}}
77: do_test async4.1.10 {
78: list [catch {sqlite3async_control lockfiles false} msg] $msg
79: } {1 SQLITE_MISUSE}
80: do_test async4.1.11 {
81: db close
82: list [catch {sqlite3async_control lockfiles false} msg] $msg
83: } {1 SQLITE_MISUSE}
84: do_test async4.1.12 {
85: sqlite3async_start
86: sqlite3async_wait
87: sqlite3async_control lockfiles false
88: } {0}
89: do_test async4.1.13 {
90: sqlite3 db test.db -vfs sqlite3async
91: execsql { CREATE TABLE t3(a, b, c) } db
92: } {}
93: do_test async4.1.14 {
94: execsql {
95: CREATE INDEX i1 ON t2(a);
96: CREATE INDEX i2 ON t1(a);
97: } db2
98: } {}
99: do_test async4.1.15 {
100: sqlite3async_start
101: sqlite3async_wait
102: hexio_write test.db 28 00000000
103: execsql { pragma integrity_check } db2
104: } {{*** in database main ***
105: Page 5 is never used}}
106: do_test async4.1.16 {
107: db close
108: db2 close
109: sqlite3async_start
110: sqlite3async_wait
111: } {}
112: do_test async4.1.17 {
113: sqlite3async_control lockfiles true
114: } {1}
115:
116: do_test async4.2.1 {
117: sqlite3async_control delay
118: } {0}
119: do_test async4.2.2 {
120: sqlite3async_control delay 23
121: } {23}
122: do_test async4.2.3 {
123: sqlite3async_control delay
124: } {23}
125: do_test async4.2.4 {
126: sqlite3async_control delay 0
127: } {0}
128: do_test async4.2.5 {
129: sqlite3 db test.db -vfs sqlite3async
130:
131: execsql { CREATE TABLE t4(a, b) }
132: set T1 [lindex [time {
133: sqlite3async_start
134: sqlite3async_wait
135: }] 0]
136:
137: sqlite3async_control delay 100
138: execsql { CREATE TABLE t5(a, b) }
139: set T2 [lindex [time {
140: sqlite3async_start
141: sqlite3async_wait
142: }] 0]
143:
144: expr {($T1+1000000) < $T2}
145: } {1}
146:
147: do_test async4.2.6 {
148: sqlite3async_control delay 0
149: execsql { CREATE TABLE t6(a, b) }
150: set T1 [lindex [time {
151: sqlite3async_start
152: sqlite3async_wait
153: }] 0]
154:
155: expr {($T1+1000000) < $T2}
156: } {1}
157:
158: do_test async4.2.7 {
159: list [catch { sqlite3async_control delay -1 } msg] $msg
160: } {1 SQLITE_MISUSE}
161:
162: do_test async4.2.8 {
163: db close
164: sqlite3async_start
165: sqlite3async_wait
166: } {}
167:
168: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>