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