blob: a1fb54caf946fabff510a8df4524f4a8f9a05d24 [file] [log] [blame]
drhbec2bf42000-05-29 23:48:22 +00001# 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#
drh5edc3122001-09-13 21:53:09 +000025# $Id: all.test,v 1.8 2001/09/13 21:53:10 drh Exp $
drhbec2bf42000-05-29 23:48:22 +000026
27set testdir [file dirname $argv0]
28source $testdir/tester.tcl
29rename finish_test really_finish_test
drh8c82b352000-12-10 18:23:50 +000030proc finish_test {} {memleak_check}
drhbec2bf42000-05-29 23:48:22 +000031
drhdf16aed2000-06-02 14:27:22 +000032if {[file exists ./sqlite_test_count]} {
33 set COUNT [exec cat ./sqlite_test_count]
34} else {
drhd4007282001-04-12 23:21:58 +000035 set COUNT 3
drhdf16aed2000-06-02 14:27:22 +000036}
37
drh8c82b352000-12-10 18:23:50 +000038# 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#
42set LeakList {}
43
44
drhdf16aed2000-06-02 14:27:22 +000045for {set Counter 0} {$Counter<$COUNT} {incr Counter} {
drh5edc3122001-09-13 21:53:09 +000046 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
drhdf16aed2000-06-02 14:27:22 +000050 }
drh8c82b352000-12-10 18:23:50 +000051 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#
59if {$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"
drhbec2bf42000-05-29 23:48:22 +000072}
73
drhdaffd0e2001-04-11 14:28:42 +000074if {[file readable $testdir/malloc.test]} {
drh5edc3122001-09-13 21:53:09 +000075 source $testdir/malloc.test
drhdaffd0e2001-04-11 14:28:42 +000076}
77
drhbec2bf42000-05-29 23:48:22 +000078really_finish_test