f84fd1
--- sqlite-src-3180000/test/sync2.test.sync2-dirsync	2017-03-30 21:26:42.000000000 +0200
f84fd1
+++ sqlite-src-3180000/test/sync2.test	2017-04-03 13:16:14.422329691 +0200
f84fd1
@@ -44,6 +44,15 @@
f84fd1
   uplevel [list do_test $tn [list execsql_sync $sql] [list {*}$res]]
f84fd1
 }
f84fd1
 
f84fd1
+# Wrapper over the expected sync count, takes DIRSYNC into consideration
f84fd1
+proc expected_sync_count {sync_count} {
f84fd1
+  ifcapable dirsync {
f84fd1
+    return $sync_count
f84fd1
+  } else {
f84fd1
+    return [ incr sync_count -1 ]
f84fd1
+  }
f84fd1
+}
f84fd1
+
f84fd1
 #-----------------------------------------------------------------------
f84fd1
 # Tests for journal mode.
f84fd1
 #
f84fd1
@@ -53,13 +62,13 @@
f84fd1
   INSERT INTO t1 VALUES(1, 2);
f84fd1
 }
f84fd1
 
f84fd1
-do_execsql_sync_test 1.1 { INSERT INTO t1 VALUES(3, 4) } 4
f84fd1
+do_execsql_sync_test 1.1 { INSERT INTO t1 VALUES(3, 4) } [ expected_sync_count 4 ]
f84fd1
 
f84fd1
 # synchronous=normal. So, 1 sync on the directory, 1 on the journal, 1 
f84fd1
 # on the db file. 3 in total.
f84fd1
 do_execsql_test      1.2.1 { PRAGMA main.synchronous = NORMAL }
f84fd1
 do_execsql_test      1.2.2 { PRAGMA main.synchronous }     1
f84fd1
-do_execsql_sync_test 1.2.3 { INSERT INTO t1 VALUES(5, 6) } 3
f84fd1
+do_execsql_sync_test 1.2.3 { INSERT INTO t1 VALUES(5, 6) } [ expected_sync_count 3 ]
f84fd1
 
f84fd1
 # synchronous=off. No syncs.
f84fd1
 do_execsql_test      1.3.1 { PRAGMA main.synchronous = OFF }
f84fd1
@@ -70,7 +79,7 @@
f84fd1
 # 2 on the journal, 1 on the db file. 4 in total.
f84fd1
 do_execsql_test      1.4.1 { PRAGMA main.synchronous = FULL }
f84fd1
 do_execsql_test      1.4.2 { PRAGMA main.synchronous }      2
f84fd1
-do_execsql_sync_test 1.4.3 { INSERT INTO t1 VALUES(9, 10) } 4
f84fd1
+do_execsql_sync_test 1.4.3 { INSERT INTO t1 VALUES(9, 10) } [ expected_sync_count 4 ]
f84fd1
 
f84fd1
 #-----------------------------------------------------------------------
f84fd1
 # Tests for wal mode.
f84fd1
@@ -79,7 +88,7 @@
f84fd1
 
f84fd1
 # sync=full, journal_mode=wal. One sync on the directory, two on the 
f84fd1
 # wal file.
f84fd1
-do_execsql_sync_test 1.6 { INSERT INTO t1 VALUES(11, 12) } 3
f84fd1
+do_execsql_sync_test 1.6 { INSERT INTO t1 VALUES(11, 12) } [ expected_sync_count 3 ]
f84fd1
 
f84fd1
 # One sync on the wal file.
f84fd1
 do_execsql_sync_test 1.7 { INSERT INTO t1 VALUES(13, 14) } 1
f84fd1
@@ -112,7 +121,7 @@
f84fd1
 
f84fd1
   # Wal mode, sync=normal. The first transaction does one sync on directory,
f84fd1
   # one on the wal file. The second does no syncs.
f84fd1
-  do_execsql_sync_test 1.11.1 { INSERT INTO t1 VALUES(19, 20) } 2
f84fd1
+  do_execsql_sync_test 1.11.1 { INSERT INTO t1 VALUES(19, 20) } [ expected_sync_count 2 ]
f84fd1
   do_execsql_sync_test 1.11.2 { INSERT INTO t1 VALUES(21, 22) } 0
f84fd1
   do_execsql_test 1.11.3      { PRAGMA main.synchronous }       1
f84fd1
 
f84fd1
@@ -129,14 +138,14 @@
f84fd1
   # Delete mode, sync=full. The first transaction does one sync on 
f84fd1
   # directory, two on the journal file, one on the db. The second does 
f84fd1
   # the same.
f84fd1
-  do_execsql_sync_test 1.15.1 { INSERT INTO t1 VALUES(26, 27) } 4
f84fd1
-  do_execsql_sync_test 1.15.2 { INSERT INTO t1 VALUES(28, 29) } 4
f84fd1
+  do_execsql_sync_test 1.15.1 { INSERT INTO t1 VALUES(26, 27) } [ expected_sync_count 4 ]
f84fd1
+  do_execsql_sync_test 1.15.2 { INSERT INTO t1 VALUES(28, 29) } [ expected_sync_count 4 ]
f84fd1
   do_execsql_test 1.15.3      { PRAGMA main.synchronous }       2
f84fd1
 
f84fd1
   # Switch back to wal mode.
f84fd1
   do_execsql_test 1.16 { PRAGMA journal_mode = wal } {wal}
f84fd1
 
f84fd1
-  do_execsql_sync_test 1.17.1 { INSERT INTO t1 VALUES(30, 31) } 2
f84fd1
+  do_execsql_sync_test 1.17.1 { INSERT INTO t1 VALUES(30, 31) } [ expected_sync_count 2 ]
f84fd1
   do_execsql_sync_test 1.17.2 { INSERT INTO t1 VALUES(32, 33) } 0
f84fd1
   do_execsql_test 1.17.3      { PRAGMA main.synchronous }       1
f84fd1
 
f84fd1
@@ -152,8 +161,8 @@
f84fd1
   # Close and reopen the db. Back to synchronous=normal.
f84fd1
   db close
f84fd1
   sqlite3 db test.db
f84fd1
-  do_execsql_sync_test 1.20.1 { INSERT INTO t1 VALUES(38, 39) } 4
f84fd1
-  do_execsql_sync_test 1.20.2 { INSERT INTO t1 VALUES(40, 41) } 4
f84fd1
+  do_execsql_sync_test 1.20.1 { INSERT INTO t1 VALUES(38, 39) } [ expected_sync_count 4 ]
f84fd1
+  do_execsql_sync_test 1.20.2 { INSERT INTO t1 VALUES(40, 41) } [ expected_sync_count 4 ]
f84fd1
   do_execsql_test 1.20.3      { PRAGMA main.synchronous }       2
f84fd1
 }
f84fd1