2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2001 September 15
2N/A#
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A#
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#
2N/A#***********************************************************************
2N/A# This file runs all tests.
2N/A#
2N/A# $Id: all.test,v 1.19 2003/02/16 22:21:33 drh Exp $
2N/A
2N/Aset testdir [file dirname $argv0]
2N/Asource $testdir/tester.tcl
2N/Arename finish_test really_finish_test
2N/Aproc finish_test {} {memleak_check}
2N/A
2N/Aif {[file exists ./sqlite_test_count]} {
2N/A set COUNT [exec cat ./sqlite_test_count]
2N/A} else {
2N/A set COUNT 4
2N/A}
2N/A
2N/Aif {[llength $argv]>0} {
2N/A foreach {name value} $argv {
2N/A switch -- $name {
2N/A -count {
2N/A set COUNT $value
2N/A }
2N/A -quick {
2N/A set ISQUICK $value
2N/A }
2N/A default {
2N/A puts stderr "Unknown option: $name"
2N/A exit
2N/A }
2N/A }
2N/A }
2N/A}
2N/Aset argv {}
2N/A
2N/A# LeakList will hold a list of the number of unfreed mallocs after
2N/A# each round of the test. This number should be constant. If it
2N/A# grows, it may mean there is a memory leak in the library.
2N/A#
2N/Aset LeakList {}
2N/A
2N/Aset EXCLUDE {
2N/A all.test
2N/A quick.test
2N/A malloc.test
2N/A misuse.test
2N/A memleak.test
2N/A}
2N/A# btree2.test
2N/A
2N/Afor {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
2N/A set btree_native_byte_order [expr {($Counter>>1)&0x1}]
2N/A if {$Counter%2} {
2N/A set ::SETUP_SQL {PRAGMA default_synchronous=off;}
2N/A } else {
2N/A catch {unset ::SETUP_SQL}
2N/A }
2N/A foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
2N/A set tail [file tail $testfile]
2N/A if {[lsearch -exact $EXCLUDE $tail]>=0} continue
2N/A source $testfile
2N/A catch {db close}
2N/A if {$sqlite_open_file_count>0} {
2N/A puts "$tail did not close all files: $sqlite_open_file_count"
2N/A incr nErr
2N/A lappend ::failList $tail
2N/A }
2N/A }
2N/A if {[info exists Leak]} {
2N/A lappend LeakList $Leak
2N/A }
2N/A}
2N/A
2N/A# Do one last test to look for a memory leak in the library. This will
2N/A# only work if SQLite is compiled with the -DMEMORY_DEBUG=1 flag.
2N/A#
2N/Aif {$LeakList!=""} {
2N/A puts -nonewline memory-leak-test...
2N/A incr ::nTest
2N/A foreach x $LeakList {
2N/A if {$x!=[lindex $LeakList 0]} {
2N/A puts " failed!"
2N/A puts "Expected: all values to be the same"
2N/A puts " Got: $LeakList"
2N/A incr ::nErr
2N/A lappend ::failList memory-leak-test
2N/A break
2N/A }
2N/A }
2N/A puts " Ok"
2N/A}
2N/A
2N/A# Run the malloc tests and the misuse test after memory leak detection.
2N/A# Both tests leak memory.
2N/A#
2N/Acatch {source $testdir/misuse.test}
2N/Acatch {source $testdir/malloc.test}
2N/A
2N/Acatch {db close}
2N/Aset sqlite_open_file_count 0
2N/Areally_finish_test