drh | bec2bf4 | 2000-05-29 23:48:22 +0000 | [diff] [blame] | 1 | # Copyright (c) 1999, 2000 D. Richard Hipp |
| 2 | # |
| 3 | # This program is free software; you can redistribute it and/or |
| 4 | # modify it under the terms of the GNU General Public |
| 5 | # License as published by the Free Software Foundation; either |
| 6 | # version 2 of the License, or (at your option) any later version. |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | # General Public License for more details. |
| 12 | # |
| 13 | # You should have received a copy of the GNU General Public |
| 14 | # License along with this library; if not, write to the |
| 15 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 16 | # Boston, MA 02111-1307, USA. |
| 17 | # |
| 18 | # Author contact information: |
| 19 | # drh@hwaci.com |
| 20 | # http://www.hwaci.com/drh/ |
| 21 | # |
| 22 | #*********************************************************************** |
| 23 | # This file runs all tests. |
| 24 | # |
drh | 5edc312 | 2001-09-13 21:53:09 +0000 | [diff] [blame^] | 25 | # $Id: all.test,v 1.8 2001/09/13 21:53:10 drh Exp $ |
drh | bec2bf4 | 2000-05-29 23:48:22 +0000 | [diff] [blame] | 26 | |
| 27 | set testdir [file dirname $argv0] |
| 28 | source $testdir/tester.tcl |
| 29 | rename finish_test really_finish_test |
drh | 8c82b35 | 2000-12-10 18:23:50 +0000 | [diff] [blame] | 30 | proc finish_test {} {memleak_check} |
drh | bec2bf4 | 2000-05-29 23:48:22 +0000 | [diff] [blame] | 31 | |
drh | df16aed | 2000-06-02 14:27:22 +0000 | [diff] [blame] | 32 | if {[file exists ./sqlite_test_count]} { |
| 33 | set COUNT [exec cat ./sqlite_test_count] |
| 34 | } else { |
drh | d400728 | 2001-04-12 23:21:58 +0000 | [diff] [blame] | 35 | set COUNT 3 |
drh | df16aed | 2000-06-02 14:27:22 +0000 | [diff] [blame] | 36 | } |
| 37 | |
drh | 8c82b35 | 2000-12-10 18:23:50 +0000 | [diff] [blame] | 38 | # LeakList will hold a list of the number of unfreed mallocs after |
| 39 | # each round of the test. This number should be constant. If it |
| 40 | # grows, it may mean there is a memory leak in the library. |
| 41 | # |
| 42 | set LeakList {} |
| 43 | |
| 44 | |
drh | df16aed | 2000-06-02 14:27:22 +0000 | [diff] [blame] | 45 | for {set Counter 0} {$Counter<$COUNT} {incr Counter} { |
drh | 5edc312 | 2001-09-13 21:53:09 +0000 | [diff] [blame^] | 46 | foreach testfile [lsort -dictionary [glob $testdir/*.test]] { |
| 47 | if {[file tail $testfile]=="all.test"} continue |
| 48 | if {[file tail $testfile]=="malloc.test"} continue |
| 49 | source $testfile |
drh | df16aed | 2000-06-02 14:27:22 +0000 | [diff] [blame] | 50 | } |
drh | 8c82b35 | 2000-12-10 18:23:50 +0000 | [diff] [blame] | 51 | if {[info exists Leak]} { |
| 52 | lappend LeakList $Leak |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | # Do one last test to look for a memory leak in the library. This will |
| 57 | # only work if SQLite is compiled with the -DMEMORY_DEBUG=1 flag. |
| 58 | # |
| 59 | if {$LeakList!=""} { |
| 60 | puts -nonewline memory-leak-test... |
| 61 | incr ::nTest |
| 62 | foreach x $LeakList { |
| 63 | if {$x!=[lindex $LeakList 0]} { |
| 64 | puts " failed!" |
| 65 | puts "Expected: all values to be the same" |
| 66 | puts " Got: $LeakList" |
| 67 | incr ::nErr |
| 68 | break |
| 69 | } |
| 70 | } |
| 71 | puts " Ok" |
drh | bec2bf4 | 2000-05-29 23:48:22 +0000 | [diff] [blame] | 72 | } |
| 73 | |
drh | daffd0e | 2001-04-11 14:28:42 +0000 | [diff] [blame] | 74 | if {[file readable $testdir/malloc.test]} { |
drh | 5edc312 | 2001-09-13 21:53:09 +0000 | [diff] [blame^] | 75 | source $testdir/malloc.test |
drh | daffd0e | 2001-04-11 14:28:42 +0000 | [diff] [blame] | 76 | } |
| 77 | |
drh | bec2bf4 | 2000-05-29 23:48:22 +0000 | [diff] [blame] | 78 | really_finish_test |