drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 1 | |
| 2 | set rcsid {$Id: $} |
| 3 | |
| 4 | # Documentation for this script. This may be output to stderr |
| 5 | # if the script is invoked incorrectly. See the [process_options] |
| 6 | # proc below. |
| 7 | # |
| 8 | set ::USAGE_MESSAGE { |
| 9 | This Tcl script is used to test the various configurations required |
| 10 | before releasing a new version. Supported command line options (all |
| 11 | optional) are: |
| 12 | |
| 13 | -makefile PATH-TO-MAKEFILE (default "releasetest.mk") |
| 14 | -platform PLATFORM (see below) |
| 15 | -quick BOOLEAN (default "0") |
| 16 | |
| 17 | The default value for -makefile is "./releasetest.mk". |
| 18 | |
| 19 | The script determines the default value for -platform using the |
| 20 | $tcl_platform(os) and $tcl_platform(machine) variables. Supported |
| 21 | platforms are "Linux-x86", "Linux-x86_64" and "Darwin-i386". |
| 22 | |
| 23 | If the -quick option is set to true, then the "veryquick.test" script |
| 24 | is run for all compilation configurations. Otherwise, sometimes "all.test" |
| 25 | is run, sometimes "veryquick.test". |
| 26 | |
| 27 | Almost any SQLite makefile (except those generated by configure - see below) |
| 28 | should work. The following properties are required: |
| 29 | |
| 30 | * The makefile should support the "fulltest" target. |
| 31 | * The makefile should support the variable "OPTS" as a way to pass |
| 32 | options from the make command line to lemon and the C compiler. |
| 33 | |
| 34 | More precisely, the following invocation must be supported: |
| 35 | |
| 36 | make -f $::MAKEFILE fulltest OPTS="-DSQLITE_SECURE_DELETE=1 -DSQLITE_DEBUG=1" |
| 37 | |
| 38 | Makefiles generated by the sqlite configure program cannot be used as |
| 39 | they do not respect the OPTS variable. |
| 40 | |
| 41 | Example Makefile contents: |
| 42 | |
| 43 | ######################################################## |
| 44 | TOP=/home/dan/work/sqlite/sqlite |
| 45 | |
| 46 | TCL_FLAGS=-I/home/dan/tcl/include |
| 47 | LIBTCL=-L/home/dan/tcl/lib -ltcl |
| 48 | |
| 49 | BCC = gcc |
| 50 | TCC = gcc -ansi -g $(CFLAGS) |
| 51 | NAWK = awk |
| 52 | AR = ar cr |
| 53 | RANLIB = ranlib |
| 54 | THREADLIB = -lpthread -ldl |
| 55 | include $(TOP)/main.mk |
| 56 | ######################################################## |
| 57 | } |
| 58 | |
| 59 | array set ::Configs { |
| 60 | "Default" { |
| 61 | -O2 |
| 62 | } |
dan | 5608973 | 2011-04-06 12:37:09 +0000 | [diff] [blame] | 63 | "Ftrapv" { |
| 64 | -O2 -ftrapv |
| 65 | -DSQLITE_MAX_ATTACHED=55 |
| 66 | -DSQLITE_TCL_DEFAULT_FULLMUTEX=1 |
| 67 | } |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 68 | "Unlock-Notify" { |
| 69 | -O2 |
| 70 | -DSQLITE_ENABLE_UNLOCK_NOTIFY |
| 71 | -DSQLITE_THREADSAFE |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 72 | -DSQLITE_TCL_DEFAULT_FULLMUTEX=1 |
| 73 | } |
| 74 | "Secure-Delete" { |
| 75 | -O2 |
| 76 | -DSQLITE_SECURE_DELETE=1 |
| 77 | -DSQLITE_SOUNDEX=1 |
| 78 | } |
| 79 | "Update-Delete-Limit" { |
| 80 | -O2 |
| 81 | -DSQLITE_DEFAULT_FILE_FORMAT=4 |
| 82 | -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 |
| 83 | } |
dan | b136e90 | 2012-12-10 10:22:48 +0000 | [diff] [blame] | 84 | "Check-Symbols" { |
| 85 | -DSQLITE_MEMDEBUG=1 |
| 86 | -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 |
| 87 | -DSQLITE_ENABLE_FTS3=1 |
| 88 | -DSQLITE_ENABLE_RTREE=1 |
| 89 | -DSQLITE_ENABLE_MEMSYS5=1 |
| 90 | -DSQLITE_ENABLE_MEMSYS3=1 |
| 91 | -DSQLITE_ENABLE_COLUMN_METADATA=1 |
| 92 | -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 |
| 93 | -DSQLITE_SECURE_DELETE=1 |
| 94 | -DSQLITE_SOUNDEX=1 |
| 95 | -DSQLITE_ENABLE_ATOMIC_WRITE=1 |
| 96 | -DSQLITE_ENABLE_IOTRACE=1 |
| 97 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 |
| 98 | -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1 |
| 99 | } |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 100 | "Debug-One" { |
| 101 | -O2 |
| 102 | -DSQLITE_DEBUG=1 |
| 103 | -DSQLITE_MEMDEBUG=1 |
| 104 | -DSQLITE_MUTEX_NOOP=1 |
| 105 | -DSQLITE_TCL_DEFAULT_FULLMUTEX=1 |
| 106 | -DSQLITE_ENABLE_FTS3=1 |
| 107 | -DSQLITE_ENABLE_RTREE=1 |
| 108 | -DSQLITE_ENABLE_MEMSYS5=1 |
| 109 | -DSQLITE_ENABLE_MEMSYS3=1 |
| 110 | -DSQLITE_ENABLE_COLUMN_METADATA=1 |
| 111 | } |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 112 | "Device-One" { |
| 113 | -O2 |
| 114 | -DSQLITE_DEBUG=1 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 115 | -DSQLITE_DEFAULT_AUTOVACUUM=1 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 116 | -DSQLITE_DEFAULT_CACHE_SIZE=64 |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 117 | -DSQLITE_DEFAULT_PAGE_SIZE=1024 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 118 | -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32 |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 119 | -DSQLITE_DISABLE_LFS=1 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 120 | -DSQLITE_ENABLE_ATOMIC_WRITE=1 |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 121 | -DSQLITE_ENABLE_IOTRACE=1 |
| 122 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 |
| 123 | -DSQLITE_MAX_PAGE_SIZE=4096 |
| 124 | -DSQLITE_OMIT_LOAD_EXTENSION=1 |
| 125 | -DSQLITE_OMIT_PROGRESS_CALLBACK=1 |
| 126 | -DSQLITE_OMIT_VIRTUALTABLE=1 |
| 127 | -DSQLITE_TEMP_STORE=3 |
| 128 | } |
| 129 | "Device-Two" { |
| 130 | -DSQLITE_4_BYTE_ALIGNED_MALLOC=1 |
| 131 | -DSQLITE_DEFAULT_AUTOVACUUM=1 |
| 132 | -DSQLITE_DEFAULT_CACHE_SIZE=1000 |
| 133 | -DSQLITE_DEFAULT_LOCKING_MODE=0 |
| 134 | -DSQLITE_DEFAULT_PAGE_SIZE=1024 |
| 135 | -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000 |
| 136 | -DSQLITE_DISABLE_LFS=1 |
| 137 | -DSQLITE_ENABLE_FTS3=1 |
| 138 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 |
| 139 | -DSQLITE_ENABLE_RTREE=1 |
| 140 | -DSQLITE_MAX_COMPOUND_SELECT=50 |
| 141 | -DSQLITE_MAX_PAGE_SIZE=32768 |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 142 | -DSQLITE_OMIT_TRACE=1 |
| 143 | -DSQLITE_TEMP_STORE=3 |
| 144 | -DSQLITE_THREADSAFE=2 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 145 | } |
| 146 | "Locking-Style" { |
| 147 | -O2 |
| 148 | -DSQLITE_ENABLE_LOCKING_STYLE=1 |
| 149 | } |
| 150 | "OS-X" { |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 151 | -DSQLITE_OMIT_LOAD_EXTENSION=1 |
| 152 | -DSQLITE_DEFAULT_MEMSTATUS=0 |
| 153 | -DSQLITE_THREADSAFE=2 |
| 154 | -DSQLITE_OS_UNIX=1 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 155 | -DSQLITE_ENABLE_LOCKING_STYLE=1 |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 156 | -DUSE_PREAD=1 |
| 157 | -DSQLITE_ENABLE_RTREE=1 |
| 158 | -DSQLITE_ENABLE_FTS3=1 |
| 159 | -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 |
| 160 | -DSQLITE_DEFAULT_CACHE_SIZE=1000 |
| 161 | -DSQLITE_MAX_LENGTH=2147483645 |
| 162 | -DSQLITE_MAX_VARIABLE_NUMBER=500000 |
| 163 | -DSQLITE_DEBUG=1 |
| 164 | -DSQLITE_PREFER_PROXY_LOCKING=1 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 165 | } |
| 166 | "Extra-Robustness" { |
| 167 | -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1 |
dan | 5608973 | 2011-04-06 12:37:09 +0000 | [diff] [blame] | 168 | -DSQLITE_MAX_ATTACHED=62 |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 169 | } |
dan | 4dc3d73 | 2012-08-20 17:24:48 +0000 | [diff] [blame] | 170 | "Devkit" { |
| 171 | -DSQLITE_DEFAULT_FILE_FORMAT=4 |
| 172 | -DSQLITE_MAX_ATTACHED=30 |
| 173 | -DSQLITE_ENABLE_COLUMN_METADATA |
| 174 | -DSQLITE_ENABLE_FTS4 |
| 175 | -DSQLITE_ENABLE_FTS4_PARENTHESIS |
| 176 | -DSQLITE_DISABLE_FTS4_DEFERRED |
| 177 | -DSQLITE_ENABLE_RTREE |
| 178 | } |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | array set ::Platforms { |
| 182 | Linux-x86_64 { |
dan | b136e90 | 2012-12-10 10:22:48 +0000 | [diff] [blame] | 183 | "Check-Symbols" checksymbols |
| 184 | "Debug-One" test |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 185 | "Secure-Delete" test |
| 186 | "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test" |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 187 | "Update-Delete-Limit" test |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 188 | "Extra-Robustness" test |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 189 | "Device-Two" test |
dan | 5608973 | 2011-04-06 12:37:09 +0000 | [diff] [blame] | 190 | "Ftrapv" test |
dan | d38bc1b | 2010-09-13 12:15:36 +0000 | [diff] [blame] | 191 | "Default" "threadtest test" |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 192 | "Device-One" fulltest |
| 193 | } |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 194 | Linux-i686 { |
dan | 4dc3d73 | 2012-08-20 17:24:48 +0000 | [diff] [blame] | 195 | "Devkit" test |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 196 | "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test" |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 197 | "Device-One" test |
dan | d38bc1b | 2010-09-13 12:15:36 +0000 | [diff] [blame] | 198 | "Device-Two" test |
| 199 | "Default" "threadtest fulltest" |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 200 | } |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 201 | Darwin-i386 { |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 202 | "Locking-Style" test |
dan | d38bc1b | 2010-09-13 12:15:36 +0000 | [diff] [blame] | 203 | "OS-X" "threadtest fulltest" |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
dan | e7152dc | 2011-07-07 08:19:16 +0000 | [diff] [blame] | 207 | |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 208 | # End of configuration section. |
| 209 | ######################################################################### |
| 210 | ######################################################################### |
| 211 | |
| 212 | foreach {key value} [array get ::Platforms] { |
| 213 | foreach {v t} $value { |
| 214 | if {0==[info exists ::Configs($v)]} { |
| 215 | puts stderr "No such configuration: \"$v\"" |
| 216 | exit -1 |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | proc run_test_suite {name testtarget config} { |
| 222 | |
| 223 | # Tcl variable $opts is used to build up the value used to set the |
| 224 | # OPTS Makefile variable. Variable $cflags holds the value for |
| 225 | # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but |
| 226 | # CFLAGS is only passed to gcc. |
| 227 | # |
| 228 | set cflags "" |
| 229 | set opts "" |
| 230 | foreach arg $config { |
| 231 | if {[string match -D* $arg]} { |
| 232 | lappend opts $arg |
| 233 | } else { |
| 234 | lappend cflags $arg |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | set cflags [join $cflags " "] |
| 239 | set opts [join $opts " "] |
| 240 | append opts " -DSQLITE_NO_SYNC=1 -DHAVE_USLEEP" |
| 241 | |
| 242 | # Set the sub-directory to use. |
| 243 | # |
| 244 | set dir [string tolower [string map {- _ " " _} $name]] |
| 245 | |
| 246 | if {$::tcl_platform(platform)=="windows"} { |
| 247 | append opts " -DSQLITE_OS_WIN=1" |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 248 | } else { |
| 249 | append opts " -DSQLITE_OS_UNIX=1" |
| 250 | } |
| 251 | |
| 252 | # Run the test. |
| 253 | # |
| 254 | set makefile [file normalize $::MAKEFILE] |
| 255 | file mkdir $dir |
| 256 | puts -nonewline "Testing configuration \"$name\" (logfile=$dir/test.log)..." |
| 257 | flush stdout |
| 258 | |
| 259 | set makecmd [concat \ |
| 260 | [list exec make -C $dir -f $makefile clean] \ |
| 261 | $testtarget \ |
| 262 | [list CFLAGS=$cflags OPTS=$opts >& $dir/test.log] \ |
| 263 | ] |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 264 | |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 265 | set tm1 [clock seconds] |
| 266 | set rc [catch $makecmd] |
| 267 | set tm2 [clock seconds] |
| 268 | |
| 269 | set minutes [expr {($tm2-$tm1)/60}] |
| 270 | set seconds [expr {($tm2-$tm1)%60}] |
| 271 | puts -nonewline [format " (%d:%.2d) " $minutes $seconds] |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 272 | if {$rc} { |
dan | 1c22a18 | 2010-09-13 11:29:02 +0000 | [diff] [blame] | 273 | puts "FAILED." |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 274 | } else { |
| 275 | puts "Ok." |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | |
| 280 | # This proc processes the command line options passed to this script. |
| 281 | # Currently the only option supported is "-makefile", default |
| 282 | # "releasetest.mk". Set the ::MAKEFILE variable to the value of this |
| 283 | # option. |
| 284 | # |
| 285 | proc process_options {argv} { |
| 286 | set ::MAKEFILE releasetest.mk ;# Default value |
| 287 | set ::QUICK 0 ;# Default value |
| 288 | set platform $::tcl_platform(os)-$::tcl_platform(machine) |
| 289 | |
| 290 | for {set i 0} {$i < [llength $argv]} {incr i} { |
| 291 | switch -- [lindex $argv $i] { |
| 292 | -makefile { |
| 293 | incr i |
| 294 | set ::MAKEFILE [lindex $argv $i] |
| 295 | } |
| 296 | |
| 297 | -platform { |
| 298 | incr i |
| 299 | set platform [lindex $argv $i] |
| 300 | } |
| 301 | |
| 302 | -quick { |
| 303 | incr i |
| 304 | set ::QUICK [lindex $argv $i] |
| 305 | } |
| 306 | |
| 307 | default { |
| 308 | puts stderr "" |
| 309 | puts stderr [string trim $::USAGE_MESSAGE] |
| 310 | exit -1 |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | set ::MAKEFILE [file normalize $::MAKEFILE] |
| 316 | |
| 317 | if {0==[info exists ::Platforms($platform)]} { |
| 318 | puts "Unknown platform: $platform" |
| 319 | puts -nonewline "Set the -platform option to " |
| 320 | set print [list] |
| 321 | foreach p [array names ::Platforms] { |
| 322 | lappend print "\"$p\"" |
| 323 | } |
| 324 | lset print end "or [lindex $print end]" |
| 325 | puts "[join $print {, }]." |
| 326 | exit |
| 327 | } |
| 328 | |
| 329 | set ::CONFIGLIST $::Platforms($platform) |
| 330 | puts "Running the following configurations for $platform:" |
| 331 | puts " [string trim $::CONFIGLIST]" |
| 332 | } |
| 333 | |
| 334 | # Main routine. |
| 335 | # |
| 336 | proc main {argv} { |
| 337 | |
| 338 | # Process any command line options. |
| 339 | process_options $argv |
| 340 | |
| 341 | foreach {zConfig target} $::CONFIGLIST { |
| 342 | if {$::QUICK} {set target test} |
| 343 | set config_options $::Configs($zConfig) |
| 344 | |
| 345 | run_test_suite $zConfig $target $config_options |
| 346 | |
| 347 | # If the configuration included the SQLITE_DEBUG option, then remove |
| 348 | # it and run veryquick.test. If it did not include the SQLITE_DEBUG option |
| 349 | # add it and run veryquick.test. |
dan | b136e90 | 2012-12-10 10:22:48 +0000 | [diff] [blame] | 350 | if {$target!="checksymbols"} { |
| 351 | set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*] |
| 352 | if {$debug_idx < 0} { |
| 353 | run_test_suite "${zConfig}_debug" test [ |
| 354 | concat $config_options -DSQLITE_DEBUG=1 |
| 355 | ] |
| 356 | } else { |
| 357 | run_test_suite "${zConfig}_ndebug" test [ |
| 358 | lreplace $config_options $debug_idx $debug_idx |
| 359 | ] |
| 360 | } |
drh | 96110de | 2010-09-06 18:44:14 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | main $argv |