sl@0: # 2001 September 15 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file runs all tests. sl@0: # sl@0: # $Id: memleak.test,v 1.10 2007/03/30 17:17:52 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: rename finish_test memleak_finish_test sl@0: proc finish_test {} { sl@0: catch {db close} sl@0: memleak_check sl@0: } sl@0: sl@0: if {[file exists ./sqlite_test_count]} { sl@0: set COUNT [exec cat ./sqlite_test_count] sl@0: } else { sl@0: set COUNT 3 sl@0: } sl@0: sl@0: # LeakList will hold a list of the number of unfreed mallocs after sl@0: # each round of the test. This number should be constant. If it sl@0: # grows, it may mean there is a memory leak in the library. sl@0: # sl@0: set LeakList {} sl@0: sl@0: set EXCLUDE { sl@0: all.test sl@0: quick.test sl@0: misuse.test sl@0: memleak.test sl@0: btree2.test sl@0: async.test sl@0: async2.test sl@0: trans.test sl@0: crash.test sl@0: autovacuum_crash.test sl@0: } sl@0: # Test files btree2.test and btree4.test don't work if the sl@0: # SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend sl@0: # on tables being allocated starting at page 2). sl@0: # sl@0: ifcapable default_autovacuum { sl@0: lappend EXCLUDE btree2.test sl@0: lappend EXCLUDE btree4.test sl@0: } sl@0: sl@0: if {[sqlite3 -has-codec]} { sl@0: # lappend EXCLUDE sl@0: } sl@0: if {[llength $argv]>0} { sl@0: set FILELIST $argv sl@0: set argv {} sl@0: } else { sl@0: set FILELIST [lsort -dictionary [glob $testdir/*.test]] sl@0: } sl@0: sl@0: foreach testfile $FILELIST { sl@0: set tail [file tail $testfile] sl@0: if {[lsearch -exact $EXCLUDE $tail]>=0} continue sl@0: set LeakList {} sl@0: for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} { sl@0: source $testfile sl@0: if {[info exists Leak]} { sl@0: lappend LeakList $Leak sl@0: } sl@0: } sl@0: if {$LeakList!=""} { sl@0: puts -nonewline memory-leak-test-$tail... sl@0: incr ::nTest sl@0: foreach x $LeakList { sl@0: if {$x!=[lindex $LeakList 0]} { sl@0: puts " failed! ($LeakList)" sl@0: incr ::nErr sl@0: lappend ::failList memory-leak-test-$tail sl@0: break sl@0: } sl@0: } sl@0: puts " Ok" sl@0: } sl@0: } sl@0: memleak_finish_test sl@0: sl@0: # Run the malloc tests and the misuse test after memory leak detection. sl@0: # Both tests leak memory. sl@0: # sl@0: #catch {source $testdir/misuse.test} sl@0: #catch {source $testdir/malloc.test} sl@0: sl@0: memleak_finish_test