memleak.test 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # 2001 September 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. # This file runs all tests.
  12. #
  13. # $Id: memleak.test,v 1.10 2007/03/30 17:17:52 drh Exp $
  14. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. rename finish_test memleak_finish_test
  17. proc finish_test {} {
  18. catch {db close}
  19. memleak_check
  20. }
  21. if {[file exists ./sqlite_test_count]} {
  22. set COUNT [exec cat ./sqlite_test_count]
  23. } else {
  24. set COUNT 3
  25. }
  26. # LeakList will hold a list of the number of unfreed mallocs after
  27. # each round of the test. This number should be constant. If it
  28. # grows, it may mean there is a memory leak in the library.
  29. #
  30. set LeakList {}
  31. set EXCLUDE {
  32. all.test
  33. quick.test
  34. misuse.test
  35. memleak.test
  36. btree2.test
  37. async.test
  38. async2.test
  39. trans.test
  40. crash.test
  41. autovacuum_crash.test
  42. }
  43. # Test files btree2.test and btree4.test don't work if the
  44. # SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
  45. # on tables being allocated starting at page 2).
  46. #
  47. ifcapable default_autovacuum {
  48. lappend EXCLUDE btree2.test
  49. lappend EXCLUDE btree4.test
  50. }
  51. if {[sqlite3 -has-codec]} {
  52. # lappend EXCLUDE
  53. }
  54. if {[llength $argv]>0} {
  55. set FILELIST $argv
  56. set argv {}
  57. } else {
  58. set FILELIST [lsort -dictionary [glob $testdir/*.test]]
  59. }
  60. foreach testfile $FILELIST {
  61. set tail [file tail $testfile]
  62. if {[lsearch -exact $EXCLUDE $tail]>=0} continue
  63. set LeakList {}
  64. for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} {
  65. source $testfile
  66. if {[info exists Leak]} {
  67. lappend LeakList $Leak
  68. }
  69. }
  70. if {$LeakList!=""} {
  71. puts -nonewline memory-leak-test-$tail...
  72. incr_ntest
  73. foreach x $LeakList {
  74. if {$x!=[lindex $LeakList 0]} {
  75. puts " failed! ($LeakList)"
  76. fail_test memory-leak-test-$tail
  77. break
  78. }
  79. }
  80. puts " Ok"
  81. }
  82. }
  83. memleak_finish_test
  84. # Run the malloc tests and the misuse test after memory leak detection.
  85. # Both tests leak memory.
  86. #
  87. #catch {source $testdir/misuse.test}
  88. #catch {source $testdir/malloc.test}
  89. memleak_finish_test