/ Artifact [21d55a97]

Artifact 21d55a97e39e7ec5776751dc9dd8b1b51ef4a048:

# Copyright (c) 1999, 2000 D. Richard Hipp
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# General Public License for more details.
# You should have received a copy of the GNU General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA  02111-1307, USA.
# Author contact information:
#   drh@hwaci.com
#   http://www.hwaci.com/drh/
# This file runs all tests.
# $Id: all.test,v 1.7 2001/04/12 23:21:59 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test
proc finish_test {} {memleak_check}

if {[file exists ./sqlite_test_count]} {
  set COUNT [exec cat ./sqlite_test_count]
} else {
  set COUNT 3

if {[file exists ./sqlite_test_prefixes]} {
  set PREFIXES [exec cat ./sqlite_test_prefixes]
} else {
  set PREFIXES {memory: gdbm:}

# LeakList will hold a list of the number of unfreed mallocs after
# each round of the test.  This number should be constant.  If it
# grows, it may mean there is a memory leak in the library.
set LeakList {}

for {set Counter 0} {$Counter<$COUNT} {incr Counter} {
  foreach p $PREFIXES {
    set dbprefix $p
    foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
      if {[file tail $testfile]=="all.test"} continue
      if {[file tail $testfile]=="malloc.test"} continue
      source $testfile
  if {[info exists Leak]} {
    lappend LeakList $Leak

# Do one last test to look for a memory leak in the library.  This will
# only work if SQLite is compiled with the -DMEMORY_DEBUG=1 flag.
if {$LeakList!=""} {
  puts -nonewline memory-leak-test...
  incr ::nTest
  foreach x $LeakList {
    if {$x!=[lindex $LeakList 0]} {
       puts " failed!"
       puts "Expected: all values to be the same"
       puts "     Got: $LeakList"
       incr ::nErr
  puts " Ok"

if {[file readable $testdir/malloc.test]} {
  foreach p $PREFIXES {
    set dbprefix $p
    source $testdir/malloc.test