1# 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 8 <script> ?test-symbol? ?-makefile PATH-TO-MAKEFILE? ?-skip_run? 9 10The default value for ::MAKEFILE is "../Makefile.linux.gcc". 11 12If -skip_run option is given then only the compile part is attempted. 13 14This 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 31 $::MAKEBIN -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1" 32 $::MAKEBIN -f $::MAKEFILE test 33 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. 49 set opts "" 50 if {$::tcl_platform(platform)=="windows"} { 51 append opts "OPTS += -DSQLITE_OS_WIN=1\n" 52 set target "testfixture.exe" 53 } else { 54 append opts "OPTS += -DSQLITE_OS_UNIX=1\n" 55 } 56 foreach sym $omit_symbol_list { 57 append opts "OPTS += -D${sym}=1\n" 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 65 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 77 set rc [catch { 78 exec $::MAKEBIN -C $dir -f makefile clean $::TARGET >& $dir/build.log 79 }] 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). 90 set sqlite3_dummy $dir/sqlite3 91 if {$::tcl_platform(platform)=="windows"} { 92 append sqlite3_dummy ".exe" 93 } 94 if {![file exists $sqlite3_dummy]} { 95 set wr [open $sqlite3_dummy w] 96 puts $wr "dummy" 97 close $wr 98 } 99 100 if {$::SKIP_RUN} { 101 puts "Skip testing $dir." 102 } else { 103 # Run the test suite. 104 puts -nonewline "Testing $dir..." 105 flush stdout 106 set rc [catch { 107 exec $::MAKEBIN -C $dir -f makefile test >& $dir/test.log 108 }] 109 if {$rc} { 110 puts "No good. See $dir/test.log." 111 } else { 112 puts "Ok" 113 } 114 } 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} { 124 set ::MAKEBIN make ;# Default value 125 if {$::tcl_platform(platform)=="windows"} { 126 set ::MAKEFILE ./Makefile ;# Default value on Windows 127 } else { 128 set ::MAKEFILE ./Makefile.linux-gcc ;# Default value 129 } 130 set ::SKIP_RUN 0 ;# Default to attempt test 131 set ::TARGET testfixture ;# Default thing to build 132 133 for {set i 0} {$i < [llength $argv]} {incr i} { 134 switch -regexp -- [lindex $argv $i] { 135 -{1,2}makefile { 136 incr i 137 set ::MAKEFILE [lindex $argv $i] 138 } 139 140 -{1,2}nmake { 141 set ::MAKEBIN nmake 142 set ::MAKEFILE ./Makefile.msc 143 } 144 145 -{1,2}target { 146 incr i 147 set ::TARGET [lindex $argv $i] 148 } 149 150 -{1,2}skip_run { 151 set ::SKIP_RUN 1 152 } 153 154 -{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 165 default { 166 if {[info exists ::SYMBOL]} { 167 puts stderr [string trim $::USAGE_MESSAGE] 168 exit -1 169 } 170 set ::SYMBOL [lindex $argv $i] 171 } 172 } 173 set ::MAKEFILE [file normalize $::MAKEFILE] 174 } 175} 176 177# Main routine. 178# 179 180proc main {argv} { 181 # List of SQLITE_OMIT_XXX symbols supported by SQLite. 182 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 \ 201 SQLITE_OMIT_CTE \ 202 SQLITE_OMIT_DATETIME_FUNCS \ 203 SQLITE_OMIT_DECLTYPE \ 204 SQLITE_OMIT_DEPRECATED \ 205 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 \ 224 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \ 225 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 \ 232 SQLITE_OMIT_UNIQUE_ENFORCEMENT \ 233 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 \ 246 SQLITE_ENABLE_COLUMN_METADATA \ 247 SQLITE_ENABLE_EXPENSIVE_ASSERT \ 248 SQLITE_ENABLE_FTS3 \ 249 SQLITE_ENABLE_FTS3_PARENTHESIS \ 250 SQLITE_ENABLE_FTS4 \ 251 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 \ 259 SQLITE_ENABLE_STAT3 \ 260 SQLITE_ENABLE_UNLOCK_NOTIFY \ 261 SQLITE_ENABLE_UPDATE_DELETE_LIMIT \ 262 ] 263 264 # Process any command line options. 265 process_options $argv 266 267 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 273 } 274 275 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" 276 run_quick_test $dirname $sym 277 } 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 { 294 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" 295 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 { 301 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" 302 run_quick_test $dirname $sym 303 } 304 } 305} 306 307main $argv 308