1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/sync.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,98 @@
1.4 +# 2005 August 28
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# This file implements tests to verify that fsync is disabled when
1.17 +# pragma synchronous=off even for multi-database commits.
1.18 +#
1.19 +# $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $
1.20 +
1.21 +set testdir [file dirname $argv0]
1.22 +source $testdir/tester.tcl
1.23 +
1.24 +#
1.25 +# These tests are only applicable on unix when pager pragma are
1.26 +# enabled. Also, since every test uses an ATTACHed database, they
1.27 +# are only run when ATTACH is enabled.
1.28 +#
1.29 +if {$::tcl_platform(platform)!="unix"} {
1.30 + finish_test
1.31 + return
1.32 +}
1.33 +ifcapable !pager_pragmas||!attach {
1.34 + finish_test
1.35 + return
1.36 +}
1.37 +
1.38 +do_test sync-1.1 {
1.39 + set sqlite_sync_count 0
1.40 + file delete -force test2.db
1.41 + file delete -force test2.db-journal
1.42 + execsql {
1.43 + PRAGMA fullfsync=OFF;
1.44 + CREATE TABLE t1(a,b);
1.45 + ATTACH DATABASE 'test2.db' AS db2;
1.46 + CREATE TABLE db2.t2(x,y);
1.47 + }
1.48 + ifcapable !dirsync {
1.49 + incr sqlite_sync_count 2
1.50 + }
1.51 + set sqlite_sync_count
1.52 +} 8
1.53 +ifcapable pager_pragmas {
1.54 + do_test sync-1.2 {
1.55 + set sqlite_sync_count 0
1.56 + execsql {
1.57 + PRAGMA main.synchronous=on;
1.58 + PRAGMA db2.synchronous=on;
1.59 + BEGIN;
1.60 + INSERT INTO t1 VALUES(1,2);
1.61 + INSERT INTO t2 VALUES(3,4);
1.62 + COMMIT;
1.63 + }
1.64 + ifcapable !dirsync {
1.65 + incr sqlite_sync_count 3
1.66 + }
1.67 + set sqlite_sync_count
1.68 + } 8
1.69 +}
1.70 +do_test sync-1.3 {
1.71 + set sqlite_sync_count 0
1.72 + execsql {
1.73 + PRAGMA main.synchronous=full;
1.74 + PRAGMA db2.synchronous=full;
1.75 + BEGIN;
1.76 + INSERT INTO t1 VALUES(3,4);
1.77 + INSERT INTO t2 VALUES(5,6);
1.78 + COMMIT;
1.79 + }
1.80 + ifcapable !dirsync {
1.81 + incr sqlite_sync_count 3
1.82 + }
1.83 + set sqlite_sync_count
1.84 +} 10
1.85 +ifcapable pager_pragmas {
1.86 + do_test sync-1.4 {
1.87 + set sqlite_sync_count 0
1.88 + execsql {
1.89 + PRAGMA main.synchronous=off;
1.90 + PRAGMA db2.synchronous=off;
1.91 + BEGIN;
1.92 + INSERT INTO t1 VALUES(5,6);
1.93 + INSERT INTO t2 VALUES(7,8);
1.94 + COMMIT;
1.95 + }
1.96 + set sqlite_sync_count
1.97 + } 0
1.98 +}
1.99 +
1.100 +
1.101 +finish_test