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 1 ;# 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 -{1,2}run { 154 set ::SKIP_RUN 0 155 } 156 157 -{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 168 default { 169 if {[info exists ::SYMBOL]} { 170 puts stderr [string trim $::USAGE_MESSAGE] 171 exit -1 172 } 173 set ::SYMBOL [lindex $argv $i] 174 } 175 } 176 set ::MAKEFILE [file normalize $::MAKEFILE] 177 } 178} 179 180# Main routine. 181# 182 183proc main {argv} { 184 # List of SQLITE_OMIT_XXX symbols supported by SQLite. 185 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 \ 198 SQLITE_OMIT_CASE_SENSITIVE_LIKE_PRAGMA \ 199 SQLITE_OMIT_CAST \ 200 SQLITE_OMIT_CHECK \ 201 SQLITE_OMIT_COMPILEOPTION_DIAGS \ 202 SQLITE_OMIT_COMPLETE \ 203 SQLITE_OMIT_COMPOUND_SELECT \ 204 SQLITE_OMIT_CONFLICT_CLAUSE \ 205 SQLITE_OMIT_CTE \ 206 SQLITE_OMIT_DATETIME_FUNCS \ 207 SQLITE_OMIT_DECLTYPE \ 208 SQLITE_OMIT_DEPRECATED \ 209 SQLITE_OMIT_DESERIALIZE \ 210 SQLITE_OMIT_DISKIO \ 211 SQLITE_OMIT_EXPLAIN \ 212 SQLITE_OMIT_FLAG_PRAGMAS \ 213 SQLITE_OMIT_FLOATING_POINT \ 214 SQLITE_OMIT_FOREIGN_KEY \ 215 SQLITE_OMIT_GENERATED_COLUMNS \ 216 SQLITE_OMIT_GET_TABLE \ 217 SQLITE_OMIT_HEX_INTEGER \ 218 SQLITE_OMIT_INCRBLOB \ 219 SQLITE_OMIT_INTEGRITY_CHECK \ 220 SQLITE_OMIT_INTROSPECTION_PRAGMAS \ 221 SQLITE_OMIT_JSON \ 222 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 \ 229 SQLITE_OMIT_PARSER_TRACE \ 230 SQLITE_OMIT_POPEN \ 231 SQLITE_OMIT_PRAGMA \ 232 SQLITE_OMIT_PROGRESS_CALLBACK \ 233 SQLITE_OMIT_QUICKBALANCE \ 234 SQLITE_OMIT_RANDOMNESS \ 235 SQLITE_OMIT_REINDEX \ 236 SQLITE_OMIT_SCHEMA_PRAGMAS \ 237 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \ 238 SQLITE_OMIT_SHARED_CACHE \ 239 SQLITE_OMIT_SHUTDOWN_DIRECTORIES \ 240 SQLITE_OMIT_SUBQUERY \ 241 SQLITE_OMIT_TCL_VARIABLE \ 242 SQLITE_OMIT_TEMPDB \ 243 SQLITE_OMIT_TEST_CONTROL \ 244 SQLITE_OMIT_TRACE \ 245 SQLITE_OMIT_TRIGGER \ 246 SQLITE_OMIT_TRUNCATE_OPTIMIZATION \ 247 SQLITE_OMIT_UPSERT \ 248 SQLITE_OMIT_UTF16 \ 249 SQLITE_OMIT_VACUUM \ 250 SQLITE_OMIT_VIEW \ 251 SQLITE_OMIT_VIRTUALTABLE \ 252 SQLITE_OMIT_WAL \ 253 SQLITE_OMIT_WINDOWFUNC \ 254 SQLITE_OMIT_WSD \ 255 SQLITE_OMIT_XFER_OPT \ 256 ] 257 258 set ::ENABLE_SYMBOLS [list \ 259 SQLITE_ALLOW_ROWID_IN_VIEW \ 260 SQLITE_DISABLE_DIRSYNC \ 261 SQLITE_DISABLE_LFS \ 262 SQLITE_ENABLE_ATOMIC_WRITE \ 263 SQLITE_ENABLE_COLUMN_METADATA \ 264 SQLITE_ENABLE_EXPENSIVE_ASSERT \ 265 SQLITE_ENABLE_FTS3 \ 266 SQLITE_ENABLE_FTS3_PARENTHESIS \ 267 SQLITE_ENABLE_FTS4 \ 268 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 \ 276 SQLITE_ENABLE_STAT3 \ 277 SQLITE_ENABLE_UNLOCK_NOTIFY \ 278 SQLITE_ENABLE_UPDATE_DELETE_LIMIT \ 279 ] 280 281 # Process any command line options. 282 process_options $argv 283 284 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 290 } 291 292 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" 293 run_quick_test $dirname $sym 294 } 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 { 311 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" 312 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 { 318 set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" 319 run_quick_test $dirname $sym 320 } 321 } 322} 323 324main $argv 325