1# 2001 September 15 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 6# May you do good and not evil. 7# May you find forgiveness for yourself and forgive others. 8# May you share freely, never taking more than you give. 9# 10#*********************************************************************** 11# This file runs all tests. 12# 13# $Id: all.test,v 1.58 2008/09/09 18:28:07 danielk1977 Exp $ 14 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17rename finish_test really_finish_test 18proc finish_test {} { 19 # no-op 20} 21 22if {[file exists ./sqlite_test_count]} { 23 set COUNT [exec cat ./sqlite_test_count] 24} else { 25 set COUNT 3 26} 27 28if {[llength $argv]>0} { 29 foreach {name value} $argv { 30 switch -- $name { 31 -count { 32 set COUNT $value 33 } 34 -quick { 35 set ISQUICK $value 36 } 37 -soak { 38 set SOAKTEST $value 39 } 40 default { 41 puts stderr "Unknown option: $name" 42 exit 43 } 44 } 45 } 46} 47set argv {} 48 49# LeakList will hold a list of the number of unfreed mallocs after 50# each round of the test. This number should be constant. If it 51# grows, it may mean there is a memory leak in the library. 52# 53set LeakList {} 54 55set EXCLUDE {} 56lappend EXCLUDE all.test ;# This file 57lappend EXCLUDE async.test 58lappend EXCLUDE crash.test ;# Run seperately later. 59lappend EXCLUDE crash2.test ;# Run seperately later. 60lappend EXCLUDE quick.test ;# Alternate test driver script 61lappend EXCLUDE veryquick.test ;# Alternate test driver script 62lappend EXCLUDE malloc.test ;# Run seperately later. 63lappend EXCLUDE misuse.test ;# Run seperately later. 64lappend EXCLUDE memleak.test ;# Alternate test driver script 65lappend EXCLUDE permutations.test ;# Run seperately later. 66lappend EXCLUDE fuzz.test 67lappend EXCLUDE fuzz3.test 68lappend EXCLUDE soak.test ;# Takes a very long time (default 1 hr) 69lappend EXCLUDE fts3.test ;# Wrapper for muliple fts3*.tests 70lappend EXCLUDE mallocAll.test ;# Wrapper for running all malloc tests 71 72# Files to include in the test. If this list is empty then everything 73# that is not in the EXCLUDE list is run. 74# 75set INCLUDE { 76} 77 78for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} { 79 if {$Counter%2} { 80 set ::SETUP_SQL {PRAGMA default_synchronous=off;} 81 } else { 82 catch {unset ::SETUP_SQL} 83 } 84 foreach testfile [lsort -dictionary [glob $testdir/*.test]] { 85 set tail [file tail $testfile] 86 if {[lsearch -exact $EXCLUDE $tail]>=0} continue 87 if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue 88 reset_prng_state 89 source $testfile 90 catch {db close} 91 if {$sqlite_open_file_count>0} { 92 puts "$tail did not close all files: $sqlite_open_file_count" 93 incr nErr 94 lappend ::failList $tail 95 set sqlite_open_file_count 0 96 } 97 } 98 if {[info exists Leak]} { 99 lappend LeakList $Leak 100 } 101} 102set argv all 103source $testdir/permutations.test 104set argv "" 105 106# Do one last test to look for a memory leak in the library. This will 107# only work if SQLite is compiled with the -DSQLITE_DEBUG=1 flag. 108# 109if {$LeakList!=""} { 110 puts -nonewline memory-leak-test... 111 incr ::nTest 112 foreach x $LeakList { 113 if {$x!=[lindex $LeakList 0]} { 114 puts " failed!" 115 puts "Expected: all values to be the same" 116 puts " Got: $LeakList" 117 incr ::nErr 118 lappend ::failList memory-leak-test 119 break 120 } 121 } 122 puts " Ok" 123} 124 125# Run the crashtest only on unix and only once. If the library does not 126# always create auto-vacuum databases, also run autovacuum_crash.test. 127# 128if {$::tcl_platform(platform)=="unix"} { 129 source $testdir/crash.test 130 source $testdir/crash2.test 131 ifcapable !default_autovacuum { 132 set argv autovacuum_crash 133 source $testdir/permutations.test 134 set argv "" 135 } 136} 137 138# Run the malloc tests and the misuse test after memory leak detection. 139# Both tests leak memory. Currently, misuse.test also leaks a handful of 140# file descriptors. This is not considered a problem, but can cause tests 141# in malloc.test to fail. So set the open-file count to zero before running 142# malloc.test to get around this. 143# 144catch {source $testdir/misuse.test} 145set sqlite_open_file_count 0 146catch {source $testdir/malloc.test} 147 148catch {db close} 149set sqlite_open_file_count 0 150really_finish_test 151