diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/async2.test')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/test/async2.test | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/async2.test b/libraries/sqlite/unix/sqlite-3.5.1/test/async2.test new file mode 100644 index 0000000..cfbe06a --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/test/async2.test | |||
@@ -0,0 +1,127 @@ | |||
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 | # | ||
8 | # $Id: async2.test,v 1.8 2007/09/05 16:54:41 danielk1977 Exp $ | ||
9 | |||
10 | |||
11 | set testdir [file dirname $argv0] | ||
12 | source $testdir/tester.tcl | ||
13 | |||
14 | if { | ||
15 | [info commands sqlite3async_enable]=="" || | ||
16 | [info command sqlite3_memdebug_fail]=="" | ||
17 | } { | ||
18 | # The async logic is not built into this system | ||
19 | puts "Skipping async2 tests: not compiled with required features" | ||
20 | finish_test | ||
21 | return | ||
22 | } | ||
23 | |||
24 | # Enable asynchronous IO. | ||
25 | |||
26 | set setup_script { | ||
27 | CREATE TABLE counter(c); | ||
28 | INSERT INTO counter(c) VALUES (1); | ||
29 | } | ||
30 | |||
31 | set sql_script { | ||
32 | BEGIN; | ||
33 | UPDATE counter SET c = 2; | ||
34 | CREATE TABLE t1(a PRIMARY KEY, b, c); | ||
35 | CREATE TABLE t2(a PRIMARY KEY, b, c); | ||
36 | COMMIT; | ||
37 | |||
38 | BEGIN; | ||
39 | UPDATE counter SET c = 3; | ||
40 | INSERT INTO t1 VALUES('abcdefghij', 'four', 'score'); | ||
41 | INSERT INTO t2 VALUES('klmnopqrst', 'and', 'seven'); | ||
42 | COMMIT; | ||
43 | |||
44 | UPDATE counter SET c = 'FIN'; | ||
45 | } | ||
46 | |||
47 | db close | ||
48 | |||
49 | foreach err [list ioerr malloc-transient malloc-persistent] { | ||
50 | set ::go 1 | ||
51 | for {set n 1} {$::go} {incr n} { | ||
52 | set ::sqlite_io_error_pending 0 | ||
53 | sqlite3_memdebug_fail -1 | ||
54 | file delete -force test.db test.db-journal | ||
55 | sqlite3 db test.db | ||
56 | execsql $::setup_script | ||
57 | db close | ||
58 | |||
59 | sqlite3async_enable 1 | ||
60 | sqlite3 db test.db | ||
61 | |||
62 | switch -- $err { | ||
63 | ioerr { set ::sqlite_io_error_pending $n } | ||
64 | malloc-persistent { sqlite3_memdebug_fail $n -repeat 1 } | ||
65 | malloc-transient { sqlite3_memdebug_fail $n -repeat 0 } | ||
66 | } | ||
67 | |||
68 | catchsql $::sql_script | ||
69 | db close | ||
70 | |||
71 | sqlite3async_halt idle | ||
72 | sqlite3async_start | ||
73 | sqlite3async_wait | ||
74 | sqlite3async_enable 0 | ||
75 | |||
76 | set ::sqlite_io_error_pending 0 | ||
77 | sqlite3_memdebug_fail -1 | ||
78 | |||
79 | sqlite3 db test.db | ||
80 | set c [db eval {SELECT c FROM counter LIMIT 1}] | ||
81 | switch -- $c { | ||
82 | 1 { | ||
83 | do_test async-$err-1.1.$n { | ||
84 | execsql { | ||
85 | SELECT name FROM sqlite_master; | ||
86 | } | ||
87 | } {counter} | ||
88 | } | ||
89 | 2 { | ||
90 | do_test async-$err-1.2.$n.1 { | ||
91 | execsql { | ||
92 | SELECT * FROM t1; | ||
93 | } | ||
94 | } {} | ||
95 | do_test async-$err-1.2.$n.2 { | ||
96 | execsql { | ||
97 | SELECT * FROM t2; | ||
98 | } | ||
99 | } {} | ||
100 | } | ||
101 | 3 { | ||
102 | do_test async-$err-1.3.$n.1 { | ||
103 | execsql { | ||
104 | SELECT * FROM t1; | ||
105 | } | ||
106 | } {abcdefghij four score} | ||
107 | do_test async-$err-1.3.$n.2 { | ||
108 | execsql { | ||
109 | SELECT * FROM t2; | ||
110 | } | ||
111 | } {klmnopqrst and seven} | ||
112 | } | ||
113 | FIN { | ||
114 | set ::go 0 | ||
115 | } | ||
116 | } | ||
117 | |||
118 | db close | ||
119 | } | ||
120 | } | ||
121 | |||
122 | catch {db close} | ||
123 | sqlite3async_halt idle | ||
124 | sqlite3async_start | ||
125 | sqlite3async_wait | ||
126 | |||
127 | finish_test | ||