| OLD | NEW |
| (Empty) |
| 1 | |
| 2 set rcsid {$Id: omittest.tcl,v 1.8 2008/10/13 15:35:09 drh Exp $} | |
| 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 | |
| 11 <script> ?-makefile PATH-TO-MAKEFILE? | |
| 12 | |
| 13 The default value for ::MAKEFILE is "../Makefile.linux.gcc". | |
| 14 | |
| 15 This script builds the testfixture program and runs the SQLite test suite | |
| 16 once with each SQLITE_OMIT_ option defined and then once with all options | |
| 17 defined together. Each run is performed in a seperate directory created | |
| 18 as a sub-directory of the current directory by the script. The output | |
| 19 of the build is saved in <sub-directory>/build.log. The output of the | |
| 20 test-suite is saved in <sub-directory>/test.log. | |
| 21 | |
| 22 Almost any SQLite makefile (except those generated by configure - see below) | |
| 23 should 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 | |
| 30 More 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 | |
| 35 Makefiles generated by the sqlite configure program cannot be used as | |
| 36 they 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 # | |
| 48 proc run_quick_test {dir omit_symbol_list} { | |
| 49 # Compile the value of the OPTS Makefile variable. | |
| 50 set opts "-DSQLITE_MEMDEBUG -DSQLITE_DEBUG -DSQLITE_NO_SYNC" | |
| 51 if {$::tcl_platform(platform)=="windows"} { | |
| 52 append opts " -DSQLITE_OS_WIN=1" | |
| 53 } elseif {$::tcl_platform(platform)=="os2"} { | |
| 54 append opts " -DSQLITE_OS_OS2=1" | |
| 55 } else { | |
| 56 append opts " -DSQLITE_OS_UNIX=1" | |
| 57 } | |
| 58 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 | |
| 67 catch { | |
| 68 file copy -force ./config.h $dir | |
| 69 file copy -force ./libtool $dir | |
| 70 } | |
| 71 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). | |
| 84 set sqlite3_dummy $dir/sqlite3 | |
| 85 if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"}
{ | |
| 86 append sqlite3_dummy ".exe" | |
| 87 } | |
| 88 if {![file exists $sqlite3_dummy]} { | |
| 89 set wr [open $sqlite3_dummy w] | |
| 90 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 # | |
| 113 proc process_options {argv} { | |
| 114 if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"}
{ | |
| 115 set ::MAKEFILE ../Makefile ;# Default value | |
| 116 } else { | |
| 117 set ::MAKEFILE ../Makefile.linux-gcc ;# Default value | |
| 118 } | |
| 119 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 # | |
| 137 | |
| 138 proc main {argv} { | |
| 139 # List of SQLITE_OMIT_XXX symbols supported by SQLite. | |
| 140 set ::SYMBOLS [list \ | |
| 141 SQLITE_OMIT_ALTERTABLE \ | |
| 142 SQLITE_OMIT_ANALYZE \ | |
| 143 SQLITE_OMIT_ATTACH \ | |
| 144 SQLITE_OMIT_AUTHORIZATION \ | |
| 145 SQLITE_OMIT_AUTOINCREMENT \ | |
| 146 SQLITE_OMIT_AUTOINIT \ | |
| 147 SQLITE_OMIT_AUTOVACUUM \ | |
| 148 SQLITE_OMIT_BETWEEN_OPTIMIZATION \ | |
| 149 SQLITE_OMIT_BLOB_LITERAL \ | |
| 150 SQLITE_OMIT_BUILTIN_TEST \ | |
| 151 SQLITE_OMIT_CAST \ | |
| 152 SQLITE_OMIT_CHECK \ | |
| 153 SQLITE_OMIT_COMPLETE \ | |
| 154 SQLITE_OMIT_COMPOUND_SELECT \ | |
| 155 SQLITE_OMIT_CONFLICT_CLAUSE \ | |
| 156 SQLITE_OMIT_DATETIME_FUNCS \ | |
| 157 SQLITE_OMIT_DECLTYPE \ | |
| 158 off_SQLITE_OMIT_DISKIO \ | |
| 159 SQLITE_OMIT_EXPLAIN \ | |
| 160 SQLITE_OMIT_FLAG_PRAGMAS \ | |
| 161 SQLITE_OMIT_FLOATING_POINT \ | |
| 162 SQLITE_OMIT_FOREIGN_KEY \ | |
| 163 SQLITE_OMIT_GET_TABLE \ | |
| 164 SQLITE_OMIT_GLOBALRECOVER \ | |
| 165 SQLITE_OMIT_INCRBLOB \ | |
| 166 SQLITE_OMIT_INTEGRITY_CHECK \ | |
| 167 SQLITE_OMIT_LIKE_OPTIMIZATION \ | |
| 168 SQLITE_OMIT_LOAD_EXTENSION \ | |
| 169 SQLITE_OMIT_LOCALTIME \ | |
| 170 SQLITE_OMIT_MEMORYDB \ | |
| 171 SQLITE_OMIT_OR_OPTIMIZATION \ | |
| 172 SQLITE_OMIT_PAGER_PRAGMAS \ | |
| 173 SQLITE_OMIT_PRAGMA \ | |
| 174 SQLITE_OMIT_PROGRESS_CALLBACK \ | |
| 175 SQLITE_OMIT_QUICKBALANCE \ | |
| 176 SQLITE_OMIT_REINDEX \ | |
| 177 SQLITE_OMIT_SCHEMA_PRAGMAS \ | |
| 178 SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \ | |
| 179 SQLITE_OMIT_SHARED_CACHE \ | |
| 180 SQLITE_OMIT_SUBQUERY \ | |
| 181 SQLITE_OMIT_TCL_VARIABLE \ | |
| 182 SQLITE_OMIT_TEMPDB \ | |
| 183 SQLITE_OMIT_TRACE \ | |
| 184 SQLITE_OMIT_TRIGGER \ | |
| 185 SQLITE_OMIT_UTF16 \ | |
| 186 SQLITE_OMIT_VACUUM \ | |
| 187 SQLITE_OMIT_VIEW \ | |
| 188 SQLITE_OMIT_VIRTUALTABLE \ | |
| 189 SQLITE_OMIT_XFER_OPT \ | |
| 190 ] | |
| 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 | |
| 206 | |
| 207 # 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 | |
| 216 main $argv | |
| OLD | NEW |