3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the operation of the library in
13 # "PRAGMA journal_mode=WAL" mode. The tests in this file use
14 # brute force methods, so may take a while to run.
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 ifcapable !wal {finish_test ; return }
24 forcedelete test.db test.db-wal
26 execsql { PRAGMA journal_mode = wal }
31 for {set seed 1} {$seed<10} {incr seed} {
35 do_test walslow-1.seed=$seed.0 {
36 execsql { CREATE TABLE t1(a, b) }
37 execsql { CREATE INDEX i1 ON t1(a) }
38 execsql { CREATE INDEX i2 ON t1(b) }
41 for {set iTest 1} {$iTest < 100} {incr iTest} {
43 do_test walslow-1.seed=$seed.$iTest.1 {
44 set w [expr int(rand()*2000)]
45 set x [expr int(rand()*2000)]
46 execsql { INSERT INTO t1 VALUES(randomblob($w), randomblob($x)) }
47 execsql { PRAGMA integrity_check }
50 do_test walslow-1.seed=$seed.$iTest.2 {
51 execsql "PRAGMA wal_checkpoint;"
52 execsql { PRAGMA integrity_check }
55 do_test walslow-1.seed=$seed.$iTest.3 {
56 forcedelete testX.db testX.db-wal
57 copy_file test.db testX.db
58 copy_file test.db-wal testX.db-wal
61 execsql { PRAGMA journal_mode = WAL } db2
62 execsql { PRAGMA integrity_check } db2
65 do_test walslow-1.seed=$seed.$iTest.4 {
66 execsql { SELECT count(*) FROM t1 WHERE a!=b } db2
67 } [execsql { SELECT count(*) FROM t1 WHERE a!=b }]