memleak.test revision 2
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2001 September 15
2N/A#
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A#
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#
2N/A#***********************************************************************
2N/A# This file runs all tests.
2N/A#
2N/A# $Id: memleak.test,v 1.3 2004/02/12 18:46:39 drh Exp $
2N/A
2N/Aset testdir [file dirname $argv0]
2N/Asource $testdir/tester.tcl
2N/Arename finish_test really_finish_test
2N/Aproc finish_test {} {
2N/A catch {db close}
2N/A memleak_check
2N/A}
2N/A
2N/Aif {[file exists ./sqlite_test_count]} {
2N/A set COUNT [exec cat ./sqlite_test_count]
2N/A} else {
2N/A set COUNT 3
2N/A}
2N/A
2N/A# LeakList will hold a list of the number of unfreed mallocs after
2N/A# each round of the test. This number should be constant. If it
2N/A# grows, it may mean there is a memory leak in the library.
2N/A#
2N/Aset LeakList {}
2N/A
2N/Aset EXCLUDE {
2N/A all.test
2N/A quick.test
2N/A malloc.test
2N/A misuse.test
2N/A memleak.test
2N/A btree2.test
2N/A trans.test
2N/A}
2N/Aif {[sqlite -has-codec]} {
2N/A lappend EXCLUDE \
2N/A attach.test \
2N/A attach2.test \
2N/A auth.test \
2N/A format3.test \
2N/A version.test
2N/A}
2N/Aif {[llength $argv]>0} {
2N/A set FILELIST $argv
2N/A set argv {}
2N/A} else {
2N/A set FILELIST [lsort -dictionary [glob $testdir/*.test]]
2N/A}
2N/A
2N/Aforeach testfile $FILELIST {
2N/A set tail [file tail $testfile]
2N/A if {[lsearch -exact $EXCLUDE $tail]>=0} continue
2N/A set LeakList {}
2N/A for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} {
2N/A source $testfile
2N/A if {[info exists Leak]} {
2N/A lappend LeakList $Leak
2N/A }
2N/A }
2N/A if {$LeakList!=""} {
2N/A puts -nonewline memory-leak-test-$tail...
2N/A incr ::nTest
2N/A foreach x $LeakList {
2N/A if {$x!=[lindex $LeakList 0]} {
2N/A puts " failed! ($LeakList)"
2N/A incr ::nErr
2N/A lappend ::failList memory-leak-test-$tail
2N/A break
2N/A }
2N/A }
2N/A puts " Ok"
2N/A }
2N/A}
2N/Areally_finish_test
2N/A
2N/A# Run the malloc tests and the misuse test after memory leak detection.
2N/A# Both tests leak memory.
2N/A#
2N/A#catch {source $testdir/misuse.test}
2N/A#catch {source $testdir/malloc.test}
2N/A
2N/Areally_finish_test