pagerfault2.test 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # 2010 June 15
  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. #
  12. # The tests in this file test the pager modules response to various
  13. # fault conditions (OOM, IO error, disk full etc.). They are similar
  14. # to those in file pagerfault1.test.
  15. #
  16. # More specifically, the tests in this file are those deemed too slow to
  17. # run as part of pagerfault1.test.
  18. #
  19. set testdir [file dirname $argv0]
  20. source $testdir/tester.tcl
  21. source $testdir/lock_common.tcl
  22. source $testdir/malloc_common.tcl
  23. if {[permutation] == "inmemory_journal"} {
  24. finish_test
  25. return
  26. }
  27. sqlite3_memdebug_vfs_oom_test 0
  28. set a_string_counter 1
  29. proc a_string {n} {
  30. global a_string_counter
  31. incr a_string_counter
  32. string range [string repeat "${a_string_counter}." $n] 1 $n
  33. }
  34. db func a_string a_string
  35. do_test pagerfault2-1-pre1 {
  36. faultsim_delete_and_reopen
  37. db func a_string a_string
  38. execsql {
  39. PRAGMA auto_vacuum = 0;
  40. PRAGMA journal_mode = DELETE;
  41. PRAGMA page_size = 1024;
  42. CREATE TABLE t1(a, b);
  43. INSERT INTO t1 VALUES(a_string(401), a_string(402));
  44. }
  45. for {set ii 0} {$ii < 13} {incr ii} {
  46. execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }
  47. }
  48. faultsim_save_and_close
  49. file size test.db
  50. } [expr 1024 * 8268]
  51. do_faultsim_test pagerfault2-1 -faults oom-transient -prep {
  52. faultsim_restore_and_reopen
  53. sqlite3_db_config_lookaside db 0 256 4096
  54. execsql {
  55. BEGIN;
  56. SELECT * FROM t1;
  57. INSERT INTO t1 VALUES(5, 6);
  58. SAVEPOINT abc;
  59. UPDATE t1 SET a = a||'x' WHERE rowid<3700;
  60. }
  61. } -body {
  62. execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 }
  63. execsql { ROLLBACK TO abc }
  64. } -test {
  65. faultsim_test_result {0 {}}
  66. }
  67. do_test pagerfault2-2-pre1 {
  68. faultsim_restore_and_reopen
  69. execsql { DELETE FROM t1 }
  70. faultsim_save_and_close
  71. } {}
  72. do_faultsim_test pagerfault2-2 -faults oom-transient -prep {
  73. faultsim_restore_and_reopen
  74. sqlite3_db_config_lookaside db 0 256 4096
  75. db func a_string a_string
  76. execsql {
  77. PRAGMA cache_size = 20;
  78. BEGIN;
  79. INSERT INTO t1 VALUES(a_string(401), a_string(402));
  80. SAVEPOINT abc;
  81. }
  82. } -body {
  83. execsql { INSERT INTO t1 VALUES (a_string(2000000), a_string(2500000)) }
  84. } -test {
  85. faultsim_test_result {0 {}}
  86. }
  87. sqlite3_memdebug_vfs_oom_test 1
  88. finish_test