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.
6 #***********************************************************************
8 # $Id: async2.test,v 1.12 2009/04/25 08:39:15 danielk1977 Exp $
11 set testdir [file dirname $argv0]
12 source $testdir/tester.tcl
15 [info commands sqlite3async_initialize]=="" ||
16 [info command sqlite3_memdebug_fail]==""
18 # The async logic is not built into this system
19 puts "Skipping async2 tests: not compiled with required features"
24 # Enable asynchronous IO.
27 CREATE TABLE counter(c);
28 INSERT INTO counter(c) VALUES (1);
33 UPDATE counter SET c = 2;
34 CREATE TABLE t1(a PRIMARY KEY, b, c);
35 CREATE TABLE t2(a PRIMARY KEY, b, c);
39 UPDATE counter SET c = 3;
40 INSERT INTO t1 VALUES('abcdefghij', 'four', 'score');
41 INSERT INTO t2 VALUES('klmnopqrst', 'and', 'seven');
44 UPDATE counter SET c = 'FIN';
49 foreach err [list ioerr malloc-transient malloc-persistent] {
51 for {set n 1} {$::go} {incr n} {
52 set ::sqlite_io_error_pending 0
53 sqlite3_memdebug_fail -1
54 forcedelete test.db test.db-journal
56 execsql $::setup_script
59 sqlite3async_initialize "" 1
61 sqlite3_db_config_lookaside db 0 0 0
64 ioerr { set ::sqlite_io_error_pending $n }
65 malloc-persistent { sqlite3_memdebug_fail $n -repeat 1 }
66 malloc-transient { sqlite3_memdebug_fail $n -repeat 0 }
69 catchsql $::sql_script
72 sqlite3async_control halt idle
75 sqlite3async_control halt never
78 set ::sqlite_io_error_pending 0
79 sqlite3_memdebug_fail -1
82 set c [db one {SELECT c FROM counter LIMIT 1}]
85 do_test async-$err-1.1.$n {
87 SELECT name FROM sqlite_master;
92 do_test async-$err-1.2.$n.1 {
97 do_test async-$err-1.2.$n.2 {
104 do_test async-$err-1.3.$n.1 {
108 } {abcdefghij four score}
109 do_test async-$err-1.3.$n.2 {
113 } {klmnopqrst and seven}