soak.test 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # 2007 May 24
  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 is the driver for the "soak" tests. It is a peer of the
  12. # quick.test and all.test scripts.
  13. #
  14. # $Id: soak.test,v 1.4 2008/11/13 18:29:51 shane Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. rename finish_test really_finish_test
  18. proc finish_test {} {}
  19. # By default, guarantee that the tests will run for at least 1 hour.
  20. #
  21. set TIMEOUT 3600
  22. # Process command-line arguments.
  23. #
  24. if {[llength $argv]>0} {
  25. foreach {name value} $argv {
  26. switch -- $name {
  27. -timeout {
  28. set TIMEOUT $value
  29. }
  30. default {
  31. puts stderr "Unknown option: $name"
  32. exit
  33. }
  34. }
  35. }
  36. }
  37. set argv [list]
  38. # Test plan:
  39. #
  40. # The general principle is to run those SQLite tests that use
  41. # pseudo-random data in some way over and over again for a very
  42. # long time. The number of tests run depends on the value of
  43. # global variable $TIMEOUT - tests are run for at least $TIMEOUT
  44. # seconds.
  45. #
  46. # fuzz.test (pseudo-random SQL statements)
  47. # trans.test (pseudo-random changes to a database followed by rollbacks)
  48. # fuzz_malloc.test
  49. # corruptC.test (pseudo-random corruption to a database)
  50. #
  51. # Many database changes maintaining some kind of invariant.
  52. # Storing checksums etc.
  53. #
  54. # List of test files that are run by this file.
  55. #
  56. set SOAKTESTS {
  57. fuzz.test
  58. fuzz_malloc.test
  59. trans.test
  60. corruptC.test
  61. }
  62. set G(isquick) 1
  63. set soak_starttime [clock seconds]
  64. set soak_finishtime [expr {$soak_starttime + $TIMEOUT}]
  65. # Loop until the timeout is reached or an error occurs.
  66. #
  67. for {set iRun 0} {[clock seconds] < $soak_finishtime} {incr iRun} {
  68. set iIdx [expr {$iRun % [llength $SOAKTESTS]}]
  69. source [file join $testdir [lindex $SOAKTESTS $iIdx]]
  70. catch {db close}
  71. if {$sqlite_open_file_count>0} {
  72. puts "$tail did not close all files: $sqlite_open_file_count"
  73. fail_test $tail
  74. set sqlite_open_file_count 0
  75. }
  76. if {[set_test_counter errors]>0} break
  77. }
  78. really_finish_test