blob: 5437f2eb01e5ad493fbb8b66d7b417337236fcc6 [file] [log] [blame]
danielk19779dfa60b2006-01-26 13:11:36 +00001
drh21717ed2008-10-13 15:35:08 +00002set rcsid {$Id: omittest.tcl,v 1.8 2008/10/13 15:35:09 drh 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
danbb2b4412011-04-06 17:54:31 +000011 <script> ?test-symbol? ?-makefile PATH-TO-MAKEFILE? ?-skip_run?
danielk19779dfa60b2006-01-26 13:11:36 +000012
13The default value for ::MAKEFILE is "../Makefile.linux.gcc".
14
shanehbb201342011-02-09 19:55:20 +000015If -skip_run option is given then only the compile part is attempted.
16
danielk19779dfa60b2006-01-26 13:11:36 +000017This script builds the testfixture program and runs the SQLite test suite
18once with each SQLITE_OMIT_ option defined and then once with all options
19defined together. Each run is performed in a seperate directory created
20as a sub-directory of the current directory by the script. The output
21of the build is saved in <sub-directory>/build.log. The output of the
22test-suite is saved in <sub-directory>/test.log.
23
24Almost any SQLite makefile (except those generated by configure - see below)
25should work. The following properties are required:
26
27 * The makefile should support the "testfixture" target.
28 * The makefile should support the "test" target.
29 * The makefile should support the variable "OPTS" as a way to pass
30 options from the make command line to lemon and the C compiler.
31
32More precisely, the following two invocations must be supported:
33
shaneh5e0855c2011-06-22 20:14:09 +000034 $::MAKEBIN -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
35 $::MAKEBIN -f $::MAKEFILE test
danielk19779dfa60b2006-01-26 13:11:36 +000036
37Makefiles generated by the sqlite configure program cannot be used as
38they do not respect the OPTS variable.
39}
40
41
42# Build a testfixture executable and run quick.test using it. The first
43# parameter is the name of the directory to create and use to run the
44# test in. The second parameter is a list of OMIT symbols to define
45# when doing so. For example:
46#
47# run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
48#
49#
50proc run_quick_test {dir omit_symbol_list} {
51 # Compile the value of the OPTS Makefile variable.
drh60bdeb22011-10-20 00:55:54 +000052 set opts ""
shane49097602008-07-31 02:43:34 +000053 if {$::tcl_platform(platform)=="windows"} {
drh60bdeb22011-10-20 00:55:54 +000054 append opts "OPTS += -DSQLITE_OS_WIN=1\n"
shanehbb201342011-02-09 19:55:20 +000055 set target "testfixture.exe"
shane49097602008-07-31 02:43:34 +000056 } else {
drh60bdeb22011-10-20 00:55:54 +000057 append opts "OPTS += -DSQLITE_OS_UNIX=1\n"
shane49097602008-07-31 02:43:34 +000058 }
danielk19779dfa60b2006-01-26 13:11:36 +000059 foreach sym $omit_symbol_list {
drh60bdeb22011-10-20 00:55:54 +000060 append opts "OPTS += -D${sym}=1\n"
danielk19779dfa60b2006-01-26 13:11:36 +000061 }
62
63 # Create the directory and do the build. If an error occurs return
64 # early without attempting to run the test suite.
65 file mkdir $dir
66 puts -nonewline "Building $dir..."
67 flush stdout
drh60bdeb22011-10-20 00:55:54 +000068 catch {
69 file copy -force ./config.h $dir
70 file copy -force ./libtool $dir
71 }
72 set fd [open $::MAKEFILE]
73 set mkfile [read $fd]
74 close $fd
75 regsub {\ninclude} $mkfile "\n$opts\ninclude" mkfile
76 set fd [open $dir/makefile w]
77 puts $fd $mkfile
78 close $fd
79
danielk19779dfa60b2006-01-26 13:11:36 +000080 set rc [catch {
drh60bdeb22011-10-20 00:55:54 +000081 exec $::MAKEBIN -C $dir -f makefile clean $::TARGET >& $dir/build.log
danielk19779dfa60b2006-01-26 13:11:36 +000082 }]
83 if {$rc} {
84 puts "No good. See $dir/build.log."
85 return
86 } else {
87 puts "Ok"
88 }
89
90 # Create an empty file "$dir/sqlite3". This is to trick the makefile out
91 # of trying to build the sqlite shell. The sqlite shell won't build
92 # with some of the OMIT options (i.e OMIT_COMPLETE).
shane49097602008-07-31 02:43:34 +000093 set sqlite3_dummy $dir/sqlite3
mistachkinf1c6bc52012-06-21 15:09:20 +000094 if {$::tcl_platform(platform)=="windows"} {
shane49097602008-07-31 02:43:34 +000095 append sqlite3_dummy ".exe"
96 }
97 if {![file exists $sqlite3_dummy]} {
98 set wr [open $sqlite3_dummy w]
danielk19779dfa60b2006-01-26 13:11:36 +000099 puts $wr "dummy"
100 close $wr
101 }
102
shanehbb201342011-02-09 19:55:20 +0000103 if {$::SKIP_RUN} {
104 puts "Skip testing $dir."
danielk19779dfa60b2006-01-26 13:11:36 +0000105 } else {
shanehbb201342011-02-09 19:55:20 +0000106 # Run the test suite.
107 puts -nonewline "Testing $dir..."
108 flush stdout
109 set rc [catch {
drh60bdeb22011-10-20 00:55:54 +0000110 exec $::MAKEBIN -C $dir -f makefile test >& $dir/test.log
shanehbb201342011-02-09 19:55:20 +0000111 }]
112 if {$rc} {
113 puts "No good. See $dir/test.log."
114 } else {
115 puts "Ok"
116 }
danielk19779dfa60b2006-01-26 13:11:36 +0000117 }
118}
119
120
121# This proc processes the command line options passed to this script.
122# Currently the only option supported is "-makefile", default
123# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
124# option.
125#
126proc process_options {argv} {
shaneh5e0855c2011-06-22 20:14:09 +0000127 set ::MAKEBIN make ;# Default value
mistachkinf1c6bc52012-06-21 15:09:20 +0000128 if {$::tcl_platform(platform)=="windows"} {
129 set ::MAKEFILE ./Makefile ;# Default value on Windows
shane49097602008-07-31 02:43:34 +0000130 } else {
danbb2b4412011-04-06 17:54:31 +0000131 set ::MAKEFILE ./Makefile.linux-gcc ;# Default value
shane49097602008-07-31 02:43:34 +0000132 }
danbb2b4412011-04-06 17:54:31 +0000133 set ::SKIP_RUN 0 ;# Default to attempt test
drh60bdeb22011-10-20 00:55:54 +0000134 set ::TARGET testfixture ;# Default thing to build
shanehbb201342011-02-09 19:55:20 +0000135
danielk19779dfa60b2006-01-26 13:11:36 +0000136 for {set i 0} {$i < [llength $argv]} {incr i} {
137 switch -- [lindex $argv $i] {
138 -makefile {
139 incr i
140 set ::MAKEFILE [lindex $argv $i]
141 }
142
shaneh5e0855c2011-06-22 20:14:09 +0000143 -nmake {
144 set ::MAKEBIN nmake
145 set ::MAKEFILE ./Makefile.msc
146 }
147
drh60bdeb22011-10-20 00:55:54 +0000148 -target {
149 incr i
150 set ::TARGET [lindex $argv $i]
151 }
152
shanehbb201342011-02-09 19:55:20 +0000153 -skip_run {
shanehbb201342011-02-09 19:55:20 +0000154 set ::SKIP_RUN 1
155 }
156
danielk19779dfa60b2006-01-26 13:11:36 +0000157 default {
danbb2b4412011-04-06 17:54:31 +0000158 if {[info exists ::SYMBOL]} {
159 puts stderr [string trim $::USAGE_MESSAGE]
160 exit -1
161 }
162 set ::SYMBOL [lindex $argv $i]
danielk19779dfa60b2006-01-26 13:11:36 +0000163 }
164 }
165 set ::MAKEFILE [file normalize $::MAKEFILE]
166 }
167}
168
169# Main routine.
170#
danielk19774b2688a2006-06-20 11:01:07 +0000171
danielk19779dfa60b2006-01-26 13:11:36 +0000172proc main {argv} {
173 # List of SQLITE_OMIT_XXX symbols supported by SQLite.
shanehbb201342011-02-09 19:55:20 +0000174 set ::OMIT_SYMBOLS [list \
175 SQLITE_OMIT_ALTERTABLE \
176 SQLITE_OMIT_ANALYZE \
177 SQLITE_OMIT_ATTACH \
178 SQLITE_OMIT_AUTHORIZATION \
179 SQLITE_OMIT_AUTOINCREMENT \
180 SQLITE_OMIT_AUTOINIT \
181 SQLITE_OMIT_AUTOMATIC_INDEX \
182 SQLITE_OMIT_AUTORESET \
183 SQLITE_OMIT_AUTOVACUUM \
184 SQLITE_OMIT_BETWEEN_OPTIMIZATION \
185 SQLITE_OMIT_BLOB_LITERAL \
186 SQLITE_OMIT_BTREECOUNT \
187 SQLITE_OMIT_BUILTIN_TEST \
188 SQLITE_OMIT_CAST \
189 SQLITE_OMIT_CHECK \
190 SQLITE_OMIT_COMPILEOPTION_DIAGS \
191 SQLITE_OMIT_COMPLETE \
192 SQLITE_OMIT_COMPOUND_SELECT \
danb68b9772014-01-25 12:16:53 +0000193 SQLITE_OMIT_CTE \
shanehbb201342011-02-09 19:55:20 +0000194 SQLITE_OMIT_DATETIME_FUNCS \
195 SQLITE_OMIT_DECLTYPE \
196 SQLITE_OMIT_DEPRECATED \
shanehbb201342011-02-09 19:55:20 +0000197 SQLITE_OMIT_EXPLAIN \
198 SQLITE_OMIT_FLAG_PRAGMAS \
199 SQLITE_OMIT_FLOATING_POINT \
200 SQLITE_OMIT_FOREIGN_KEY \
201 SQLITE_OMIT_GET_TABLE \
202 SQLITE_OMIT_INCRBLOB \
203 SQLITE_OMIT_INTEGRITY_CHECK \
204 SQLITE_OMIT_LIKE_OPTIMIZATION \
205 SQLITE_OMIT_LOAD_EXTENSION \
206 SQLITE_OMIT_LOCALTIME \
207 SQLITE_OMIT_LOOKASIDE \
208 SQLITE_OMIT_MEMORYDB \
209 SQLITE_OMIT_OR_OPTIMIZATION \
210 SQLITE_OMIT_PAGER_PRAGMAS \
211 SQLITE_OMIT_PRAGMA \
212 SQLITE_OMIT_PROGRESS_CALLBACK \
213 SQLITE_OMIT_QUICKBALANCE \
214 SQLITE_OMIT_REINDEX \
215 SQLITE_OMIT_SCHEMA_PRAGMAS \
danielk19779dfa60b2006-01-26 13:11:36 +0000216 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
shanehbb201342011-02-09 19:55:20 +0000217 SQLITE_OMIT_SHARED_CACHE \
218 SQLITE_OMIT_SUBQUERY \
219 SQLITE_OMIT_TCL_VARIABLE \
220 SQLITE_OMIT_TEMPDB \
221 SQLITE_OMIT_TRACE \
222 SQLITE_OMIT_TRIGGER \
223 SQLITE_OMIT_TRUNCATE_OPTIMIZATION \
shaneh11c58f72011-03-12 04:58:55 +0000224 SQLITE_OMIT_UNIQUE_ENFORCEMENT \
shanehbb201342011-02-09 19:55:20 +0000225 SQLITE_OMIT_UTF16 \
226 SQLITE_OMIT_VACUUM \
227 SQLITE_OMIT_VIEW \
228 SQLITE_OMIT_VIRTUALTABLE \
229 SQLITE_OMIT_WAL \
230 SQLITE_OMIT_WSD \
231 SQLITE_OMIT_XFER_OPT \
232 ]
233
234 set ::ENABLE_SYMBOLS [list \
235 SQLITE_DISABLE_DIRSYNC \
236 SQLITE_DISABLE_LFS \
237 SQLITE_ENABLE_ATOMIC_WRITE \
shanehbb201342011-02-09 19:55:20 +0000238 SQLITE_ENABLE_COLUMN_METADATA \
239 SQLITE_ENABLE_EXPENSIVE_ASSERT \
shanehbb201342011-02-09 19:55:20 +0000240 SQLITE_ENABLE_FTS3 \
241 SQLITE_ENABLE_FTS3_PARENTHESIS \
242 SQLITE_ENABLE_FTS4 \
shanehbb201342011-02-09 19:55:20 +0000243 SQLITE_ENABLE_IOTRACE \
244 SQLITE_ENABLE_LOAD_EXTENSION \
245 SQLITE_ENABLE_LOCKING_STYLE \
246 SQLITE_ENABLE_MEMORY_MANAGEMENT \
247 SQLITE_ENABLE_MEMSYS3 \
248 SQLITE_ENABLE_MEMSYS5 \
249 SQLITE_ENABLE_OVERSIZE_CELL_CHECK \
250 SQLITE_ENABLE_RTREE \
drh60bdeb22011-10-20 00:55:54 +0000251 SQLITE_ENABLE_STAT3 \
shanehbb201342011-02-09 19:55:20 +0000252 SQLITE_ENABLE_UNLOCK_NOTIFY \
253 SQLITE_ENABLE_UPDATE_DELETE_LIMIT \
danielk19779dfa60b2006-01-26 13:11:36 +0000254 ]
255
256 # Process any command line options.
257 process_options $argv
shanehbb201342011-02-09 19:55:20 +0000258
danbb2b4412011-04-06 17:54:31 +0000259 if {[info exists ::SYMBOL] } {
260 set sym $::SYMBOL
261
262 if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} {
263 puts stderr "No such symbol: $sym"
264 exit -1
danielk19779dfa60b2006-01-26 13:11:36 +0000265 }
shane49097602008-07-31 02:43:34 +0000266
shaneh5e0855c2011-06-22 20:14:09 +0000267 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
shanehbb201342011-02-09 19:55:20 +0000268 run_quick_test $dirname $sym
danbb2b4412011-04-06 17:54:31 +0000269 } else {
270 # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
271 # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
272 # and the latter is currently incompatible with the test suite (this should
273 # be fixed, but it will be a lot of work).
274 set allsyms [list]
275 foreach s $::OMIT_SYMBOLS {
276 if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
277 lappend allsyms $s
278 }
279 }
280 run_quick_test test_OMIT_EVERYTHING $allsyms
281
282 # Now try one quick.test with each of the OMIT symbols defined. Included
283 # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
284 # know they will fail. It's good to be reminded of this from time to time.
285 foreach sym $::OMIT_SYMBOLS {
shaneh5e0855c2011-06-22 20:14:09 +0000286 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
danbb2b4412011-04-06 17:54:31 +0000287 run_quick_test $dirname $sym
288 }
289
290 # Try the ENABLE/DISABLE symbols one at a time.
291 # We don't do them all at once since some are conflicting.
292 foreach sym $::ENABLE_SYMBOLS {
shaneh5e0855c2011-06-22 20:14:09 +0000293 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
danbb2b4412011-04-06 17:54:31 +0000294 run_quick_test $dirname $sym
295 }
danielk19779dfa60b2006-01-26 13:11:36 +0000296 }
297}
298
299main $argv