blob: ceb50193879ad96c5903e775c25e9c639b0e53ec [file] [log] [blame]
danielk19779dfa60b2006-01-26 13:11:36 +00001
shane49097602008-07-31 02:43:34 +00002set rcsid {$Id: omittest.tcl,v 1.5 2008/07/31 02:43:35 shane 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
shane49097602008-07-31 02:43:34 +000065 file copy -force ./config.h $dir
66 file copy -force ./libtool $dir
danielk19779dfa60b2006-01-26 13:11:36 +000067 set rc [catch {
68 exec make -C $dir -f $::MAKEFILE testfixture OPTS=$opts >& $dir/build.log
69 }]
70 if {$rc} {
71 puts "No good. See $dir/build.log."
72 return
73 } else {
74 puts "Ok"
75 }
76
77 # Create an empty file "$dir/sqlite3". This is to trick the makefile out
78 # of trying to build the sqlite shell. The sqlite shell won't build
79 # with some of the OMIT options (i.e OMIT_COMPLETE).
shane49097602008-07-31 02:43:34 +000080 set sqlite3_dummy $dir/sqlite3
81 if {$::tcl_platform(platform)=="windows"} {
82 append sqlite3_dummy ".exe"
83 }
84 if {![file exists $sqlite3_dummy]} {
85 set wr [open $sqlite3_dummy w]
danielk19779dfa60b2006-01-26 13:11:36 +000086 puts $wr "dummy"
87 close $wr
88 }
89
90 # Run the test suite.
91 puts -nonewline "Testing $dir..."
92 flush stdout
93 set rc [catch {
94 exec make -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
95 }]
96 if {$rc} {
97 puts "No good. See $dir/test.log."
98 } else {
99 puts "Ok"
100 }
101}
102
103
104# This proc processes the command line options passed to this script.
105# Currently the only option supported is "-makefile", default
106# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
107# option.
108#
109proc process_options {argv} {
shane49097602008-07-31 02:43:34 +0000110 if {$::tcl_platform(platform)=="windows"} {
111 set ::MAKEFILE ../Makefile ;# Default value
112 } else {
113 set ::MAKEFILE ../Makefile.linux-gcc ;# Default value
114 }
danielk19779dfa60b2006-01-26 13:11:36 +0000115 for {set i 0} {$i < [llength $argv]} {incr i} {
116 switch -- [lindex $argv $i] {
117 -makefile {
118 incr i
119 set ::MAKEFILE [lindex $argv $i]
120 }
121
122 default {
123 puts stderr [string trim $::USAGE_MESSAGE]
124 exit -1
125 }
126 }
127 set ::MAKEFILE [file normalize $::MAKEFILE]
128 }
129}
130
131# Main routine.
132#
danielk19774b2688a2006-06-20 11:01:07 +0000133
danielk19779dfa60b2006-01-26 13:11:36 +0000134proc main {argv} {
135 # List of SQLITE_OMIT_XXX symbols supported by SQLite.
136 set ::SYMBOLS [list \
danielk19779dfa60b2006-01-26 13:11:36 +0000137 SQLITE_OMIT_ALTERTABLE \
shane49097602008-07-31 02:43:34 +0000138 SQLITE_OMIT_ANALYZE \
139 SQLITE_OMIT_ATTACH \
danielk1977a15db352007-09-14 16:20:00 +0000140 SQLITE_OMIT_AUTHORIZATION \
141 SQLITE_OMIT_AUTOINCREMENT \
shane49097602008-07-31 02:43:34 +0000142 SQLITE_OMIT_AUTOINIT \
danielk1977a15db352007-09-14 16:20:00 +0000143 SQLITE_OMIT_AUTOVACUUM \
shane49097602008-07-31 02:43:34 +0000144 SQLITE_OMIT_BETWEEN_OPTIMIZATION \
danielk1977a15db352007-09-14 16:20:00 +0000145 SQLITE_OMIT_BLOB_LITERAL \
shane49097602008-07-31 02:43:34 +0000146 SQLITE_OMIT_BUILTIN_TEST \
147 SQLITE_OMIT_CAST \
148 SQLITE_OMIT_CHECK \
danielk1977a15db352007-09-14 16:20:00 +0000149 SQLITE_OMIT_COMPLETE \
150 SQLITE_OMIT_COMPOUND_SELECT \
151 SQLITE_OMIT_CONFLICT_CLAUSE \
152 SQLITE_OMIT_DATETIME_FUNCS \
shane49097602008-07-31 02:43:34 +0000153 SQLITE_OMIT_DECLTYPE \
154 SQLITE_OMIT_DISKIO \
danielk19779dfa60b2006-01-26 13:11:36 +0000155 SQLITE_OMIT_EXPLAIN \
shane49097602008-07-31 02:43:34 +0000156 SQLITE_OMIT_FLAG_PRAGMAS \
danielk19779dfa60b2006-01-26 13:11:36 +0000157 SQLITE_OMIT_FLOATING_POINT \
158 SQLITE_OMIT_FOREIGN_KEY \
shane49097602008-07-31 02:43:34 +0000159 SQLITE_OMIT_GET_TABLE \
160 SQLITE_OMIT_GLOBALRECOVER \
danielk1977a15db352007-09-14 16:20:00 +0000161 SQLITE_OMIT_INCRBLOB \
danielk19779dfa60b2006-01-26 13:11:36 +0000162 SQLITE_OMIT_INTEGRITY_CHECK \
shane49097602008-07-31 02:43:34 +0000163 SQLITE_OMIT_LIKE_OPTIMIZATION \
164 SQLITE_OMIT_LOAD_EXTENSION \
165 SQLITE_OMIT_LOCALTIME \
danielk19779dfa60b2006-01-26 13:11:36 +0000166 SQLITE_OMIT_MEMORYDB \
shane49097602008-07-31 02:43:34 +0000167 SQLITE_OMIT_OR_OPTIMIZATION \
danielk19779dfa60b2006-01-26 13:11:36 +0000168 SQLITE_OMIT_PAGER_PRAGMAS \
shane49097602008-07-31 02:43:34 +0000169 SQLITE_OMIT_PARSER \
danielk19779dfa60b2006-01-26 13:11:36 +0000170 SQLITE_OMIT_PRAGMA \
171 SQLITE_OMIT_PROGRESS_CALLBACK \
shane49097602008-07-31 02:43:34 +0000172 SQLITE_OMIT_QUICKBALANCE \
danielk19779dfa60b2006-01-26 13:11:36 +0000173 SQLITE_OMIT_REINDEX \
174 SQLITE_OMIT_SCHEMA_PRAGMAS \
175 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
shane49097602008-07-31 02:43:34 +0000176 SQLITE_OMIT_SHARED_CACHE \
danielk19779dfa60b2006-01-26 13:11:36 +0000177 SQLITE_OMIT_SUBQUERY \
178 SQLITE_OMIT_TCL_VARIABLE \
shane49097602008-07-31 02:43:34 +0000179 SQLITE_OMIT_TEMPDB \
180 SQLITE_OMIT_TRACE \
danielk19779dfa60b2006-01-26 13:11:36 +0000181 SQLITE_OMIT_TRIGGER \
182 SQLITE_OMIT_UTF16 \
183 SQLITE_OMIT_VACUUM \
danielk1977a15db352007-09-14 16:20:00 +0000184 SQLITE_OMIT_VIEW \
185 SQLITE_OMIT_VIRTUALTABLE \
shane49097602008-07-31 02:43:34 +0000186 SQLITE_OMIT_XFER_OPT \
danielk19779dfa60b2006-01-26 13:11:36 +0000187 ]
188
189 # Process any command line options.
190 process_options $argv
191
192 # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
193 # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
194 # and the latter is currently incompatible with the test suite (this should
195 # be fixed, but it will be a lot of work).
196 set allsyms [list]
197 foreach s $::SYMBOLS {
198 if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
199 lappend allsyms $s
200 }
201 }
202 run_quick_test test_OMIT_EVERYTHING $allsyms
shane49097602008-07-31 02:43:34 +0000203
danielk19779dfa60b2006-01-26 13:11:36 +0000204 # Now try one quick.test with each of the OMIT symbols defined. Included
205 # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
206 # know they will fail. It's good to be reminded of this from time to time.
207 foreach sym $::SYMBOLS {
208 set dirname "test_[string range $sym 7 end]"
209 run_quick_test $dirname $sym
210 }
211}
212
213main $argv