sync.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # 2005 August 28
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  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.
  9. #
  10. #***********************************************************************
  11. # This file implements regression tests for SQLite library.
  12. #
  13. # This file implements tests to verify that fsync is disabled when
  14. # pragma synchronous=off even for multi-database commits.
  15. #
  16. # $Id: sync.test,v 1.6 2007/10/09 08:29:33 danielk1977 Exp $
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. #
  20. # These tests are only applicable when pager pragma are
  21. # enabled. Also, since every test uses an ATTACHed database, they
  22. # are only run when ATTACH is enabled.
  23. #
  24. ifcapable !pager_pragmas||!attach {
  25. finish_test
  26. return
  27. }
  28. set sqlite_sync_count 0
  29. proc cond_incr_sync_count {adj} {
  30. global sqlite_sync_count
  31. if {$::tcl_platform(platform) == "windows"} {
  32. incr sqlite_sync_count $adj
  33. } {
  34. ifcapable !dirsync {
  35. incr sqlite_sync_count $adj
  36. }
  37. }
  38. }
  39. do_test sync-1.1 {
  40. set sqlite_sync_count 0
  41. forcedelete test2.db
  42. forcedelete test2.db-journal
  43. execsql {
  44. PRAGMA fullfsync=OFF;
  45. CREATE TABLE t1(a,b);
  46. ATTACH DATABASE 'test2.db' AS db2;
  47. CREATE TABLE db2.t2(x,y);
  48. }
  49. cond_incr_sync_count 2
  50. set sqlite_sync_count
  51. } 8
  52. ifcapable pager_pragmas {
  53. do_test sync-1.2 {
  54. set sqlite_sync_count 0
  55. execsql {
  56. PRAGMA main.synchronous=on;
  57. PRAGMA db2.synchronous=on;
  58. BEGIN;
  59. INSERT INTO t1 VALUES(1,2);
  60. INSERT INTO t2 VALUES(3,4);
  61. COMMIT;
  62. }
  63. cond_incr_sync_count 3
  64. set sqlite_sync_count
  65. } 8
  66. }
  67. do_test sync-1.3 {
  68. set sqlite_sync_count 0
  69. execsql {
  70. PRAGMA main.synchronous=full;
  71. PRAGMA db2.synchronous=full;
  72. BEGIN;
  73. INSERT INTO t1 VALUES(3,4);
  74. INSERT INTO t2 VALUES(5,6);
  75. COMMIT;
  76. }
  77. cond_incr_sync_count 3
  78. set sqlite_sync_count
  79. } 10
  80. ifcapable pager_pragmas {
  81. do_test sync-1.4 {
  82. set sqlite_sync_count 0
  83. execsql {
  84. PRAGMA main.synchronous=off;
  85. PRAGMA db2.synchronous=off;
  86. BEGIN;
  87. INSERT INTO t1 VALUES(5,6);
  88. INSERT INTO t2 VALUES(7,8);
  89. COMMIT;
  90. }
  91. set sqlite_sync_count
  92. } 0
  93. }
  94. finish_test