xref: /titanic_41/usr/src/lib/libsqlite/test/all.test (revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968)
1
2#pragma ident	"%Z%%M%	%I%	%E% SMI"
3
4# 2001 September 15
5#
6# The author disclaims copyright to this source code.  In place of
7# a legal notice, here is a blessing:
8#
9#    May you do good and not evil.
10#    May you find forgiveness for yourself and forgive others.
11#    May you share freely, never taking more than you give.
12#
13#***********************************************************************
14# This file runs all tests.
15#
16# $Id: all.test,v 1.19 2003/02/16 22:21:33 drh Exp $
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20rename finish_test really_finish_test
21proc finish_test {} {memleak_check}
22
23if {[file exists ./sqlite_test_count]} {
24  set COUNT [exec cat ./sqlite_test_count]
25} else {
26  set COUNT 4
27}
28
29if {[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      default {
39         puts stderr "Unknown option: $name"
40         exit
41      }
42    }
43  }
44}
45set argv {}
46
47# LeakList will hold a list of the number of unfreed mallocs after
48# each round of the test.  This number should be constant.  If it
49# grows, it may mean there is a memory leak in the library.
50#
51set LeakList {}
52
53set EXCLUDE {
54  all.test
55  quick.test
56  malloc.test
57  misuse.test
58  memleak.test
59}
60#  btree2.test
61
62for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
63  set btree_native_byte_order [expr {($Counter>>1)&0x1}]
64  if {$Counter%2} {
65    set ::SETUP_SQL {PRAGMA default_synchronous=off;}
66  } else {
67    catch {unset ::SETUP_SQL}
68  }
69  foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
70    set tail [file tail $testfile]
71    if {[lsearch -exact $EXCLUDE $tail]>=0} continue
72    source $testfile
73    catch {db close}
74    if {$sqlite_open_file_count>0} {
75      puts "$tail did not close all files: $sqlite_open_file_count"
76      incr nErr
77      lappend ::failList $tail
78    }
79  }
80  if {[info exists Leak]} {
81    lappend LeakList $Leak
82  }
83}
84
85# Do one last test to look for a memory leak in the library.  This will
86# only work if SQLite is compiled with the -DMEMORY_DEBUG=1 flag.
87#
88if {$LeakList!=""} {
89  puts -nonewline memory-leak-test...
90  incr ::nTest
91  foreach x $LeakList {
92    if {$x!=[lindex $LeakList 0]} {
93       puts " failed!"
94       puts "Expected: all values to be the same"
95       puts "     Got: $LeakList"
96       incr ::nErr
97       lappend ::failList memory-leak-test
98       break
99    }
100  }
101  puts " Ok"
102}
103
104# Run the malloc tests and the misuse test after memory leak detection.
105# Both tests leak memory.
106#
107catch {source $testdir/misuse.test}
108catch {source $testdir/malloc.test}
109
110catch {db close}
111set sqlite_open_file_count 0
112really_finish_test
113