Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/memleak.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / memleak.test` 95 lines ยท 2297 bytes Raw Blame History 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 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 rename finish_test memleak_finish_test 18 proc finish_test {} { 19 catch {db close} 20 memleak_check 21 } 22 23 if {[file exists ./sqlite_test_count]} { 24 set COUNT [exec cat ./sqlite_test_count] 25 } else { 26 set COUNT 3 27 } 28 29 # LeakList will hold a list of the number of unfreed mallocs after 30 # each round of the test. This number should be constant. If it 31 # grows, it may mean there is a memory leak in the library. 32 # 33 set LeakList {} 34 35 set EXCLUDE { 36 all.test 37 quick.test 38 misuse.test 39 memleak.test 40 btree2.test 41 trans.test 42 crash.test 43 autovacuum_crash.test 44 } 45 # Test files btree2.test and btree4.test don't work if the 46 # SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend 47 # on tables being allocated starting at page 2). 48 # 49 ifcapable default_autovacuum { 50 lappend EXCLUDE btree2.test 51 lappend EXCLUDE btree4.test 52 } 53 54 if {[sqlite3 -has-codec]} { 55 # lappend EXCLUDE 56 } 57 if {[llength $argv]>0} { 58 set FILELIST $argv 59 set argv {} 60 } else { 61 set FILELIST [lsort -dictionary [glob $testdir/*.test]] 62 } 63 64 foreach testfile $FILELIST { 65 set tail [file tail $testfile] 66 if {[lsearch -exact $EXCLUDE $tail]>=0} continue 67 set LeakList {} 68 for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} { 69 source $testfile 70 if {[info exists Leak]} { 71 lappend LeakList $Leak 72 } 73 } 74 if {$LeakList!=""} { 75 puts -nonewline memory-leak-test-$tail... 76 incr_ntest 77 foreach x $LeakList { 78 if {$x!=[lindex $LeakList 0]} { 79 puts " failed! ($LeakList)" 80 fail_test memory-leak-test-$tail 81 break 82 } 83 } 84 puts " Ok" 85 } 86 } 87 memleak_finish_test 88 89 # Run the malloc tests and the misuse test after memory leak detection. 90 # Both tests leak memory. 91 # 92 #catch {source $testdir/misuse.test} 93 #catch {source $testdir/malloc.test} 94 95 memleak_finish_test