blob: b54f2984d414b9e1f06176da29254323de9121dc [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} {
drhef9f7192020-01-17 19:14:08 +0000101 # 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 }
drhef9f7192020-01-17 19:14:08 +0000130 set ::SKIP_RUN 1 ;# 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 }
drhef9f7192020-01-17 19:14:08 +0000153 -{1,2}run {
154 set ::SKIP_RUN 0
155 }
shanehbb201342011-02-09 19:55:20 +0000156
drh96a27f42017-05-15 15:05:48 +0000157 -{1,2}help {
158 puts $::USAGE_MESSAGE
159 exit
160 }
161
162 -.* {
163 puts stderr "Unknown option: [lindex $argv i]"
164 puts stderr $::USAGE_MESSAGE
165 exit 1
166 }
167
danielk19779dfa60b2006-01-26 13:11:36 +0000168 default {
danbb2b4412011-04-06 17:54:31 +0000169 if {[info exists ::SYMBOL]} {
170 puts stderr [string trim $::USAGE_MESSAGE]
171 exit -1
172 }
173 set ::SYMBOL [lindex $argv $i]
danielk19779dfa60b2006-01-26 13:11:36 +0000174 }
175 }
176 set ::MAKEFILE [file normalize $::MAKEFILE]
177 }
178}
179
180# Main routine.
181#
danielk19774b2688a2006-06-20 11:01:07 +0000182
danielk19779dfa60b2006-01-26 13:11:36 +0000183proc main {argv} {
184 # List of SQLITE_OMIT_XXX symbols supported by SQLite.
shanehbb201342011-02-09 19:55:20 +0000185 set ::OMIT_SYMBOLS [list \
186 SQLITE_OMIT_ALTERTABLE \
187 SQLITE_OMIT_ANALYZE \
188 SQLITE_OMIT_ATTACH \
189 SQLITE_OMIT_AUTHORIZATION \
190 SQLITE_OMIT_AUTOINCREMENT \
191 SQLITE_OMIT_AUTOINIT \
192 SQLITE_OMIT_AUTOMATIC_INDEX \
193 SQLITE_OMIT_AUTORESET \
194 SQLITE_OMIT_AUTOVACUUM \
195 SQLITE_OMIT_BETWEEN_OPTIMIZATION \
196 SQLITE_OMIT_BLOB_LITERAL \
197 SQLITE_OMIT_BTREECOUNT \
drhef9f7192020-01-17 19:14:08 +0000198 SQLITE_OMIT_CASE_SENSITIVE_LIKE_PRAGMA \
shanehbb201342011-02-09 19:55:20 +0000199 SQLITE_OMIT_CAST \
200 SQLITE_OMIT_CHECK \
201 SQLITE_OMIT_COMPILEOPTION_DIAGS \
202 SQLITE_OMIT_COMPLETE \
203 SQLITE_OMIT_COMPOUND_SELECT \
drh6adba902019-04-10 18:29:40 +0000204 SQLITE_OMIT_CONFLICT_CLAUSE \
danb68b9772014-01-25 12:16:53 +0000205 SQLITE_OMIT_CTE \
shanehbb201342011-02-09 19:55:20 +0000206 SQLITE_OMIT_DATETIME_FUNCS \
207 SQLITE_OMIT_DECLTYPE \
208 SQLITE_OMIT_DEPRECATED \
drh8d889af2021-05-08 17:18:23 +0000209 SQLITE_OMIT_DESERIALIZE \
drh6adba902019-04-10 18:29:40 +0000210 SQLITE_OMIT_DISKIO \
shanehbb201342011-02-09 19:55:20 +0000211 SQLITE_OMIT_EXPLAIN \
212 SQLITE_OMIT_FLAG_PRAGMAS \
213 SQLITE_OMIT_FLOATING_POINT \
214 SQLITE_OMIT_FOREIGN_KEY \
drhef9f7192020-01-17 19:14:08 +0000215 SQLITE_OMIT_GENERATED_COLUMNS \
shanehbb201342011-02-09 19:55:20 +0000216 SQLITE_OMIT_GET_TABLE \
drh6adba902019-04-10 18:29:40 +0000217 SQLITE_OMIT_HEX_INTEGER \
shanehbb201342011-02-09 19:55:20 +0000218 SQLITE_OMIT_INCRBLOB \
219 SQLITE_OMIT_INTEGRITY_CHECK \
drhef9f7192020-01-17 19:14:08 +0000220 SQLITE_OMIT_INTROSPECTION_PRAGMAS \
drh91260dc2022-02-21 13:02:23 +0000221 SQLITE_OMIT_JSON \
shanehbb201342011-02-09 19:55:20 +0000222 SQLITE_OMIT_LIKE_OPTIMIZATION \
223 SQLITE_OMIT_LOAD_EXTENSION \
224 SQLITE_OMIT_LOCALTIME \
225 SQLITE_OMIT_LOOKASIDE \
226 SQLITE_OMIT_MEMORYDB \
227 SQLITE_OMIT_OR_OPTIMIZATION \
228 SQLITE_OMIT_PAGER_PRAGMAS \
drh6adba902019-04-10 18:29:40 +0000229 SQLITE_OMIT_PARSER_TRACE \
230 SQLITE_OMIT_POPEN \
shanehbb201342011-02-09 19:55:20 +0000231 SQLITE_OMIT_PRAGMA \
232 SQLITE_OMIT_PROGRESS_CALLBACK \
233 SQLITE_OMIT_QUICKBALANCE \
drh6adba902019-04-10 18:29:40 +0000234 SQLITE_OMIT_RANDOMNESS \
shanehbb201342011-02-09 19:55:20 +0000235 SQLITE_OMIT_REINDEX \
236 SQLITE_OMIT_SCHEMA_PRAGMAS \
danielk19779dfa60b2006-01-26 13:11:36 +0000237 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
shanehbb201342011-02-09 19:55:20 +0000238 SQLITE_OMIT_SHARED_CACHE \
drh6adba902019-04-10 18:29:40 +0000239 SQLITE_OMIT_SHUTDOWN_DIRECTORIES \
shanehbb201342011-02-09 19:55:20 +0000240 SQLITE_OMIT_SUBQUERY \
241 SQLITE_OMIT_TCL_VARIABLE \
242 SQLITE_OMIT_TEMPDB \
drh6adba902019-04-10 18:29:40 +0000243 SQLITE_OMIT_TEST_CONTROL \
shanehbb201342011-02-09 19:55:20 +0000244 SQLITE_OMIT_TRACE \
245 SQLITE_OMIT_TRIGGER \
246 SQLITE_OMIT_TRUNCATE_OPTIMIZATION \
drh6adba902019-04-10 18:29:40 +0000247 SQLITE_OMIT_UPSERT \
shanehbb201342011-02-09 19:55:20 +0000248 SQLITE_OMIT_UTF16 \
249 SQLITE_OMIT_VACUUM \
250 SQLITE_OMIT_VIEW \
251 SQLITE_OMIT_VIRTUALTABLE \
252 SQLITE_OMIT_WAL \
drh6adba902019-04-10 18:29:40 +0000253 SQLITE_OMIT_WINDOWFUNC \
shanehbb201342011-02-09 19:55:20 +0000254 SQLITE_OMIT_WSD \
255 SQLITE_OMIT_XFER_OPT \
256 ]
257
258 set ::ENABLE_SYMBOLS [list \
drha875b722021-04-07 18:08:23 +0000259 SQLITE_ALLOW_ROWID_IN_VIEW \
shanehbb201342011-02-09 19:55:20 +0000260 SQLITE_DISABLE_DIRSYNC \
261 SQLITE_DISABLE_LFS \
262 SQLITE_ENABLE_ATOMIC_WRITE \
shanehbb201342011-02-09 19:55:20 +0000263 SQLITE_ENABLE_COLUMN_METADATA \
264 SQLITE_ENABLE_EXPENSIVE_ASSERT \
shanehbb201342011-02-09 19:55:20 +0000265 SQLITE_ENABLE_FTS3 \
266 SQLITE_ENABLE_FTS3_PARENTHESIS \
267 SQLITE_ENABLE_FTS4 \
shanehbb201342011-02-09 19:55:20 +0000268 SQLITE_ENABLE_IOTRACE \
269 SQLITE_ENABLE_LOAD_EXTENSION \
270 SQLITE_ENABLE_LOCKING_STYLE \
271 SQLITE_ENABLE_MEMORY_MANAGEMENT \
272 SQLITE_ENABLE_MEMSYS3 \
273 SQLITE_ENABLE_MEMSYS5 \
274 SQLITE_ENABLE_OVERSIZE_CELL_CHECK \
275 SQLITE_ENABLE_RTREE \
drh60bdeb22011-10-20 00:55:54 +0000276 SQLITE_ENABLE_STAT3 \
shanehbb201342011-02-09 19:55:20 +0000277 SQLITE_ENABLE_UNLOCK_NOTIFY \
278 SQLITE_ENABLE_UPDATE_DELETE_LIMIT \
danielk19779dfa60b2006-01-26 13:11:36 +0000279 ]
280
281 # Process any command line options.
282 process_options $argv
shanehbb201342011-02-09 19:55:20 +0000283
danbb2b4412011-04-06 17:54:31 +0000284 if {[info exists ::SYMBOL] } {
285 set sym $::SYMBOL
286
287 if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} {
288 puts stderr "No such symbol: $sym"
289 exit -1
danielk19779dfa60b2006-01-26 13:11:36 +0000290 }
shane49097602008-07-31 02:43:34 +0000291
shaneh5e0855c2011-06-22 20:14:09 +0000292 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
shanehbb201342011-02-09 19:55:20 +0000293 run_quick_test $dirname $sym
danbb2b4412011-04-06 17:54:31 +0000294 } else {
295 # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
296 # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
297 # and the latter is currently incompatible with the test suite (this should
298 # be fixed, but it will be a lot of work).
299 set allsyms [list]
300 foreach s $::OMIT_SYMBOLS {
301 if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
302 lappend allsyms $s
303 }
304 }
305 run_quick_test test_OMIT_EVERYTHING $allsyms
306
307 # Now try one quick.test with each of the OMIT symbols defined. Included
308 # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
309 # know they will fail. It's good to be reminded of this from time to time.
310 foreach sym $::OMIT_SYMBOLS {
shaneh5e0855c2011-06-22 20:14:09 +0000311 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
danbb2b4412011-04-06 17:54:31 +0000312 run_quick_test $dirname $sym
313 }
314
315 # Try the ENABLE/DISABLE symbols one at a time.
316 # We don't do them all at once since some are conflicting.
317 foreach sym $::ENABLE_SYMBOLS {
shaneh5e0855c2011-06-22 20:14:09 +0000318 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
danbb2b4412011-04-06 17:54:31 +0000319 run_quick_test $dirname $sym
320 }
danielk19779dfa60b2006-01-26 13:11:36 +0000321 }
322}
323
324main $argv