blob: 13a70cd2475e4cfff4dddeac1d602d1400d9b6a6 [file] [log] [blame]
danielk19779dfa60b2006-01-26 13:11:36 +00001
danielk1977de3e41e2008-08-04 03:51:24 +00002set rcsid {$Id: omittest.tcl,v 1.6 2008/08/04 03:51:24 danielk1977 Exp $}
danielk19779dfa60b2006-01-26 13:11:36 +00003
4# Documentation for this script. This may be output to stderr
5# if the script is invoked incorrectly.
6set ::USAGE_MESSAGE {
7This Tcl script is used to test the various compile time options
8available for omitting code (the SQLITE_OMIT_xxx options). It
9should be invoked as follows:
10
11 <script> ?-makefile PATH-TO-MAKEFILE?
12
13The default value for ::MAKEFILE is "../Makefile.linux.gcc".
14
15This script builds the testfixture program and runs the SQLite test suite
16once with each SQLITE_OMIT_ option defined and then once with all options
17defined together. Each run is performed in a seperate directory created
18as a sub-directory of the current directory by the script. The output
19of the build is saved in <sub-directory>/build.log. The output of the
20test-suite is saved in <sub-directory>/test.log.
21
22Almost any SQLite makefile (except those generated by configure - see below)
23should work. The following properties are required:
24
25 * The makefile should support the "testfixture" target.
26 * The makefile should support the "test" target.
27 * The makefile should support the variable "OPTS" as a way to pass
28 options from the make command line to lemon and the C compiler.
29
30More precisely, the following two invocations must be supported:
31
32 make -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
33 make -f $::MAKEFILE test
34
35Makefiles generated by the sqlite configure program cannot be used as
36they do not respect the OPTS variable.
37}
38
39
40# Build a testfixture executable and run quick.test using it. The first
41# parameter is the name of the directory to create and use to run the
42# test in. The second parameter is a list of OMIT symbols to define
43# when doing so. For example:
44#
45# run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
46#
47#
48proc run_quick_test {dir omit_symbol_list} {
49 # Compile the value of the OPTS Makefile variable.
shane49097602008-07-31 02:43:34 +000050 set opts "-DSQLITE_MEMDEBUG -DSQLITE_DEBUG"
51 if {$::tcl_platform(platform)=="windows"} {
52 append opts " -DSQLITE_OS_WIN=1"
53 } else {
54 append opts " -DSQLITE_OS_UNIX=1"
55 }
danielk19779dfa60b2006-01-26 13:11:36 +000056 foreach sym $omit_symbol_list {
57 append opts " -D${sym}=1"
58 }
59
60 # Create the directory and do the build. If an error occurs return
61 # early without attempting to run the test suite.
62 file mkdir $dir
63 puts -nonewline "Building $dir..."
64 flush stdout
danielk1977de3e41e2008-08-04 03:51:24 +000065catch {
shane49097602008-07-31 02:43:34 +000066 file copy -force ./config.h $dir
67 file copy -force ./libtool $dir
danielk1977de3e41e2008-08-04 03:51:24 +000068}
danielk19779dfa60b2006-01-26 13:11:36 +000069 set rc [catch {
70 exec make -C $dir -f $::MAKEFILE testfixture OPTS=$opts >& $dir/build.log
71 }]
72 if {$rc} {
73 puts "No good. See $dir/build.log."
74 return
75 } else {
76 puts "Ok"
77 }
78
79 # Create an empty file "$dir/sqlite3". This is to trick the makefile out
80 # of trying to build the sqlite shell. The sqlite shell won't build
81 # with some of the OMIT options (i.e OMIT_COMPLETE).
shane49097602008-07-31 02:43:34 +000082 set sqlite3_dummy $dir/sqlite3
83 if {$::tcl_platform(platform)=="windows"} {
84 append sqlite3_dummy ".exe"
85 }
86 if {![file exists $sqlite3_dummy]} {
87 set wr [open $sqlite3_dummy w]
danielk19779dfa60b2006-01-26 13:11:36 +000088 puts $wr "dummy"
89 close $wr
90 }
91
92 # Run the test suite.
93 puts -nonewline "Testing $dir..."
94 flush stdout
95 set rc [catch {
96 exec make -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
97 }]
98 if {$rc} {
99 puts "No good. See $dir/test.log."
100 } else {
101 puts "Ok"
102 }
103}
104
105
106# This proc processes the command line options passed to this script.
107# Currently the only option supported is "-makefile", default
108# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
109# option.
110#
111proc process_options {argv} {
shane49097602008-07-31 02:43:34 +0000112 if {$::tcl_platform(platform)=="windows"} {
113 set ::MAKEFILE ../Makefile ;# Default value
114 } else {
115 set ::MAKEFILE ../Makefile.linux-gcc ;# Default value
116 }
danielk19779dfa60b2006-01-26 13:11:36 +0000117 for {set i 0} {$i < [llength $argv]} {incr i} {
118 switch -- [lindex $argv $i] {
119 -makefile {
120 incr i
121 set ::MAKEFILE [lindex $argv $i]
122 }
123
124 default {
125 puts stderr [string trim $::USAGE_MESSAGE]
126 exit -1
127 }
128 }
129 set ::MAKEFILE [file normalize $::MAKEFILE]
130 }
131}
132
133# Main routine.
134#
danielk19774b2688a2006-06-20 11:01:07 +0000135
danielk19779dfa60b2006-01-26 13:11:36 +0000136proc main {argv} {
137 # List of SQLITE_OMIT_XXX symbols supported by SQLite.
138 set ::SYMBOLS [list \
danielk19779dfa60b2006-01-26 13:11:36 +0000139 SQLITE_OMIT_ALTERTABLE \
shane49097602008-07-31 02:43:34 +0000140 SQLITE_OMIT_ANALYZE \
141 SQLITE_OMIT_ATTACH \
danielk1977a15db352007-09-14 16:20:00 +0000142 SQLITE_OMIT_AUTHORIZATION \
143 SQLITE_OMIT_AUTOINCREMENT \
shane49097602008-07-31 02:43:34 +0000144 SQLITE_OMIT_AUTOINIT \
danielk1977a15db352007-09-14 16:20:00 +0000145 SQLITE_OMIT_AUTOVACUUM \
shane49097602008-07-31 02:43:34 +0000146 SQLITE_OMIT_BETWEEN_OPTIMIZATION \
danielk1977a15db352007-09-14 16:20:00 +0000147 SQLITE_OMIT_BLOB_LITERAL \
shane49097602008-07-31 02:43:34 +0000148 SQLITE_OMIT_BUILTIN_TEST \
149 SQLITE_OMIT_CAST \
150 SQLITE_OMIT_CHECK \
danielk1977a15db352007-09-14 16:20:00 +0000151 SQLITE_OMIT_COMPLETE \
152 SQLITE_OMIT_COMPOUND_SELECT \
153 SQLITE_OMIT_CONFLICT_CLAUSE \
154 SQLITE_OMIT_DATETIME_FUNCS \
shane49097602008-07-31 02:43:34 +0000155 SQLITE_OMIT_DECLTYPE \
156 SQLITE_OMIT_DISKIO \
danielk19779dfa60b2006-01-26 13:11:36 +0000157 SQLITE_OMIT_EXPLAIN \
shane49097602008-07-31 02:43:34 +0000158 SQLITE_OMIT_FLAG_PRAGMAS \
danielk19779dfa60b2006-01-26 13:11:36 +0000159 SQLITE_OMIT_FLOATING_POINT \
160 SQLITE_OMIT_FOREIGN_KEY \
shane49097602008-07-31 02:43:34 +0000161 SQLITE_OMIT_GET_TABLE \
162 SQLITE_OMIT_GLOBALRECOVER \
danielk1977a15db352007-09-14 16:20:00 +0000163 SQLITE_OMIT_INCRBLOB \
danielk19779dfa60b2006-01-26 13:11:36 +0000164 SQLITE_OMIT_INTEGRITY_CHECK \
shane49097602008-07-31 02:43:34 +0000165 SQLITE_OMIT_LIKE_OPTIMIZATION \
166 SQLITE_OMIT_LOAD_EXTENSION \
167 SQLITE_OMIT_LOCALTIME \
danielk19779dfa60b2006-01-26 13:11:36 +0000168 SQLITE_OMIT_MEMORYDB \
shane49097602008-07-31 02:43:34 +0000169 SQLITE_OMIT_OR_OPTIMIZATION \
danielk19779dfa60b2006-01-26 13:11:36 +0000170 SQLITE_OMIT_PAGER_PRAGMAS \
shane49097602008-07-31 02:43:34 +0000171 SQLITE_OMIT_PARSER \
danielk19779dfa60b2006-01-26 13:11:36 +0000172 SQLITE_OMIT_PRAGMA \
173 SQLITE_OMIT_PROGRESS_CALLBACK \
shane49097602008-07-31 02:43:34 +0000174 SQLITE_OMIT_QUICKBALANCE \
danielk19779dfa60b2006-01-26 13:11:36 +0000175 SQLITE_OMIT_REINDEX \
176 SQLITE_OMIT_SCHEMA_PRAGMAS \
177 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
shane49097602008-07-31 02:43:34 +0000178 SQLITE_OMIT_SHARED_CACHE \
danielk19779dfa60b2006-01-26 13:11:36 +0000179 SQLITE_OMIT_SUBQUERY \
180 SQLITE_OMIT_TCL_VARIABLE \
shane49097602008-07-31 02:43:34 +0000181 SQLITE_OMIT_TEMPDB \
182 SQLITE_OMIT_TRACE \
danielk19779dfa60b2006-01-26 13:11:36 +0000183 SQLITE_OMIT_TRIGGER \
184 SQLITE_OMIT_UTF16 \
185 SQLITE_OMIT_VACUUM \
danielk1977a15db352007-09-14 16:20:00 +0000186 SQLITE_OMIT_VIEW \
187 SQLITE_OMIT_VIRTUALTABLE \
shane49097602008-07-31 02:43:34 +0000188 SQLITE_OMIT_XFER_OPT \
danielk19779dfa60b2006-01-26 13:11:36 +0000189 ]
190
191 # Process any command line options.
192 process_options $argv
193
194 # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
195 # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
196 # and the latter is currently incompatible with the test suite (this should
197 # be fixed, but it will be a lot of work).
198 set allsyms [list]
199 foreach s $::SYMBOLS {
200 if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
201 lappend allsyms $s
202 }
203 }
204 run_quick_test test_OMIT_EVERYTHING $allsyms
shane49097602008-07-31 02:43:34 +0000205
danielk19779dfa60b2006-01-26 13:11:36 +0000206 # Now try one quick.test with each of the OMIT symbols defined. Included
207 # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
208 # know they will fail. It's good to be reminded of this from time to time.
209 foreach sym $::SYMBOLS {
210 set dirname "test_[string range $sym 7 end]"
211 run_quick_test $dirname $sym
212 }
213}
214
215main $argv