blob: c42519dd8c19f83687355f754673bb9fb7deb78a [file] [log] [blame]
danielk19779dfa60b2006-01-26 13:11:36 +00001# Documentation for this script. This may be output to stderr
2# if the script is invoked incorrectly.
3set ::USAGE_MESSAGE {
4This Tcl script is used to test the various compile time options
5available for omitting code (the SQLITE_OMIT_xxx options). It
6should be invoked as follows:
7
danbb2b4412011-04-06 17:54:31 +00008 <script> ?test-symbol? ?-makefile PATH-TO-MAKEFILE? ?-skip_run?
danielk19779dfa60b2006-01-26 13:11:36 +00009
10The default value for ::MAKEFILE is "../Makefile.linux.gcc".
11
shanehbb201342011-02-09 19:55:20 +000012If -skip_run option is given then only the compile part is attempted.
13
danielk19779dfa60b2006-01-26 13:11:36 +000014This script builds the testfixture program and runs the SQLite test suite
15once with each SQLITE_OMIT_ option defined and then once with all options
16defined together. Each run is performed in a seperate directory created
17as a sub-directory of the current directory by the script. The output
18of the build is saved in <sub-directory>/build.log. The output of the
19test-suite is saved in <sub-directory>/test.log.
20
21Almost any SQLite makefile (except those generated by configure - see below)
22should work. The following properties are required:
23
24 * The makefile should support the "testfixture" target.
25 * The makefile should support the "test" target.
26 * The makefile should support the variable "OPTS" as a way to pass
27 options from the make command line to lemon and the C compiler.
28
29More precisely, the following two invocations must be supported:
30
shaneh5e0855c2011-06-22 20:14:09 +000031 $::MAKEBIN -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
32 $::MAKEBIN -f $::MAKEFILE test
danielk19779dfa60b2006-01-26 13:11:36 +000033
34Makefiles generated by the sqlite configure program cannot be used as
35they do not respect the OPTS variable.
36}
37
38
39# Build a testfixture executable and run quick.test using it. The first
40# parameter is the name of the directory to create and use to run the
41# test in. The second parameter is a list of OMIT symbols to define
42# when doing so. For example:
43#
44# run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
45#
46#
47proc run_quick_test {dir omit_symbol_list} {
48 # Compile the value of the OPTS Makefile variable.
drh60bdeb22011-10-20 00:55:54 +000049 set opts ""
shane49097602008-07-31 02:43:34 +000050 if {$::tcl_platform(platform)=="windows"} {
drh60bdeb22011-10-20 00:55:54 +000051 append opts "OPTS += -DSQLITE_OS_WIN=1\n"
shanehbb201342011-02-09 19:55:20 +000052 set target "testfixture.exe"
shane49097602008-07-31 02:43:34 +000053 } else {
drh60bdeb22011-10-20 00:55:54 +000054 append opts "OPTS += -DSQLITE_OS_UNIX=1\n"
shane49097602008-07-31 02:43:34 +000055 }
danielk19779dfa60b2006-01-26 13:11:36 +000056 foreach sym $omit_symbol_list {
drh60bdeb22011-10-20 00:55:54 +000057 append opts "OPTS += -D${sym}=1\n"
danielk19779dfa60b2006-01-26 13:11:36 +000058 }
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
drh60bdeb22011-10-20 00:55:54 +000065 catch {
66 file copy -force ./config.h $dir
67 file copy -force ./libtool $dir
68 }
69 set fd [open $::MAKEFILE]
70 set mkfile [read $fd]
71 close $fd
72 regsub {\ninclude} $mkfile "\n$opts\ninclude" mkfile
73 set fd [open $dir/makefile w]
74 puts $fd $mkfile
75 close $fd
76
danielk19779dfa60b2006-01-26 13:11:36 +000077 set rc [catch {
drh60bdeb22011-10-20 00:55:54 +000078 exec $::MAKEBIN -C $dir -f makefile clean $::TARGET >& $dir/build.log
danielk19779dfa60b2006-01-26 13:11:36 +000079 }]
80 if {$rc} {
81 puts "No good. See $dir/build.log."
82 return
83 } else {
84 puts "Ok"
85 }
86
87 # Create an empty file "$dir/sqlite3". This is to trick the makefile out
88 # of trying to build the sqlite shell. The sqlite shell won't build
89 # with some of the OMIT options (i.e OMIT_COMPLETE).
shane49097602008-07-31 02:43:34 +000090 set sqlite3_dummy $dir/sqlite3
mistachkinf1c6bc52012-06-21 15:09:20 +000091 if {$::tcl_platform(platform)=="windows"} {
shane49097602008-07-31 02:43:34 +000092 append sqlite3_dummy ".exe"
93 }
94 if {![file exists $sqlite3_dummy]} {
95 set wr [open $sqlite3_dummy w]
danielk19779dfa60b2006-01-26 13:11:36 +000096 puts $wr "dummy"
97 close $wr
98 }
99
shanehbb201342011-02-09 19:55:20 +0000100 if {$::SKIP_RUN} {
101 puts "Skip testing $dir."
danielk19779dfa60b2006-01-26 13:11:36 +0000102 } else {
shanehbb201342011-02-09 19:55:20 +0000103 # Run the test suite.
104 puts -nonewline "Testing $dir..."
105 flush stdout
106 set rc [catch {
drh60bdeb22011-10-20 00:55:54 +0000107 exec $::MAKEBIN -C $dir -f makefile test >& $dir/test.log
shanehbb201342011-02-09 19:55:20 +0000108 }]
109 if {$rc} {
110 puts "No good. See $dir/test.log."
111 } else {
112 puts "Ok"
113 }
danielk19779dfa60b2006-01-26 13:11:36 +0000114 }
115}
116
117
118# This proc processes the command line options passed to this script.
119# Currently the only option supported is "-makefile", default
120# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
121# option.
122#
123proc process_options {argv} {
shaneh5e0855c2011-06-22 20:14:09 +0000124 set ::MAKEBIN make ;# Default value
mistachkinf1c6bc52012-06-21 15:09:20 +0000125 if {$::tcl_platform(platform)=="windows"} {
126 set ::MAKEFILE ./Makefile ;# Default value on Windows
shane49097602008-07-31 02:43:34 +0000127 } else {
danbb2b4412011-04-06 17:54:31 +0000128 set ::MAKEFILE ./Makefile.linux-gcc ;# Default value
shane49097602008-07-31 02:43:34 +0000129 }
danbb2b4412011-04-06 17:54:31 +0000130 set ::SKIP_RUN 0 ;# Default to attempt test
drh60bdeb22011-10-20 00:55:54 +0000131 set ::TARGET testfixture ;# Default thing to build
shanehbb201342011-02-09 19:55:20 +0000132
danielk19779dfa60b2006-01-26 13:11:36 +0000133 for {set i 0} {$i < [llength $argv]} {incr i} {
drh96a27f42017-05-15 15:05:48 +0000134 switch -regexp -- [lindex $argv $i] {
135 -{1,2}makefile {
danielk19779dfa60b2006-01-26 13:11:36 +0000136 incr i
137 set ::MAKEFILE [lindex $argv $i]
138 }
139
drh96a27f42017-05-15 15:05:48 +0000140 -{1,2}nmake {
shaneh5e0855c2011-06-22 20:14:09 +0000141 set ::MAKEBIN nmake
142 set ::MAKEFILE ./Makefile.msc
143 }
144
drh96a27f42017-05-15 15:05:48 +0000145 -{1,2}target {
drh60bdeb22011-10-20 00:55:54 +0000146 incr i
147 set ::TARGET [lindex $argv $i]
148 }
149
drh96a27f42017-05-15 15:05:48 +0000150 -{1,2}skip_run {
shanehbb201342011-02-09 19:55:20 +0000151 set ::SKIP_RUN 1
152 }
153
drh96a27f42017-05-15 15:05:48 +0000154 -{1,2}help {
155 puts $::USAGE_MESSAGE
156 exit
157 }
158
159 -.* {
160 puts stderr "Unknown option: [lindex $argv i]"
161 puts stderr $::USAGE_MESSAGE
162 exit 1
163 }
164
danielk19779dfa60b2006-01-26 13:11:36 +0000165 default {
danbb2b4412011-04-06 17:54:31 +0000166 if {[info exists ::SYMBOL]} {
167 puts stderr [string trim $::USAGE_MESSAGE]
168 exit -1
169 }
170 set ::SYMBOL [lindex $argv $i]
danielk19779dfa60b2006-01-26 13:11:36 +0000171 }
172 }
173 set ::MAKEFILE [file normalize $::MAKEFILE]
174 }
175}
176
177# Main routine.
178#
danielk19774b2688a2006-06-20 11:01:07 +0000179
danielk19779dfa60b2006-01-26 13:11:36 +0000180proc main {argv} {
181 # List of SQLITE_OMIT_XXX symbols supported by SQLite.
shanehbb201342011-02-09 19:55:20 +0000182 set ::OMIT_SYMBOLS [list \
183 SQLITE_OMIT_ALTERTABLE \
184 SQLITE_OMIT_ANALYZE \
185 SQLITE_OMIT_ATTACH \
186 SQLITE_OMIT_AUTHORIZATION \
187 SQLITE_OMIT_AUTOINCREMENT \
188 SQLITE_OMIT_AUTOINIT \
189 SQLITE_OMIT_AUTOMATIC_INDEX \
190 SQLITE_OMIT_AUTORESET \
191 SQLITE_OMIT_AUTOVACUUM \
192 SQLITE_OMIT_BETWEEN_OPTIMIZATION \
193 SQLITE_OMIT_BLOB_LITERAL \
194 SQLITE_OMIT_BTREECOUNT \
195 SQLITE_OMIT_BUILTIN_TEST \
196 SQLITE_OMIT_CAST \
197 SQLITE_OMIT_CHECK \
198 SQLITE_OMIT_COMPILEOPTION_DIAGS \
199 SQLITE_OMIT_COMPLETE \
200 SQLITE_OMIT_COMPOUND_SELECT \
danb68b9772014-01-25 12:16:53 +0000201 SQLITE_OMIT_CTE \
shanehbb201342011-02-09 19:55:20 +0000202 SQLITE_OMIT_DATETIME_FUNCS \
203 SQLITE_OMIT_DECLTYPE \
204 SQLITE_OMIT_DEPRECATED \
shanehbb201342011-02-09 19:55:20 +0000205 SQLITE_OMIT_EXPLAIN \
206 SQLITE_OMIT_FLAG_PRAGMAS \
207 SQLITE_OMIT_FLOATING_POINT \
208 SQLITE_OMIT_FOREIGN_KEY \
209 SQLITE_OMIT_GET_TABLE \
210 SQLITE_OMIT_INCRBLOB \
211 SQLITE_OMIT_INTEGRITY_CHECK \
212 SQLITE_OMIT_LIKE_OPTIMIZATION \
213 SQLITE_OMIT_LOAD_EXTENSION \
214 SQLITE_OMIT_LOCALTIME \
215 SQLITE_OMIT_LOOKASIDE \
216 SQLITE_OMIT_MEMORYDB \
217 SQLITE_OMIT_OR_OPTIMIZATION \
218 SQLITE_OMIT_PAGER_PRAGMAS \
219 SQLITE_OMIT_PRAGMA \
220 SQLITE_OMIT_PROGRESS_CALLBACK \
221 SQLITE_OMIT_QUICKBALANCE \
222 SQLITE_OMIT_REINDEX \
223 SQLITE_OMIT_SCHEMA_PRAGMAS \
danielk19779dfa60b2006-01-26 13:11:36 +0000224 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
shanehbb201342011-02-09 19:55:20 +0000225 SQLITE_OMIT_SHARED_CACHE \
226 SQLITE_OMIT_SUBQUERY \
227 SQLITE_OMIT_TCL_VARIABLE \
228 SQLITE_OMIT_TEMPDB \
229 SQLITE_OMIT_TRACE \
230 SQLITE_OMIT_TRIGGER \
231 SQLITE_OMIT_TRUNCATE_OPTIMIZATION \
shaneh11c58f72011-03-12 04:58:55 +0000232 SQLITE_OMIT_UNIQUE_ENFORCEMENT \
shanehbb201342011-02-09 19:55:20 +0000233 SQLITE_OMIT_UTF16 \
234 SQLITE_OMIT_VACUUM \
235 SQLITE_OMIT_VIEW \
236 SQLITE_OMIT_VIRTUALTABLE \
237 SQLITE_OMIT_WAL \
238 SQLITE_OMIT_WSD \
239 SQLITE_OMIT_XFER_OPT \
240 ]
241
242 set ::ENABLE_SYMBOLS [list \
243 SQLITE_DISABLE_DIRSYNC \
244 SQLITE_DISABLE_LFS \
245 SQLITE_ENABLE_ATOMIC_WRITE \
shanehbb201342011-02-09 19:55:20 +0000246 SQLITE_ENABLE_COLUMN_METADATA \
247 SQLITE_ENABLE_EXPENSIVE_ASSERT \
shanehbb201342011-02-09 19:55:20 +0000248 SQLITE_ENABLE_FTS3 \
249 SQLITE_ENABLE_FTS3_PARENTHESIS \
250 SQLITE_ENABLE_FTS4 \
shanehbb201342011-02-09 19:55:20 +0000251 SQLITE_ENABLE_IOTRACE \
252 SQLITE_ENABLE_LOAD_EXTENSION \
253 SQLITE_ENABLE_LOCKING_STYLE \
254 SQLITE_ENABLE_MEMORY_MANAGEMENT \
255 SQLITE_ENABLE_MEMSYS3 \
256 SQLITE_ENABLE_MEMSYS5 \
257 SQLITE_ENABLE_OVERSIZE_CELL_CHECK \
258 SQLITE_ENABLE_RTREE \
drh60bdeb22011-10-20 00:55:54 +0000259 SQLITE_ENABLE_STAT3 \
shanehbb201342011-02-09 19:55:20 +0000260 SQLITE_ENABLE_UNLOCK_NOTIFY \
261 SQLITE_ENABLE_UPDATE_DELETE_LIMIT \
danielk19779dfa60b2006-01-26 13:11:36 +0000262 ]
263
264 # Process any command line options.
265 process_options $argv
shanehbb201342011-02-09 19:55:20 +0000266
danbb2b4412011-04-06 17:54:31 +0000267 if {[info exists ::SYMBOL] } {
268 set sym $::SYMBOL
269
270 if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} {
271 puts stderr "No such symbol: $sym"
272 exit -1
danielk19779dfa60b2006-01-26 13:11:36 +0000273 }
shane49097602008-07-31 02:43:34 +0000274
shaneh5e0855c2011-06-22 20:14:09 +0000275 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
shanehbb201342011-02-09 19:55:20 +0000276 run_quick_test $dirname $sym
danbb2b4412011-04-06 17:54:31 +0000277 } else {
278 # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
279 # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
280 # and the latter is currently incompatible with the test suite (this should
281 # be fixed, but it will be a lot of work).
282 set allsyms [list]
283 foreach s $::OMIT_SYMBOLS {
284 if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
285 lappend allsyms $s
286 }
287 }
288 run_quick_test test_OMIT_EVERYTHING $allsyms
289
290 # Now try one quick.test with each of the OMIT symbols defined. Included
291 # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
292 # know they will fail. It's good to be reminded of this from time to time.
293 foreach sym $::OMIT_SYMBOLS {
shaneh5e0855c2011-06-22 20:14:09 +0000294 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
danbb2b4412011-04-06 17:54:31 +0000295 run_quick_test $dirname $sym
296 }
297
298 # Try the ENABLE/DISABLE symbols one at a time.
299 # We don't do them all at once since some are conflicting.
300 foreach sym $::ENABLE_SYMBOLS {
shaneh5e0855c2011-06-22 20:14:09 +0000301 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
danbb2b4412011-04-06 17:54:31 +0000302 run_quick_test $dirname $sym
303 }
danielk19779dfa60b2006-01-26 13:11:36 +0000304 }
305}
306
307main $argv