danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 1 | |
drh | 21717ed | 2008-10-13 15:35:08 +0000 | [diff] [blame] | 2 | set rcsid {$Id: omittest.tcl,v 1.8 2008/10/13 15:35:09 drh Exp $} |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 3 | |
| 4 | # Documentation for this script. This may be output to stderr |
| 5 | # if the script is invoked incorrectly. |
| 6 | set ::USAGE_MESSAGE { |
| 7 | This Tcl script is used to test the various compile time options |
| 8 | available for omitting code (the SQLITE_OMIT_xxx options). It |
| 9 | should be invoked as follows: |
| 10 | |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 11 | <script> ?test-symbol? ?-makefile PATH-TO-MAKEFILE? ?-skip_run? |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 12 | |
| 13 | The default value for ::MAKEFILE is "../Makefile.linux.gcc". |
| 14 | |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 15 | If -skip_run option is given then only the compile part is attempted. |
| 16 | |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 17 | This script builds the testfixture program and runs the SQLite test suite |
| 18 | once with each SQLITE_OMIT_ option defined and then once with all options |
| 19 | defined together. Each run is performed in a seperate directory created |
| 20 | as a sub-directory of the current directory by the script. The output |
| 21 | of the build is saved in <sub-directory>/build.log. The output of the |
| 22 | test-suite is saved in <sub-directory>/test.log. |
| 23 | |
| 24 | Almost any SQLite makefile (except those generated by configure - see below) |
| 25 | should work. The following properties are required: |
| 26 | |
| 27 | * The makefile should support the "testfixture" target. |
| 28 | * The makefile should support the "test" target. |
| 29 | * The makefile should support the variable "OPTS" as a way to pass |
| 30 | options from the make command line to lemon and the C compiler. |
| 31 | |
| 32 | More precisely, the following two invocations must be supported: |
| 33 | |
shaneh | 5e0855c | 2011-06-22 20:14:09 +0000 | [diff] [blame] | 34 | $::MAKEBIN -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1" |
| 35 | $::MAKEBIN -f $::MAKEFILE test |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 36 | |
| 37 | Makefiles generated by the sqlite configure program cannot be used as |
| 38 | they do not respect the OPTS variable. |
| 39 | } |
| 40 | |
| 41 | |
| 42 | # Build a testfixture executable and run quick.test using it. The first |
| 43 | # parameter is the name of the directory to create and use to run the |
| 44 | # test in. The second parameter is a list of OMIT symbols to define |
| 45 | # when doing so. For example: |
| 46 | # |
| 47 | # run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW} |
| 48 | # |
| 49 | # |
| 50 | proc run_quick_test {dir omit_symbol_list} { |
| 51 | # Compile the value of the OPTS Makefile variable. |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 52 | set opts "" |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 53 | if {$::tcl_platform(platform)=="windows"} { |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 54 | append opts "OPTS += -DSQLITE_OS_WIN=1\n" |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 55 | set target "testfixture.exe" |
pweilbacher | e7c8a5c | 2008-08-22 13:57:39 +0000 | [diff] [blame] | 56 | } elseif {$::tcl_platform(platform)=="os2"} { |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 57 | append opts "OPTS += -DSQLITE_OS_OS2=1\n" |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 58 | } else { |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 59 | append opts "OPTS += -DSQLITE_OS_UNIX=1\n" |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 60 | } |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 61 | foreach sym $omit_symbol_list { |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 62 | append opts "OPTS += -D${sym}=1\n" |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | # Create the directory and do the build. If an error occurs return |
| 66 | # early without attempting to run the test suite. |
| 67 | file mkdir $dir |
| 68 | puts -nonewline "Building $dir..." |
| 69 | flush stdout |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 70 | catch { |
| 71 | file copy -force ./config.h $dir |
| 72 | file copy -force ./libtool $dir |
| 73 | } |
| 74 | set fd [open $::MAKEFILE] |
| 75 | set mkfile [read $fd] |
| 76 | close $fd |
| 77 | regsub {\ninclude} $mkfile "\n$opts\ninclude" mkfile |
| 78 | set fd [open $dir/makefile w] |
| 79 | puts $fd $mkfile |
| 80 | close $fd |
| 81 | |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 82 | set rc [catch { |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 83 | exec $::MAKEBIN -C $dir -f makefile clean $::TARGET >& $dir/build.log |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 84 | }] |
| 85 | if {$rc} { |
| 86 | puts "No good. See $dir/build.log." |
| 87 | return |
| 88 | } else { |
| 89 | puts "Ok" |
| 90 | } |
| 91 | |
| 92 | # Create an empty file "$dir/sqlite3". This is to trick the makefile out |
| 93 | # of trying to build the sqlite shell. The sqlite shell won't build |
| 94 | # with some of the OMIT options (i.e OMIT_COMPLETE). |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 95 | set sqlite3_dummy $dir/sqlite3 |
pweilbacher | e7c8a5c | 2008-08-22 13:57:39 +0000 | [diff] [blame] | 96 | if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 97 | append sqlite3_dummy ".exe" |
| 98 | } |
| 99 | if {![file exists $sqlite3_dummy]} { |
| 100 | set wr [open $sqlite3_dummy w] |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 101 | puts $wr "dummy" |
| 102 | close $wr |
| 103 | } |
| 104 | |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 105 | if {$::SKIP_RUN} { |
| 106 | puts "Skip testing $dir." |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 107 | } else { |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 108 | # Run the test suite. |
| 109 | puts -nonewline "Testing $dir..." |
| 110 | flush stdout |
| 111 | set rc [catch { |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 112 | exec $::MAKEBIN -C $dir -f makefile test >& $dir/test.log |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 113 | }] |
| 114 | if {$rc} { |
| 115 | puts "No good. See $dir/test.log." |
| 116 | } else { |
| 117 | puts "Ok" |
| 118 | } |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | |
| 122 | |
| 123 | # This proc processes the command line options passed to this script. |
| 124 | # Currently the only option supported is "-makefile", default |
| 125 | # "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this |
| 126 | # option. |
| 127 | # |
| 128 | proc process_options {argv} { |
shaneh | 5e0855c | 2011-06-22 20:14:09 +0000 | [diff] [blame] | 129 | set ::MAKEBIN make ;# Default value |
pweilbacher | e7c8a5c | 2008-08-22 13:57:39 +0000 | [diff] [blame] | 130 | if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { |
shaneh | 5e0855c | 2011-06-22 20:14:09 +0000 | [diff] [blame] | 131 | set ::MAKEFILE ./Makefile ;# Default value on Windows and OS2 |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 132 | } else { |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 133 | set ::MAKEFILE ./Makefile.linux-gcc ;# Default value |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 134 | } |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 135 | set ::SKIP_RUN 0 ;# Default to attempt test |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 136 | set ::TARGET testfixture ;# Default thing to build |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 137 | |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 138 | for {set i 0} {$i < [llength $argv]} {incr i} { |
| 139 | switch -- [lindex $argv $i] { |
| 140 | -makefile { |
| 141 | incr i |
| 142 | set ::MAKEFILE [lindex $argv $i] |
| 143 | } |
| 144 | |
shaneh | 5e0855c | 2011-06-22 20:14:09 +0000 | [diff] [blame] | 145 | -nmake { |
| 146 | set ::MAKEBIN nmake |
| 147 | set ::MAKEFILE ./Makefile.msc |
| 148 | } |
| 149 | |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 150 | -target { |
| 151 | incr i |
| 152 | set ::TARGET [lindex $argv $i] |
| 153 | } |
| 154 | |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 155 | -skip_run { |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 156 | set ::SKIP_RUN 1 |
| 157 | } |
| 158 | |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 159 | default { |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 160 | if {[info exists ::SYMBOL]} { |
| 161 | puts stderr [string trim $::USAGE_MESSAGE] |
| 162 | exit -1 |
| 163 | } |
| 164 | set ::SYMBOL [lindex $argv $i] |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | set ::MAKEFILE [file normalize $::MAKEFILE] |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | # Main routine. |
| 172 | # |
danielk1977 | 4b2688a | 2006-06-20 11:01:07 +0000 | [diff] [blame] | 173 | |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 174 | proc main {argv} { |
| 175 | # List of SQLITE_OMIT_XXX symbols supported by SQLite. |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 176 | set ::OMIT_SYMBOLS [list \ |
| 177 | SQLITE_OMIT_ALTERTABLE \ |
| 178 | SQLITE_OMIT_ANALYZE \ |
| 179 | SQLITE_OMIT_ATTACH \ |
| 180 | SQLITE_OMIT_AUTHORIZATION \ |
| 181 | SQLITE_OMIT_AUTOINCREMENT \ |
| 182 | SQLITE_OMIT_AUTOINIT \ |
| 183 | SQLITE_OMIT_AUTOMATIC_INDEX \ |
| 184 | SQLITE_OMIT_AUTORESET \ |
| 185 | SQLITE_OMIT_AUTOVACUUM \ |
| 186 | SQLITE_OMIT_BETWEEN_OPTIMIZATION \ |
| 187 | SQLITE_OMIT_BLOB_LITERAL \ |
| 188 | SQLITE_OMIT_BTREECOUNT \ |
| 189 | SQLITE_OMIT_BUILTIN_TEST \ |
| 190 | SQLITE_OMIT_CAST \ |
| 191 | SQLITE_OMIT_CHECK \ |
| 192 | SQLITE_OMIT_COMPILEOPTION_DIAGS \ |
| 193 | SQLITE_OMIT_COMPLETE \ |
| 194 | SQLITE_OMIT_COMPOUND_SELECT \ |
| 195 | SQLITE_OMIT_DATETIME_FUNCS \ |
| 196 | SQLITE_OMIT_DECLTYPE \ |
| 197 | SQLITE_OMIT_DEPRECATED \ |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 198 | SQLITE_OMIT_EXPLAIN \ |
| 199 | SQLITE_OMIT_FLAG_PRAGMAS \ |
| 200 | SQLITE_OMIT_FLOATING_POINT \ |
| 201 | SQLITE_OMIT_FOREIGN_KEY \ |
| 202 | SQLITE_OMIT_GET_TABLE \ |
| 203 | SQLITE_OMIT_INCRBLOB \ |
| 204 | SQLITE_OMIT_INTEGRITY_CHECK \ |
| 205 | SQLITE_OMIT_LIKE_OPTIMIZATION \ |
| 206 | SQLITE_OMIT_LOAD_EXTENSION \ |
| 207 | SQLITE_OMIT_LOCALTIME \ |
| 208 | SQLITE_OMIT_LOOKASIDE \ |
| 209 | SQLITE_OMIT_MEMORYDB \ |
| 210 | SQLITE_OMIT_OR_OPTIMIZATION \ |
| 211 | SQLITE_OMIT_PAGER_PRAGMAS \ |
| 212 | SQLITE_OMIT_PRAGMA \ |
| 213 | SQLITE_OMIT_PROGRESS_CALLBACK \ |
| 214 | SQLITE_OMIT_QUICKBALANCE \ |
| 215 | SQLITE_OMIT_REINDEX \ |
| 216 | SQLITE_OMIT_SCHEMA_PRAGMAS \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 217 | SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \ |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 218 | SQLITE_OMIT_SHARED_CACHE \ |
| 219 | SQLITE_OMIT_SUBQUERY \ |
| 220 | SQLITE_OMIT_TCL_VARIABLE \ |
| 221 | SQLITE_OMIT_TEMPDB \ |
| 222 | SQLITE_OMIT_TRACE \ |
| 223 | SQLITE_OMIT_TRIGGER \ |
| 224 | SQLITE_OMIT_TRUNCATE_OPTIMIZATION \ |
shaneh | 11c58f7 | 2011-03-12 04:58:55 +0000 | [diff] [blame] | 225 | SQLITE_OMIT_UNIQUE_ENFORCEMENT \ |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 226 | SQLITE_OMIT_UTF16 \ |
| 227 | SQLITE_OMIT_VACUUM \ |
| 228 | SQLITE_OMIT_VIEW \ |
| 229 | SQLITE_OMIT_VIRTUALTABLE \ |
| 230 | SQLITE_OMIT_WAL \ |
| 231 | SQLITE_OMIT_WSD \ |
| 232 | SQLITE_OMIT_XFER_OPT \ |
| 233 | ] |
| 234 | |
| 235 | set ::ENABLE_SYMBOLS [list \ |
| 236 | SQLITE_DISABLE_DIRSYNC \ |
| 237 | SQLITE_DISABLE_LFS \ |
| 238 | SQLITE_ENABLE_ATOMIC_WRITE \ |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 239 | SQLITE_ENABLE_COLUMN_METADATA \ |
| 240 | SQLITE_ENABLE_EXPENSIVE_ASSERT \ |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 241 | SQLITE_ENABLE_FTS3 \ |
| 242 | SQLITE_ENABLE_FTS3_PARENTHESIS \ |
| 243 | SQLITE_ENABLE_FTS4 \ |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 244 | SQLITE_ENABLE_IOTRACE \ |
| 245 | SQLITE_ENABLE_LOAD_EXTENSION \ |
| 246 | SQLITE_ENABLE_LOCKING_STYLE \ |
| 247 | SQLITE_ENABLE_MEMORY_MANAGEMENT \ |
| 248 | SQLITE_ENABLE_MEMSYS3 \ |
| 249 | SQLITE_ENABLE_MEMSYS5 \ |
| 250 | SQLITE_ENABLE_OVERSIZE_CELL_CHECK \ |
| 251 | SQLITE_ENABLE_RTREE \ |
drh | 60bdeb2 | 2011-10-20 00:55:54 +0000 | [diff] [blame] | 252 | SQLITE_ENABLE_STAT3 \ |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 253 | SQLITE_ENABLE_UNLOCK_NOTIFY \ |
| 254 | SQLITE_ENABLE_UPDATE_DELETE_LIMIT \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 255 | ] |
| 256 | |
| 257 | # Process any command line options. |
| 258 | process_options $argv |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 259 | |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 260 | if {[info exists ::SYMBOL] } { |
| 261 | set sym $::SYMBOL |
| 262 | |
| 263 | if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} { |
| 264 | puts stderr "No such symbol: $sym" |
| 265 | exit -1 |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 266 | } |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 267 | |
shaneh | 5e0855c | 2011-06-22 20:14:09 +0000 | [diff] [blame] | 268 | set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" |
shaneh | bb20134 | 2011-02-09 19:55:20 +0000 | [diff] [blame] | 269 | run_quick_test $dirname $sym |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 270 | } else { |
| 271 | # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT |
| 272 | # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults) |
| 273 | # and the latter is currently incompatible with the test suite (this should |
| 274 | # be fixed, but it will be a lot of work). |
| 275 | set allsyms [list] |
| 276 | foreach s $::OMIT_SYMBOLS { |
| 277 | if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} { |
| 278 | lappend allsyms $s |
| 279 | } |
| 280 | } |
| 281 | run_quick_test test_OMIT_EVERYTHING $allsyms |
| 282 | |
| 283 | # Now try one quick.test with each of the OMIT symbols defined. Included |
| 284 | # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we |
| 285 | # know they will fail. It's good to be reminded of this from time to time. |
| 286 | foreach sym $::OMIT_SYMBOLS { |
shaneh | 5e0855c | 2011-06-22 20:14:09 +0000 | [diff] [blame] | 287 | set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 288 | run_quick_test $dirname $sym |
| 289 | } |
| 290 | |
| 291 | # Try the ENABLE/DISABLE symbols one at a time. |
| 292 | # We don't do them all at once since some are conflicting. |
| 293 | foreach sym $::ENABLE_SYMBOLS { |
shaneh | 5e0855c | 2011-06-22 20:14:09 +0000 | [diff] [blame] | 294 | set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]" |
dan | bb2b441 | 2011-04-06 17:54:31 +0000 | [diff] [blame] | 295 | run_quick_test $dirname $sym |
| 296 | } |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
| 300 | main $argv |