blob: ec1508c23910e823b1f91dc6cc55c96a49d3692e [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
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.
drh21717ed2008-10-13 15:35:08 +000050 set opts "-DSQLITE_MEMDEBUG -DSQLITE_DEBUG -DSQLITE_NO_SYNC"
shane49097602008-07-31 02:43:34 +000051 if {$::tcl_platform(platform)=="windows"} {
52 append opts " -DSQLITE_OS_WIN=1"
pweilbachere7c8a5c2008-08-22 13:57:39 +000053 } elseif {$::tcl_platform(platform)=="os2"} {
54 append opts " -DSQLITE_OS_OS2=1"
shane49097602008-07-31 02:43:34 +000055 } else {
56 append opts " -DSQLITE_OS_UNIX=1"
57 }
danielk19779dfa60b2006-01-26 13:11:36 +000058 foreach sym $omit_symbol_list {
59 append opts " -D${sym}=1"
60 }
61
62 # Create the directory and do the build. If an error occurs return
63 # early without attempting to run the test suite.
64 file mkdir $dir
65 puts -nonewline "Building $dir..."
66 flush stdout
danielk1977de3e41e2008-08-04 03:51:24 +000067catch {
shane49097602008-07-31 02:43:34 +000068 file copy -force ./config.h $dir
69 file copy -force ./libtool $dir
danielk1977de3e41e2008-08-04 03:51:24 +000070}
danielk19779dfa60b2006-01-26 13:11:36 +000071 set rc [catch {
72 exec make -C $dir -f $::MAKEFILE testfixture OPTS=$opts >& $dir/build.log
73 }]
74 if {$rc} {
75 puts "No good. See $dir/build.log."
76 return
77 } else {
78 puts "Ok"
79 }
80
81 # Create an empty file "$dir/sqlite3". This is to trick the makefile out
82 # of trying to build the sqlite shell. The sqlite shell won't build
83 # with some of the OMIT options (i.e OMIT_COMPLETE).
shane49097602008-07-31 02:43:34 +000084 set sqlite3_dummy $dir/sqlite3
pweilbachere7c8a5c2008-08-22 13:57:39 +000085 if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} {
shane49097602008-07-31 02:43:34 +000086 append sqlite3_dummy ".exe"
87 }
88 if {![file exists $sqlite3_dummy]} {
89 set wr [open $sqlite3_dummy w]
danielk19779dfa60b2006-01-26 13:11:36 +000090 puts $wr "dummy"
91 close $wr
92 }
93
94 # Run the test suite.
95 puts -nonewline "Testing $dir..."
96 flush stdout
97 set rc [catch {
98 exec make -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
99 }]
100 if {$rc} {
101 puts "No good. See $dir/test.log."
102 } else {
103 puts "Ok"
104 }
105}
106
107
108# This proc processes the command line options passed to this script.
109# Currently the only option supported is "-makefile", default
110# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
111# option.
112#
113proc process_options {argv} {
pweilbachere7c8a5c2008-08-22 13:57:39 +0000114 if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} {
shane49097602008-07-31 02:43:34 +0000115 set ::MAKEFILE ../Makefile ;# Default value
116 } else {
117 set ::MAKEFILE ../Makefile.linux-gcc ;# Default value
118 }
danielk19779dfa60b2006-01-26 13:11:36 +0000119 for {set i 0} {$i < [llength $argv]} {incr i} {
120 switch -- [lindex $argv $i] {
121 -makefile {
122 incr i
123 set ::MAKEFILE [lindex $argv $i]
124 }
125
126 default {
127 puts stderr [string trim $::USAGE_MESSAGE]
128 exit -1
129 }
130 }
131 set ::MAKEFILE [file normalize $::MAKEFILE]
132 }
133}
134
135# Main routine.
136#
danielk19774b2688a2006-06-20 11:01:07 +0000137
danielk19779dfa60b2006-01-26 13:11:36 +0000138proc main {argv} {
139 # List of SQLITE_OMIT_XXX symbols supported by SQLite.
140 set ::SYMBOLS [list \
danielk19779dfa60b2006-01-26 13:11:36 +0000141 SQLITE_OMIT_ALTERTABLE \
shane49097602008-07-31 02:43:34 +0000142 SQLITE_OMIT_ANALYZE \
143 SQLITE_OMIT_ATTACH \
danielk1977a15db352007-09-14 16:20:00 +0000144 SQLITE_OMIT_AUTHORIZATION \
145 SQLITE_OMIT_AUTOINCREMENT \
shane49097602008-07-31 02:43:34 +0000146 SQLITE_OMIT_AUTOINIT \
danielk1977a15db352007-09-14 16:20:00 +0000147 SQLITE_OMIT_AUTOVACUUM \
shane49097602008-07-31 02:43:34 +0000148 SQLITE_OMIT_BETWEEN_OPTIMIZATION \
danielk1977a15db352007-09-14 16:20:00 +0000149 SQLITE_OMIT_BLOB_LITERAL \
shane49097602008-07-31 02:43:34 +0000150 SQLITE_OMIT_BUILTIN_TEST \
151 SQLITE_OMIT_CAST \
152 SQLITE_OMIT_CHECK \
danielk1977a15db352007-09-14 16:20:00 +0000153 SQLITE_OMIT_COMPLETE \
154 SQLITE_OMIT_COMPOUND_SELECT \
155 SQLITE_OMIT_CONFLICT_CLAUSE \
156 SQLITE_OMIT_DATETIME_FUNCS \
shane49097602008-07-31 02:43:34 +0000157 SQLITE_OMIT_DECLTYPE \
drh21717ed2008-10-13 15:35:08 +0000158 off_SQLITE_OMIT_DISKIO \
danielk19779dfa60b2006-01-26 13:11:36 +0000159 SQLITE_OMIT_EXPLAIN \
shane49097602008-07-31 02:43:34 +0000160 SQLITE_OMIT_FLAG_PRAGMAS \
danielk19779dfa60b2006-01-26 13:11:36 +0000161 SQLITE_OMIT_FLOATING_POINT \
162 SQLITE_OMIT_FOREIGN_KEY \
shane49097602008-07-31 02:43:34 +0000163 SQLITE_OMIT_GET_TABLE \
164 SQLITE_OMIT_GLOBALRECOVER \
danielk1977a15db352007-09-14 16:20:00 +0000165 SQLITE_OMIT_INCRBLOB \
danielk19779dfa60b2006-01-26 13:11:36 +0000166 SQLITE_OMIT_INTEGRITY_CHECK \
shane49097602008-07-31 02:43:34 +0000167 SQLITE_OMIT_LIKE_OPTIMIZATION \
168 SQLITE_OMIT_LOAD_EXTENSION \
169 SQLITE_OMIT_LOCALTIME \
danielk19779dfa60b2006-01-26 13:11:36 +0000170 SQLITE_OMIT_MEMORYDB \
shane49097602008-07-31 02:43:34 +0000171 SQLITE_OMIT_OR_OPTIMIZATION \
danielk19779dfa60b2006-01-26 13:11:36 +0000172 SQLITE_OMIT_PAGER_PRAGMAS \
173 SQLITE_OMIT_PRAGMA \
174 SQLITE_OMIT_PROGRESS_CALLBACK \
shane49097602008-07-31 02:43:34 +0000175 SQLITE_OMIT_QUICKBALANCE \
danielk19779dfa60b2006-01-26 13:11:36 +0000176 SQLITE_OMIT_REINDEX \
177 SQLITE_OMIT_SCHEMA_PRAGMAS \
178 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
shane49097602008-07-31 02:43:34 +0000179 SQLITE_OMIT_SHARED_CACHE \
danielk19779dfa60b2006-01-26 13:11:36 +0000180 SQLITE_OMIT_SUBQUERY \
181 SQLITE_OMIT_TCL_VARIABLE \
shane49097602008-07-31 02:43:34 +0000182 SQLITE_OMIT_TEMPDB \
183 SQLITE_OMIT_TRACE \
danielk19779dfa60b2006-01-26 13:11:36 +0000184 SQLITE_OMIT_TRIGGER \
185 SQLITE_OMIT_UTF16 \
186 SQLITE_OMIT_VACUUM \
danielk1977a15db352007-09-14 16:20:00 +0000187 SQLITE_OMIT_VIEW \
188 SQLITE_OMIT_VIRTUALTABLE \
shane49097602008-07-31 02:43:34 +0000189 SQLITE_OMIT_XFER_OPT \
danielk19779dfa60b2006-01-26 13:11:36 +0000190 ]
191
192 # Process any command line options.
193 process_options $argv
194
195 # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT
196 # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
197 # and the latter is currently incompatible with the test suite (this should
198 # be fixed, but it will be a lot of work).
199 set allsyms [list]
200 foreach s $::SYMBOLS {
201 if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
202 lappend allsyms $s
203 }
204 }
205 run_quick_test test_OMIT_EVERYTHING $allsyms
shane49097602008-07-31 02:43:34 +0000206
danielk19779dfa60b2006-01-26 13:11:36 +0000207 # Now try one quick.test with each of the OMIT symbols defined. Included
208 # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
209 # know they will fail. It's good to be reminded of this from time to time.
210 foreach sym $::SYMBOLS {
211 set dirname "test_[string range $sym 7 end]"
212 run_quick_test $dirname $sym
213 }
214}
215
216main $argv