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.2 2009/05/15 14:41:40 danielk1977 Exp $ 13 14set testdir [file dirname $argv0] 15source $testdir/tester.tcl 16if {[info commands sqlite3async_initialize] eq ""} { 17 # The async logic is not built into this system 18 finish_test 19 return 20} 21db close 22 23# Test layout: 24# 25# async4.1.*: Test the lockfiles parameter. 26# async4.2.*: Test the delay parameter. 27 28do_test async4.1.1 { 29 sqlite3async_initialize {} 0 30 sqlite3async_control lockfiles 31} {1} 32do_test async4.1.2 { 33 sqlite3async_control lockfiles false 34} {0} 35do_test async4.1.3 { 36 sqlite3async_control lockfiles 37} {0} 38do_test async4.1.4 { 39 sqlite3async_control lockfiles true 40} {1} 41 42do_test async4.1.5 { 43 sqlite3 db test.db -vfs sqlite3async 44 execsql { CREATE TABLE t1(a, b, c) } 45} {} 46do_test async4.1.6 { 47 list [file exists test.db] [file size test.db] 48} {1 0} 49do_test async4.1.7 { 50 sqlite3 db2 test.db 51 catchsql { CREATE TABLE t2(a, b, c) } db2 52} {1 {database is locked}} 53do_test async4.1.8 { 54 sqlite3async_control halt idle 55 sqlite3async_start 56 sqlite3async_wait 57} {} 58do_test async4.1.9 { 59 catchsql { CREATE TABLE t2(a, b, c) } db2 60} {0 {}} 61do_test async4.1.10 { 62 list [catch {sqlite3async_control lockfiles false} msg] $msg 63} {1 SQLITE_MISUSE} 64do_test async4.1.11 { 65 db close 66 list [catch {sqlite3async_control lockfiles false} msg] $msg 67} {1 SQLITE_MISUSE} 68do_test async4.1.12 { 69 sqlite3async_start 70 sqlite3async_wait 71 sqlite3async_control lockfiles false 72} {0} 73do_test async4.1.13 { 74 sqlite3 db test.db -vfs sqlite3async 75 execsql { CREATE TABLE t3(a, b, c) } db 76} {} 77do_test async4.1.14 { 78 execsql { 79 CREATE INDEX i1 ON t2(a); 80 CREATE INDEX i2 ON t1(a); 81 } db2 82} {} 83do_test async4.1.15 { 84 sqlite3async_start 85 sqlite3async_wait 86 execsql { pragma integrity_check } db2 87} {{*** in database main *** 88Page 5 is never used}} 89do_test async4.1.16 { 90 db close 91 db2 close 92 sqlite3async_start 93 sqlite3async_wait 94} {} 95do_test async4.1.17 { 96 sqlite3async_control lockfiles true 97} {1} 98 99do_test async4.2.1 { 100 sqlite3async_control delay 101} {0} 102do_test async4.2.2 { 103 sqlite3async_control delay 23 104} {23} 105do_test async4.2.3 { 106 sqlite3async_control delay 107} {23} 108do_test async4.2.4 { 109 sqlite3async_control delay 0 110} {0} 111do_test async4.2.5 { 112 sqlite3 db test.db -vfs sqlite3async 113 114 execsql { CREATE TABLE t4(a, b) } 115 set T1 [lindex [time { 116 sqlite3async_start 117 sqlite3async_wait 118 }] 0] 119 120 sqlite3async_control delay 100 121 execsql { CREATE TABLE t5(a, b) } 122 set T2 [lindex [time { 123 sqlite3async_start 124 sqlite3async_wait 125 }] 0] 126 127 expr {($T1+1000000) < $T2} 128} {1} 129 130do_test async4.2.6 { 131 sqlite3async_control delay 0 132 execsql { CREATE TABLE t6(a, b) } 133 set T1 [lindex [time { 134 sqlite3async_start 135 sqlite3async_wait 136 }] 0] 137 138 expr {($T1+1000000) < $T2} 139} {1} 140 141do_test async4.2.7 { 142 list [catch { sqlite3async_control delay -1 } msg] $msg 143} {1 SQLITE_MISUSE} 144 145do_test async4.2.8 { 146 db close 147 sqlite3async_start 148 sqlite3async_wait 149} {} 150 151finish_test 152 153