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 | |
| 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. |
drh | 21717ed | 2008-10-13 15:35:08 +0000 | [diff] [blame] | 50 | set opts "-DSQLITE_MEMDEBUG -DSQLITE_DEBUG -DSQLITE_NO_SYNC" |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 51 | if {$::tcl_platform(platform)=="windows"} { |
| 52 | append opts " -DSQLITE_OS_WIN=1" |
pweilbacher | e7c8a5c | 2008-08-22 13:57:39 +0000 | [diff] [blame] | 53 | } elseif {$::tcl_platform(platform)=="os2"} { |
| 54 | append opts " -DSQLITE_OS_OS2=1" |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 55 | } else { |
| 56 | append opts " -DSQLITE_OS_UNIX=1" |
| 57 | } |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 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 |
danielk1977 | de3e41e | 2008-08-04 03:51:24 +0000 | [diff] [blame] | 67 | catch { |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 68 | file copy -force ./config.h $dir |
| 69 | file copy -force ./libtool $dir |
danielk1977 | de3e41e | 2008-08-04 03:51:24 +0000 | [diff] [blame] | 70 | } |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 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). |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 84 | set sqlite3_dummy $dir/sqlite3 |
pweilbacher | e7c8a5c | 2008-08-22 13:57:39 +0000 | [diff] [blame] | 85 | if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 86 | append sqlite3_dummy ".exe" |
| 87 | } |
| 88 | if {![file exists $sqlite3_dummy]} { |
| 89 | set wr [open $sqlite3_dummy w] |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 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} { |
pweilbacher | e7c8a5c | 2008-08-22 13:57:39 +0000 | [diff] [blame] | 114 | if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 115 | set ::MAKEFILE ../Makefile ;# Default value |
| 116 | } else { |
| 117 | set ::MAKEFILE ../Makefile.linux-gcc ;# Default value |
| 118 | } |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 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 | # |
danielk1977 | 4b2688a | 2006-06-20 11:01:07 +0000 | [diff] [blame] | 137 | |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 138 | proc main {argv} { |
| 139 | # List of SQLITE_OMIT_XXX symbols supported by SQLite. |
| 140 | set ::SYMBOLS [list \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 141 | SQLITE_OMIT_ALTERTABLE \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 142 | SQLITE_OMIT_ANALYZE \ |
| 143 | SQLITE_OMIT_ATTACH \ |
danielk1977 | a15db35 | 2007-09-14 16:20:00 +0000 | [diff] [blame] | 144 | SQLITE_OMIT_AUTHORIZATION \ |
| 145 | SQLITE_OMIT_AUTOINCREMENT \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 146 | SQLITE_OMIT_AUTOINIT \ |
danielk1977 | a15db35 | 2007-09-14 16:20:00 +0000 | [diff] [blame] | 147 | SQLITE_OMIT_AUTOVACUUM \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 148 | SQLITE_OMIT_BETWEEN_OPTIMIZATION \ |
danielk1977 | a15db35 | 2007-09-14 16:20:00 +0000 | [diff] [blame] | 149 | SQLITE_OMIT_BLOB_LITERAL \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 150 | SQLITE_OMIT_BUILTIN_TEST \ |
| 151 | SQLITE_OMIT_CAST \ |
| 152 | SQLITE_OMIT_CHECK \ |
danielk1977 | a15db35 | 2007-09-14 16:20:00 +0000 | [diff] [blame] | 153 | SQLITE_OMIT_COMPLETE \ |
| 154 | SQLITE_OMIT_COMPOUND_SELECT \ |
| 155 | SQLITE_OMIT_CONFLICT_CLAUSE \ |
| 156 | SQLITE_OMIT_DATETIME_FUNCS \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 157 | SQLITE_OMIT_DECLTYPE \ |
drh | 21717ed | 2008-10-13 15:35:08 +0000 | [diff] [blame] | 158 | off_SQLITE_OMIT_DISKIO \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 159 | SQLITE_OMIT_EXPLAIN \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 160 | SQLITE_OMIT_FLAG_PRAGMAS \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 161 | SQLITE_OMIT_FLOATING_POINT \ |
| 162 | SQLITE_OMIT_FOREIGN_KEY \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 163 | SQLITE_OMIT_GET_TABLE \ |
| 164 | SQLITE_OMIT_GLOBALRECOVER \ |
danielk1977 | a15db35 | 2007-09-14 16:20:00 +0000 | [diff] [blame] | 165 | SQLITE_OMIT_INCRBLOB \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 166 | SQLITE_OMIT_INTEGRITY_CHECK \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 167 | SQLITE_OMIT_LIKE_OPTIMIZATION \ |
| 168 | SQLITE_OMIT_LOAD_EXTENSION \ |
| 169 | SQLITE_OMIT_LOCALTIME \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 170 | SQLITE_OMIT_MEMORYDB \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 171 | SQLITE_OMIT_OR_OPTIMIZATION \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 172 | SQLITE_OMIT_PAGER_PRAGMAS \ |
| 173 | SQLITE_OMIT_PRAGMA \ |
| 174 | SQLITE_OMIT_PROGRESS_CALLBACK \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 175 | SQLITE_OMIT_QUICKBALANCE \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 176 | SQLITE_OMIT_REINDEX \ |
| 177 | SQLITE_OMIT_SCHEMA_PRAGMAS \ |
| 178 | SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 179 | SQLITE_OMIT_SHARED_CACHE \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 180 | SQLITE_OMIT_SUBQUERY \ |
| 181 | SQLITE_OMIT_TCL_VARIABLE \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 182 | SQLITE_OMIT_TEMPDB \ |
| 183 | SQLITE_OMIT_TRACE \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 184 | SQLITE_OMIT_TRIGGER \ |
| 185 | SQLITE_OMIT_UTF16 \ |
| 186 | SQLITE_OMIT_VACUUM \ |
danielk1977 | a15db35 | 2007-09-14 16:20:00 +0000 | [diff] [blame] | 187 | SQLITE_OMIT_VIEW \ |
| 188 | SQLITE_OMIT_VIRTUALTABLE \ |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 189 | SQLITE_OMIT_XFER_OPT \ |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 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 |
shane | 4909760 | 2008-07-31 02:43:34 +0000 | [diff] [blame] | 206 | |
danielk1977 | 9dfa60b | 2006-01-26 13:11:36 +0000 | [diff] [blame] | 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 |