Update test file walprotocol.test to account for the changes in the wal
[sqlite.git] / test / sync.test
blob210039acb5b7ace866ea5046ecf7ca050aa706c9
1 # 2005 August 28
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.
13 # This file implements tests to verify that fsync is disabled when
14 # pragma synchronous=off even for multi-database commits.
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
21 # These tests are only applicable when pager pragma are
22 # enabled. Also, since every test uses an ATTACHed database, they
23 # are only run when ATTACH is enabled.
25 ifcapable !pager_pragmas||!attach {
26   finish_test
27   return
30 set sqlite_sync_count 0
31 proc cond_incr_sync_count {adj} {
32   global sqlite_sync_count
33   if {$::tcl_platform(platform) == "windows"} {
34     incr sqlite_sync_count $adj
35   } else {
36     ifcapable !dirsync {
37       incr sqlite_sync_count $adj
38     }
39   }
42 do_test sync-1.1 {
43   set sqlite_sync_count 0
44   forcedelete test2.db
45   forcedelete test2.db-journal
46   execsql {
47     PRAGMA fullfsync=OFF;
48     CREATE TABLE t1(a,b);
49     ATTACH DATABASE 'test2.db' AS db2;
50     CREATE TABLE db2.t2(x,y);
51   }
52   cond_incr_sync_count 2
53   set sqlite_sync_count
54 } 8
55 ifcapable pager_pragmas {
56   do_test sync-1.2 {
57     set sqlite_sync_count 0
58     execsql {
59       PRAGMA main.synchronous=on;
60       PRAGMA db2.synchronous=on;
61       BEGIN;
62       INSERT INTO t1 VALUES(1,2);
63       INSERT INTO t2 VALUES(3,4);
64       COMMIT;
65     }
66     cond_incr_sync_count 4
67     set sqlite_sync_count
68   } 9
70 do_test sync-1.3 {
71   set sqlite_sync_count 0
72   execsql {
73     PRAGMA main.synchronous=full;
74     PRAGMA db2.synchronous=full;
75     BEGIN;
76     INSERT INTO t1 VALUES(3,4);
77     INSERT INTO t2 VALUES(5,6);
78     COMMIT;
79   }
80   cond_incr_sync_count 4
81   set sqlite_sync_count
82 } 11
83 ifcapable pager_pragmas {
84 if {[permutation]!="journaltest"} {
85   do_test sync-1.4 {
86     set sqlite_sync_count 0
87     execsql {
88       PRAGMA main.synchronous=off;
89       PRAGMA db2.synchronous=off;
90       BEGIN;
91       INSERT INTO t1 VALUES(5,6);
92       INSERT INTO t2 VALUES(7,8);
93       COMMIT;
94     }
95     set sqlite_sync_count
96   } 0
101 finish_test