btreefault.test 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # 2013 April 02
  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. # This file contains fault injection tests designed to test the btree.c
  13. # module.
  14. #
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. source $testdir/malloc_common.tcl
  18. set testprefix btreefault
  19. # This test will not work with an in-memory journal, as the database will
  20. # become corrupt if an error is injected into a transaction after it starts
  21. # writing data out to the db file.
  22. if {[permutation]=="inmemory_journal"} {
  23. finish_test
  24. return
  25. }
  26. do_test 1-pre1 {
  27. execsql {
  28. PRAGMA auto_vacuum = incremental;
  29. PRAGMA journal_mode = DELETE;
  30. CREATE TABLE t1(a PRIMARY KEY, b);
  31. INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
  32. INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
  33. INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
  34. INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
  35. INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
  36. DELETE FROM t1 WHERE rowid%2;
  37. }
  38. faultsim_save_and_close
  39. } {}
  40. do_faultsim_test 1 -prep {
  41. faultsim_restore_and_reopen
  42. set ::STMT [sqlite3_prepare db "SELECT * FROM t1 ORDER BY a" -1 DUMMY]
  43. sqlite3_step $::STMT
  44. sqlite3_step $::STMT
  45. } -body {
  46. execsql { PRAGMA incremental_vacuum = 10 }
  47. } -test {
  48. sqlite3_finalize $::STMT
  49. faultsim_test_result {0 {}}
  50. faultsim_integrity_check
  51. }
  52. finish_test