1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/memleak.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,98 @@
1.4 +# 2001 September 15
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file runs all tests.
1.15 +#
1.16 +# $Id: memleak.test,v 1.10 2007/03/30 17:17:52 drh Exp $
1.17 +
1.18 +set testdir [file dirname $argv0]
1.19 +source $testdir/tester.tcl
1.20 +rename finish_test memleak_finish_test
1.21 +proc finish_test {} {
1.22 + catch {db close}
1.23 + memleak_check
1.24 +}
1.25 +
1.26 +if {[file exists ./sqlite_test_count]} {
1.27 + set COUNT [exec cat ./sqlite_test_count]
1.28 +} else {
1.29 + set COUNT 3
1.30 +}
1.31 +
1.32 +# LeakList will hold a list of the number of unfreed mallocs after
1.33 +# each round of the test. This number should be constant. If it
1.34 +# grows, it may mean there is a memory leak in the library.
1.35 +#
1.36 +set LeakList {}
1.37 +
1.38 +set EXCLUDE {
1.39 + all.test
1.40 + quick.test
1.41 + misuse.test
1.42 + memleak.test
1.43 + btree2.test
1.44 + async.test
1.45 + async2.test
1.46 + trans.test
1.47 + crash.test
1.48 + autovacuum_crash.test
1.49 +}
1.50 +# Test files btree2.test and btree4.test don't work if the
1.51 +# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
1.52 +# on tables being allocated starting at page 2).
1.53 +#
1.54 +ifcapable default_autovacuum {
1.55 + lappend EXCLUDE btree2.test
1.56 + lappend EXCLUDE btree4.test
1.57 +}
1.58 +
1.59 +if {[sqlite3 -has-codec]} {
1.60 + # lappend EXCLUDE
1.61 +}
1.62 +if {[llength $argv]>0} {
1.63 + set FILELIST $argv
1.64 + set argv {}
1.65 +} else {
1.66 + set FILELIST [lsort -dictionary [glob $testdir/*.test]]
1.67 +}
1.68 +
1.69 +foreach testfile $FILELIST {
1.70 + set tail [file tail $testfile]
1.71 + if {[lsearch -exact $EXCLUDE $tail]>=0} continue
1.72 + set LeakList {}
1.73 + for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} {
1.74 + source $testfile
1.75 + if {[info exists Leak]} {
1.76 + lappend LeakList $Leak
1.77 + }
1.78 + }
1.79 + if {$LeakList!=""} {
1.80 + puts -nonewline memory-leak-test-$tail...
1.81 + incr ::nTest
1.82 + foreach x $LeakList {
1.83 + if {$x!=[lindex $LeakList 0]} {
1.84 + puts " failed! ($LeakList)"
1.85 + incr ::nErr
1.86 + lappend ::failList memory-leak-test-$tail
1.87 + break
1.88 + }
1.89 + }
1.90 + puts " Ok"
1.91 + }
1.92 +}
1.93 +memleak_finish_test
1.94 +
1.95 +# Run the malloc tests and the misuse test after memory leak detection.
1.96 +# Both tests leak memory.
1.97 +#
1.98 +#catch {source $testdir/misuse.test}
1.99 +#catch {source $testdir/malloc.test}
1.100 +
1.101 +memleak_finish_test