os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/memleak.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2001 September 15
sl@0
     2
#
sl@0
     3
# The author disclaims copyright to this source code.  In place of
sl@0
     4
# a legal notice, here is a blessing:
sl@0
     5
#
sl@0
     6
#    May you do good and not evil.
sl@0
     7
#    May you find forgiveness for yourself and forgive others.
sl@0
     8
#    May you share freely, never taking more than you give.
sl@0
     9
#
sl@0
    10
#***********************************************************************
sl@0
    11
# This file runs all tests.
sl@0
    12
#
sl@0
    13
# $Id: memleak.test,v 1.10 2007/03/30 17:17:52 drh Exp $
sl@0
    14
sl@0
    15
set testdir [file dirname $argv0]
sl@0
    16
source $testdir/tester.tcl
sl@0
    17
rename finish_test memleak_finish_test
sl@0
    18
proc finish_test {} {
sl@0
    19
  catch {db close}
sl@0
    20
  memleak_check
sl@0
    21
}
sl@0
    22
sl@0
    23
if {[file exists ./sqlite_test_count]} {
sl@0
    24
  set COUNT [exec cat ./sqlite_test_count]
sl@0
    25
} else {
sl@0
    26
  set COUNT 3
sl@0
    27
}
sl@0
    28
sl@0
    29
# LeakList will hold a list of the number of unfreed mallocs after
sl@0
    30
# each round of the test.  This number should be constant.  If it
sl@0
    31
# grows, it may mean there is a memory leak in the library.
sl@0
    32
#
sl@0
    33
set LeakList {}
sl@0
    34
sl@0
    35
set EXCLUDE {
sl@0
    36
  all.test
sl@0
    37
  quick.test
sl@0
    38
  misuse.test
sl@0
    39
  memleak.test
sl@0
    40
  btree2.test
sl@0
    41
  async.test
sl@0
    42
  async2.test
sl@0
    43
  trans.test
sl@0
    44
  crash.test
sl@0
    45
  autovacuum_crash.test
sl@0
    46
}
sl@0
    47
# Test files btree2.test and btree4.test don't work if the 
sl@0
    48
# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
sl@0
    49
# on tables being allocated starting at page 2).
sl@0
    50
#
sl@0
    51
ifcapable default_autovacuum {
sl@0
    52
  lappend EXCLUDE btree2.test
sl@0
    53
  lappend EXCLUDE btree4.test
sl@0
    54
}
sl@0
    55
sl@0
    56
if {[sqlite3 -has-codec]} {
sl@0
    57
  # lappend EXCLUDE 
sl@0
    58
}
sl@0
    59
if {[llength $argv]>0} {
sl@0
    60
  set FILELIST $argv
sl@0
    61
  set argv {}
sl@0
    62
} else {
sl@0
    63
  set FILELIST [lsort -dictionary [glob $testdir/*.test]]
sl@0
    64
}
sl@0
    65
sl@0
    66
foreach testfile $FILELIST {
sl@0
    67
  set tail [file tail $testfile]
sl@0
    68
  if {[lsearch -exact $EXCLUDE $tail]>=0} continue
sl@0
    69
  set LeakList {}
sl@0
    70
  for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} {
sl@0
    71
    source $testfile
sl@0
    72
    if {[info exists Leak]} {
sl@0
    73
      lappend LeakList $Leak
sl@0
    74
    }
sl@0
    75
  }
sl@0
    76
  if {$LeakList!=""} {
sl@0
    77
    puts -nonewline memory-leak-test-$tail...
sl@0
    78
    incr ::nTest
sl@0
    79
    foreach x $LeakList {
sl@0
    80
      if {$x!=[lindex $LeakList 0]} {
sl@0
    81
         puts " failed! ($LeakList)"
sl@0
    82
         incr ::nErr
sl@0
    83
         lappend ::failList memory-leak-test-$tail
sl@0
    84
         break
sl@0
    85
       }
sl@0
    86
    }
sl@0
    87
    puts " Ok"
sl@0
    88
  }
sl@0
    89
}
sl@0
    90
memleak_finish_test
sl@0
    91
sl@0
    92
# Run the malloc tests and the misuse test after memory leak detection.
sl@0
    93
# Both tests leak memory.
sl@0
    94
#
sl@0
    95
#catch {source $testdir/misuse.test}
sl@0
    96
#catch {source $testdir/malloc.test}
sl@0
    97
sl@0
    98
memleak_finish_test