2001-09-16 04:13:26 +04:00
|
|
|
# 2001 September 15
|
2000-05-30 03:48:22 +04:00
|
|
|
#
|
2001-09-16 04:13:26 +04:00
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
2000-05-30 03:48:22 +04:00
|
|
|
#
|
2001-09-16 04:13:26 +04:00
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
2000-05-30 03:48:22 +04:00
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file runs all tests.
|
|
|
|
#
|
2005-01-17 10:53:44 +03:00
|
|
|
# $Id: all.test,v 1.30 2005/01/17 07:53:44 danielk1977 Exp $
|
2000-05-30 03:48:22 +04:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
rename finish_test really_finish_test
|
2000-12-10 21:23:50 +03:00
|
|
|
proc finish_test {} {memleak_check}
|
2000-05-30 03:48:22 +04:00
|
|
|
|
2000-06-02 18:27:22 +04:00
|
|
|
if {[file exists ./sqlite_test_count]} {
|
|
|
|
set COUNT [exec cat ./sqlite_test_count]
|
|
|
|
} else {
|
2004-06-26 23:35:29 +04:00
|
|
|
set COUNT 3
|
2000-06-02 18:27:22 +04:00
|
|
|
}
|
|
|
|
|
2002-12-04 16:40:25 +03:00
|
|
|
if {[llength $argv]>0} {
|
|
|
|
foreach {name value} $argv {
|
|
|
|
switch -- $name {
|
|
|
|
-count {
|
|
|
|
set COUNT $value
|
|
|
|
}
|
|
|
|
-quick {
|
|
|
|
set ISQUICK $value
|
|
|
|
}
|
|
|
|
default {
|
|
|
|
puts stderr "Unknown option: $name"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set argv {}
|
|
|
|
|
2000-12-10 21:23:50 +03:00
|
|
|
# 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 {}
|
|
|
|
|
2001-09-16 04:13:26 +04:00
|
|
|
set EXCLUDE {
|
|
|
|
all.test
|
2004-06-26 23:35:29 +04:00
|
|
|
crash.test
|
2005-01-08 05:35:44 +03:00
|
|
|
autovacuum_crash.test
|
2001-09-16 04:13:26 +04:00
|
|
|
quick.test
|
|
|
|
malloc.test
|
2002-05-10 17:14:07 +04:00
|
|
|
misuse.test
|
2002-08-24 22:24:51 +04:00
|
|
|
memleak.test
|
2001-09-16 04:13:26 +04:00
|
|
|
}
|
2005-01-08 05:35:44 +03:00
|
|
|
|
|
|
|
# Test files btree2.test and btree4.test don't work if the
|
|
|
|
# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
|
|
|
|
# on tables being allocated starting at page 2).
|
|
|
|
#
|
|
|
|
ifcapable default_autovacuum {
|
|
|
|
lappend EXCLUDE btree2.test
|
|
|
|
lappend EXCLUDE btree4.test
|
|
|
|
}
|
2000-12-10 21:23:50 +03:00
|
|
|
|
2001-09-14 20:42:12 +04:00
|
|
|
for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
|
2002-03-07 01:01:34 +03:00
|
|
|
if {$Counter%2} {
|
|
|
|
set ::SETUP_SQL {PRAGMA default_synchronous=off;}
|
|
|
|
} else {
|
|
|
|
catch {unset ::SETUP_SQL}
|
|
|
|
}
|
2001-09-14 01:53:09 +04:00
|
|
|
foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
|
2001-09-16 04:13:26 +04:00
|
|
|
set tail [file tail $testfile]
|
|
|
|
if {[lsearch -exact $EXCLUDE $tail]>=0} continue
|
2001-09-14 01:53:09 +04:00
|
|
|
source $testfile
|
2003-02-17 01:21:32 +03:00
|
|
|
catch {db close}
|
|
|
|
if {$sqlite_open_file_count>0} {
|
|
|
|
puts "$tail did not close all files: $sqlite_open_file_count"
|
|
|
|
incr nErr
|
|
|
|
lappend ::failList $tail
|
|
|
|
}
|
2000-06-02 18:27:22 +04:00
|
|
|
}
|
2000-12-10 21:23:50 +03:00
|
|
|
if {[info exists Leak]} {
|
|
|
|
lappend LeakList $Leak
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Do one last test to look for a memory leak in the library. This will
|
2005-01-03 04:32:59 +03:00
|
|
|
# only work if SQLite is compiled with the -DSQLITE_DEBUG=1 flag.
|
2000-12-10 21:23:50 +03:00
|
|
|
#
|
|
|
|
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
|
2001-09-14 20:42:12 +04:00
|
|
|
lappend ::failList memory-leak-test
|
2000-12-10 21:23:50 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
puts " Ok"
|
2000-05-30 03:48:22 +04:00
|
|
|
}
|
|
|
|
|
2005-01-08 05:35:44 +03:00
|
|
|
# Run the crashtest only on unix and only once. If the library does not
|
|
|
|
# always create auto-vacuum databases, also run autovacuum_crash.test.
|
2004-06-26 23:35:29 +04:00
|
|
|
#
|
2005-01-13 14:07:52 +03:00
|
|
|
if {$::tcl_platform(platform)=="unix"} {
|
2004-06-26 23:35:29 +04:00
|
|
|
source $testdir/crash.test
|
2005-01-08 05:35:44 +03:00
|
|
|
ifcapable !default_autovacuum {
|
|
|
|
source $testdir/autovacuum_crash.test
|
|
|
|
}
|
2004-06-26 23:35:29 +04:00
|
|
|
}
|
|
|
|
|
2002-05-10 17:14:07 +04:00
|
|
|
# Run the malloc tests and the misuse test after memory leak detection.
|
2004-06-30 12:20:16 +04:00
|
|
|
# Both tests leak memory. Currently, misuse.test also leaks a handful of
|
|
|
|
# file descriptors. This is not considered a problem, but can cause tests
|
|
|
|
# in malloc.test to fail. So set the open-file count to zero before running
|
|
|
|
# malloc.test to get around this.
|
2001-10-22 06:58:08 +04:00
|
|
|
#
|
2002-05-10 17:14:07 +04:00
|
|
|
catch {source $testdir/misuse.test}
|
2004-06-30 12:20:16 +04:00
|
|
|
set sqlite_open_file_count 0
|
2001-10-22 06:58:08 +04:00
|
|
|
catch {source $testdir/malloc.test}
|
2001-04-11 18:28:42 +04:00
|
|
|
|
2003-02-17 01:21:32 +03:00
|
|
|
catch {db close}
|
|
|
|
set sqlite_open_file_count 0
|
2000-05-30 03:48:22 +04:00
|
|
|
really_finish_test
|