blob: dde3f039d64f91662469bb0d34a888183b996d65 [file] [log] [blame]
drhd477eee2014-12-23 19:40:51 +00001#!/usr/bin/tclsh
2#
drh96110de2010-09-06 18:44:14 +00003# Documentation for this script. This may be output to stderr
4# if the script is invoked incorrectly. See the [process_options]
5# proc below.
6#
7set ::USAGE_MESSAGE {
8This Tcl script is used to test the various configurations required
mistachkin72840562014-12-23 20:22:57 +00009before releasing a new version. Supported command line options (all
drh96110de2010-09-06 18:44:14 +000010optional) are:
11
drhd477eee2014-12-23 19:40:51 +000012 --srcdir TOP-OF-SQLITE-TREE (see below)
13 --platform PLATFORM (see below)
14 --config CONFIGNAME (Run only CONFIGNAME)
15 --quick (Run "veryquick.test" only)
drh5bfff9d2015-01-08 01:05:42 +000016 --veryquick (Run "make smoketest" only)
mistachkin00eb70d2015-04-04 00:02:07 +000017 --msvc (Use MSVC as the compiler)
drhd477eee2014-12-23 19:40:51 +000018 --buildonly (Just build testfixture - do not run)
mistachkin72840562014-12-23 20:22:57 +000019 --dryrun (Print what would have happened)
drhd477eee2014-12-23 19:40:51 +000020 --info (Show diagnostic info)
drh0ef84d02015-04-24 17:50:37 +000021 --with-tcl=DIR (Use TCL build at DIR)
drh96110de2010-09-06 18:44:14 +000022
drhd477eee2014-12-23 19:40:51 +000023The default value for --srcdir is the parent of the directory holding
24this script.
drh96110de2010-09-06 18:44:14 +000025
drhd477eee2014-12-23 19:40:51 +000026The script determines the default value for --platform using the
mistachkin00eb70d2015-04-04 00:02:07 +000027$tcl_platform(os) and $tcl_platform(machine) variables. Supported
28platforms are "Linux-x86", "Linux-x86_64", "Darwin-i386",
29"Darwin-x86_64", "Windows NT-intel", and "Windows NT-amd64".
drh96110de2010-09-06 18:44:14 +000030
drhd477eee2014-12-23 19:40:51 +000031Every test begins with a fresh run of the configure script at the top
32of the SQLite source tree.
drh96110de2010-09-06 18:44:14 +000033}
34
drh6aed1c42015-01-10 15:21:26 +000035# Omit comments (text between # and \n) in a long multi-line string.
36#
37proc strip_comments {in} {
38 regsub -all {#[^\n]*\n} $in {} out
39 return $out
40}
41
42array set ::Configs [strip_comments {
drh96110de2010-09-06 18:44:14 +000043 "Default" {
44 -O2
drhedb31cd2015-01-08 02:15:11 +000045 --disable-amalgamation --disable-shared
drh96110de2010-09-06 18:44:14 +000046 }
drh4081d5d2015-01-01 23:02:01 +000047 "Sanitize" {
drh149735d2015-01-01 19:53:10 +000048 CC=clang -fsanitize=undefined
drh4081d5d2015-01-01 23:02:01 +000049 -DSQLITE_ENABLE_STAT4
dan56089732011-04-06 12:37:09 +000050 }
drh0ede9eb2015-01-10 16:49:23 +000051 "Have-Not" {
52 # The "Have-Not" configuration sets all possible -UHAVE_feature options
53 # in order to verify that the code works even on platforms that lack
54 # these support services.
55 -DHAVE_FDATASYNC=0
56 -DHAVE_GMTIME_R=0
drh8567d402015-01-10 18:22:06 +000057 -DHAVE_ISNAN=0
drh0ede9eb2015-01-10 16:49:23 +000058 -DHAVE_LOCALTIME_R=0
59 -DHAVE_LOCALTIME_S=0
60 -DHAVE_MALLOC_USABLE_SIZE=0
61 -DHAVE_STRCHRNUL=0
62 -DHAVE_USLEEP=0
63 -DHAVE_UTIME=0
drh96110de2010-09-06 18:44:14 +000064 }
65 "Unlock-Notify" {
66 -O2
67 -DSQLITE_ENABLE_UNLOCK_NOTIFY
68 -DSQLITE_THREADSAFE
drh96110de2010-09-06 18:44:14 +000069 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
70 }
71 "Secure-Delete" {
72 -O2
73 -DSQLITE_SECURE_DELETE=1
74 -DSQLITE_SOUNDEX=1
75 }
76 "Update-Delete-Limit" {
77 -O2
78 -DSQLITE_DEFAULT_FILE_FORMAT=4
79 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
drh1a803842015-01-09 20:00:21 +000080 -DSQLITE_ENABLE_STMT_SCANSTATUS
drh96110de2010-09-06 18:44:14 +000081 }
danb136e902012-12-10 10:22:48 +000082 "Check-Symbols" {
83 -DSQLITE_MEMDEBUG=1
84 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
85 -DSQLITE_ENABLE_FTS3=1
86 -DSQLITE_ENABLE_RTREE=1
87 -DSQLITE_ENABLE_MEMSYS5=1
88 -DSQLITE_ENABLE_MEMSYS3=1
89 -DSQLITE_ENABLE_COLUMN_METADATA=1
90 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
91 -DSQLITE_SECURE_DELETE=1
92 -DSQLITE_SOUNDEX=1
93 -DSQLITE_ENABLE_ATOMIC_WRITE=1
danb136e902012-12-10 10:22:48 +000094 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
95 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
drh4081d5d2015-01-01 23:02:01 +000096 -DSQLITE_ENABLE_STAT4
drh1a803842015-01-09 20:00:21 +000097 -DSQLITE_ENABLE_STMT_SCANSTATUS
danb136e902012-12-10 10:22:48 +000098 }
drh96110de2010-09-06 18:44:14 +000099 "Debug-One" {
drh8f455552015-01-07 14:41:18 +0000100 --disable-shared
drh96110de2010-09-06 18:44:14 +0000101 -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
drh4081d5d2015-01-01 23:02:01 +0000111 -DSQLITE_ENABLE_STAT4
drhedb31cd2015-01-08 02:15:11 +0000112 -DSQLITE_MAX_ATTACHED=125
drh96110de2010-09-06 18:44:14 +0000113 }
drhf3320712015-04-25 13:39:29 +0000114 "Fast-One" {
115 -O6
116 -DSQLITE_ENABLE_FTS4=1
117 -DSQLITE_ENABLE_RTREE=1
118 -DSQLITE_ENABLE_STAT4
drhcfb8f8d2015-07-23 20:44:49 +0000119 -DSQLITE_ENABLE_RBU
drh96110de2010-09-06 18:44:14 +0000120 -DSQLITE_MAX_ATTACHED=125
121 }
drh96110de2010-09-06 18:44:14 +0000122 "Device-One" {
123 -O2
124 -DSQLITE_DEBUG=1
drh96110de2010-09-06 18:44:14 +0000125 -DSQLITE_DEFAULT_AUTOVACUUM=1
drh96110de2010-09-06 18:44:14 +0000126 -DSQLITE_DEFAULT_CACHE_SIZE=64
dan1c22a182010-09-13 11:29:02 +0000127 -DSQLITE_DEFAULT_PAGE_SIZE=1024
drh96110de2010-09-06 18:44:14 +0000128 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
dan1c22a182010-09-13 11:29:02 +0000129 -DSQLITE_DISABLE_LFS=1
drh96110de2010-09-06 18:44:14 +0000130 -DSQLITE_ENABLE_ATOMIC_WRITE=1
dan1c22a182010-09-13 11:29:02 +0000131 -DSQLITE_ENABLE_IOTRACE=1
132 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
133 -DSQLITE_MAX_PAGE_SIZE=4096
134 -DSQLITE_OMIT_LOAD_EXTENSION=1
135 -DSQLITE_OMIT_PROGRESS_CALLBACK=1
136 -DSQLITE_OMIT_VIRTUALTABLE=1
137 -DSQLITE_TEMP_STORE=3
138 }
139 "Device-Two" {
140 -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
141 -DSQLITE_DEFAULT_AUTOVACUUM=1
142 -DSQLITE_DEFAULT_CACHE_SIZE=1000
143 -DSQLITE_DEFAULT_LOCKING_MODE=0
144 -DSQLITE_DEFAULT_PAGE_SIZE=1024
145 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000
146 -DSQLITE_DISABLE_LFS=1
147 -DSQLITE_ENABLE_FTS3=1
148 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
149 -DSQLITE_ENABLE_RTREE=1
150 -DSQLITE_MAX_COMPOUND_SELECT=50
151 -DSQLITE_MAX_PAGE_SIZE=32768
dan1c22a182010-09-13 11:29:02 +0000152 -DSQLITE_OMIT_TRACE=1
153 -DSQLITE_TEMP_STORE=3
154 -DSQLITE_THREADSAFE=2
drh96110de2010-09-06 18:44:14 +0000155 }
156 "Locking-Style" {
157 -O2
158 -DSQLITE_ENABLE_LOCKING_STYLE=1
159 }
160 "OS-X" {
drh149735d2015-01-01 19:53:10 +0000161 -O1 # Avoid a compiler bug in gcc 4.2.1 build 5658
dan1c22a182010-09-13 11:29:02 +0000162 -DSQLITE_OMIT_LOAD_EXTENSION=1
163 -DSQLITE_DEFAULT_MEMSTATUS=0
164 -DSQLITE_THREADSAFE=2
165 -DSQLITE_OS_UNIX=1
drh96110de2010-09-06 18:44:14 +0000166 -DSQLITE_ENABLE_LOCKING_STYLE=1
dan1c22a182010-09-13 11:29:02 +0000167 -DUSE_PREAD=1
168 -DSQLITE_ENABLE_RTREE=1
169 -DSQLITE_ENABLE_FTS3=1
170 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
171 -DSQLITE_DEFAULT_CACHE_SIZE=1000
172 -DSQLITE_MAX_LENGTH=2147483645
173 -DSQLITE_MAX_VARIABLE_NUMBER=500000
mistachkin72840562014-12-23 20:22:57 +0000174 -DSQLITE_DEBUG=1
dan1c22a182010-09-13 11:29:02 +0000175 -DSQLITE_PREFER_PROXY_LOCKING=1
drhc67d6502014-12-31 15:14:29 +0000176 -DSQLITE_ENABLE_API_ARMOR=1
drh96110de2010-09-06 18:44:14 +0000177 }
178 "Extra-Robustness" {
179 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
dan56089732011-04-06 12:37:09 +0000180 -DSQLITE_MAX_ATTACHED=62
drh96110de2010-09-06 18:44:14 +0000181 }
dan4dc3d732012-08-20 17:24:48 +0000182 "Devkit" {
183 -DSQLITE_DEFAULT_FILE_FORMAT=4
184 -DSQLITE_MAX_ATTACHED=30
185 -DSQLITE_ENABLE_COLUMN_METADATA
186 -DSQLITE_ENABLE_FTS4
187 -DSQLITE_ENABLE_FTS4_PARENTHESIS
188 -DSQLITE_DISABLE_FTS4_DEFERRED
189 -DSQLITE_ENABLE_RTREE
190 }
dand79d27a2014-08-12 14:06:13 +0000191 "No-lookaside" {
192 -DSQLITE_TEST_REALLOC_STRESS=1
193 -DSQLITE_OMIT_LOOKASIDE=1
194 -DHAVE_USLEEP=1
195 }
drh8a2a0f52015-01-07 14:09:41 +0000196 "Valgrind" {
197 -DSQLITE_ENABLE_STAT4
198 -DSQLITE_ENABLE_FTS4
199 -DSQLITE_ENABLE_RTREE
200 }
drh96110de2010-09-06 18:44:14 +0000201
drh6aed1c42015-01-10 15:21:26 +0000202 # The next group of configurations are used only by the
203 # Failure-Detection platform. They are all the same, but we need
204 # different names for them all so that they results appear in separate
205 # subdirectories.
206 #
drhedb31cd2015-01-08 02:15:11 +0000207 Fail0 {-O0}
208 Fail2 {-O0}
209 Fail3 {-O0}
drhdb6bafa2015-01-09 21:54:58 +0000210 Fail4 {-O0}
drh8ea5eca2015-04-24 16:53:03 +0000211 FuzzFail1 {-O0}
212 FuzzFail2 {-O0}
drh6aed1c42015-01-10 15:21:26 +0000213}]
drh96110de2010-09-06 18:44:14 +0000214
drh6aed1c42015-01-10 15:21:26 +0000215array set ::Platforms [strip_comments {
drh96110de2010-09-06 18:44:14 +0000216 Linux-x86_64 {
danb136e902012-12-10 10:22:48 +0000217 "Check-Symbols" checksymbols
drhbd41d562014-12-30 20:40:32 +0000218 "Debug-One" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000219 "Have-Not" test
drh96110de2010-09-06 18:44:14 +0000220 "Secure-Delete" test
221 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
drh96110de2010-09-06 18:44:14 +0000222 "Update-Delete-Limit" test
drh96110de2010-09-06 18:44:14 +0000223 "Extra-Robustness" test
dan1c22a182010-09-13 11:29:02 +0000224 "Device-Two" test
dand79d27a2014-08-12 14:06:13 +0000225 "No-lookaside" test
dan5d510d42014-10-15 15:28:27 +0000226 "Devkit" test
drh8a2a0f52015-01-07 14:09:41 +0000227 "Sanitize" {QUICKTEST_OMIT=func4.test,nan.test test}
drh3da29a12015-05-27 19:35:08 +0000228 "Fast-One" fuzztest
drh8a2a0f52015-01-07 14:09:41 +0000229 "Valgrind" valgrindtest
dan5d510d42014-10-15 15:28:27 +0000230 "Default" "threadtest fulltest"
drh96110de2010-09-06 18:44:14 +0000231 "Device-One" fulltest
232 }
dan1c22a182010-09-13 11:29:02 +0000233 Linux-i686 {
dan4dc3d732012-08-20 17:24:48 +0000234 "Devkit" test
drh0ede9eb2015-01-10 16:49:23 +0000235 "Have-Not" test
dan1c22a182010-09-13 11:29:02 +0000236 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
dan1c22a182010-09-13 11:29:02 +0000237 "Device-One" test
dand38bc1b2010-09-13 12:15:36 +0000238 "Device-Two" test
239 "Default" "threadtest fulltest"
dan1c22a182010-09-13 11:29:02 +0000240 }
drh96110de2010-09-06 18:44:14 +0000241 Darwin-i386 {
drhbd41d562014-12-30 20:40:32 +0000242 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000243 "Have-Not" test
dand38bc1b2010-09-13 12:15:36 +0000244 "OS-X" "threadtest fulltest"
drh96110de2010-09-06 18:44:14 +0000245 }
drhbcbac682014-12-31 18:55:09 +0000246 Darwin-x86_64 {
247 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000248 "Have-Not" test
drhbcbac682014-12-31 18:55:09 +0000249 "OS-X" "threadtest fulltest"
250 }
mistachkin72840562014-12-23 20:22:57 +0000251 "Windows NT-intel" {
drhbd41d562014-12-30 20:40:32 +0000252 "Default" "mptest fulltestonly"
drh0ede9eb2015-01-10 16:49:23 +0000253 "Have-Not" test
mistachkin72840562014-12-23 20:22:57 +0000254 }
mistachkin00eb70d2015-04-04 00:02:07 +0000255 "Windows NT-amd64" {
256 "Default" "mptest fulltestonly"
257 "Have-Not" test
258 }
drh6aed1c42015-01-10 15:21:26 +0000259
260 # The Failure-Detection platform runs various tests that deliberately
261 # fail. This is used as a test of this script to verify that this script
262 # correctly identifies failures.
263 #
drhedb31cd2015-01-08 02:15:11 +0000264 Failure-Detection {
265 Fail0 "TEST_FAILURE=0 test"
266 Sanitize "TEST_FAILURE=1 test"
267 Fail2 "TEST_FAILURE=2 valgrindtest"
268 Fail3 "TEST_FAILURE=3 valgrindtest"
drhdb6bafa2015-01-09 21:54:58 +0000269 Fail4 "TEST_FAILURE=4 test"
drh8ea5eca2015-04-24 16:53:03 +0000270 FuzzFail1 "TEST_FAILURE=5 test"
271 FuzzFail2 "TEST_FAILURE=5 valgrindtest"
drhedb31cd2015-01-08 02:15:11 +0000272 }
drh6aed1c42015-01-10 15:21:26 +0000273}]
drh96110de2010-09-06 18:44:14 +0000274
dane7152dc2011-07-07 08:19:16 +0000275
drh96110de2010-09-06 18:44:14 +0000276# End of configuration section.
277#########################################################################
278#########################################################################
279
280foreach {key value} [array get ::Platforms] {
281 foreach {v t} $value {
282 if {0==[info exists ::Configs($v)]} {
283 puts stderr "No such configuration: \"$v\""
284 exit -1
285 }
286 }
287}
288
drhe31dc592015-08-14 12:53:37 +0000289# Output log
290#
291set LOG [open releasetest-out.txt w]
292proc PUTS {args} {
293 if {[llength $args]==2} {
294 puts [lindex $args 0] [lindex $args 1]
drhb1031f02015-09-10 15:20:49 +0000295 puts $::LOG [lindex $args 1]
drhe31dc592015-08-14 12:53:37 +0000296 } else {
297 puts [lindex $args 0]
298 puts $::LOG [lindex $args 0]
299 }
drhd9dfeb52015-09-16 17:46:11 +0000300 flush $::LOG
drhe31dc592015-08-14 12:53:37 +0000301}
302puts $LOG "$argv0 $argv"
303set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]
304puts $LOG "start-time: $tm0 UTC"
305
drh277b4e42014-12-29 02:55:58 +0000306# Open the file $logfile and look for a report on the number of errors
307# and the number of test cases run. Add these values to the global
308# $::NERRCASE and $::NTESTCASE variables.
309#
310# If any errors occur, then write into $errmsgVar the text of an appropriate
311# one-line error message to show on the output.
312#
313proc count_tests_and_errors {logfile rcVar errmsgVar} {
drhcb281a92014-12-29 19:54:10 +0000314 if {$::DRYRUN} return
drh277b4e42014-12-29 02:55:58 +0000315 upvar 1 $rcVar rc $errmsgVar errmsg
316 set fd [open $logfile rb]
317 set seen 0
318 while {![eof $fd]} {
319 set line [gets $fd]
drhbd41d562014-12-30 20:40:32 +0000320 if {[regexp {(\d+) errors out of (\d+) tests} $line all nerr ntest]} {
drh277b4e42014-12-29 02:55:58 +0000321 incr ::NERRCASE $nerr
322 incr ::NTESTCASE $ntest
323 set seen 1
324 if {$nerr>0} {
325 set rc 1
326 set errmsg $line
327 }
drh277b4e42014-12-29 02:55:58 +0000328 }
drh4081d5d2015-01-01 23:02:01 +0000329 if {[regexp {runtime error: +(.*)} $line all msg]} {
drh36c25f72015-07-29 20:24:39 +0000330 # skip over "value is outside range" errors
331 if {[regexp {value .* is outside the range of representable} $line]} {
332 # noop
333 } else {
334 incr ::NERRCASE
335 if {$rc==0} {
336 set rc 1
337 set errmsg $msg
338 }
drh4081d5d2015-01-01 23:02:01 +0000339 }
340 }
mistachkin00eb70d2015-04-04 00:02:07 +0000341 if {[regexp {fatal error +(.*)} $line all msg]} {
342 incr ::NERRCASE
343 if {$rc==0} {
344 set rc 1
345 set errmsg $msg
346 }
347 }
drh8a2a0f52015-01-07 14:09:41 +0000348 if {[regexp {ERROR SUMMARY: (\d+) errors.*} $line all cnt] && $cnt>0} {
349 incr ::NERRCASE
350 if {$rc==0} {
351 set rc 1
352 set errmsg $all
353 }
354 }
drh5bfff9d2015-01-08 01:05:42 +0000355 if {[regexp {^VERSION: 3\.\d+.\d+} $line]} {
356 set v [string range $line 9 end]
357 if {$::SQLITE_VERSION eq ""} {
358 set ::SQLITE_VERSION $v
359 } elseif {$::SQLITE_VERSION ne $v} {
360 set rc 1
361 set errmsg "version conflict: {$::SQLITE_VERSION} vs. {$v}"
362 }
363 }
drh277b4e42014-12-29 02:55:58 +0000364 }
365 close $fd
mistachkin00eb70d2015-04-04 00:02:07 +0000366 if {$::BUILDONLY} {
367 if {$rc==0} {
368 set errmsg "Build complete"
369 } else {
370 set errmsg "Build failed"
371 }
372 } elseif {!$seen} {
drh277b4e42014-12-29 02:55:58 +0000373 set rc 1
374 set errmsg "Test did not complete"
drhdb6bafa2015-01-09 21:54:58 +0000375 if {[file readable core]} {
376 append errmsg " - core file exists"
377 }
drh277b4e42014-12-29 02:55:58 +0000378 }
379}
380
drh96110de2010-09-06 18:44:14 +0000381proc run_test_suite {name testtarget config} {
mistachkin72840562014-12-23 20:22:57 +0000382 # Tcl variable $opts is used to build up the value used to set the
drh96110de2010-09-06 18:44:14 +0000383 # OPTS Makefile variable. Variable $cflags holds the value for
384 # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
385 # CFLAGS is only passed to gcc.
386 #
mistachkin00eb70d2015-04-04 00:02:07 +0000387 set cflags [expr {$::MSVC ? "-Zi" : "-g"}]
drh96110de2010-09-06 18:44:14 +0000388 set opts ""
drha780d8d2015-01-03 18:59:17 +0000389 set title ${name}($testtarget)
drh0ef84d02015-04-24 17:50:37 +0000390 set configOpts $::WITHTCL
drha780d8d2015-01-03 18:59:17 +0000391
drh149735d2015-01-01 19:53:10 +0000392 regsub -all {#[^\n]*\n} $config \n config
drh96110de2010-09-06 18:44:14 +0000393 foreach arg $config {
drh0ede9eb2015-01-10 16:49:23 +0000394 if {[regexp {^-[UD]} $arg]} {
drh96110de2010-09-06 18:44:14 +0000395 lappend opts $arg
drh0ede9eb2015-01-10 16:49:23 +0000396 } elseif {[regexp {^[A-Z]+=} $arg]} {
drh149735d2015-01-01 19:53:10 +0000397 lappend testtarget $arg
drh8f455552015-01-07 14:41:18 +0000398 } elseif {[regexp {^--(enable|disable)-} $arg]} {
399 lappend configOpts $arg
drh96110de2010-09-06 18:44:14 +0000400 } else {
401 lappend cflags $arg
402 }
403 }
404
405 set cflags [join $cflags " "]
406 set opts [join $opts " "]
mistachkin00eb70d2015-04-04 00:02:07 +0000407 append opts " -DSQLITE_NO_SYNC=1"
408
409 # Some configurations already set HAVE_USLEEP; in that case, skip it.
410 #
411 if {![regexp { -DHAVE_USLEEP$} $opts]
412 && ![regexp { -DHAVE_USLEEP[ =]+} $opts]} {
413 append opts " -DHAVE_USLEEP=1"
414 }
drh96110de2010-09-06 18:44:14 +0000415
416 # Set the sub-directory to use.
417 #
418 set dir [string tolower [string map {- _ " " _} $name]]
419
420 if {$::tcl_platform(platform)=="windows"} {
421 append opts " -DSQLITE_OS_WIN=1"
drh96110de2010-09-06 18:44:14 +0000422 } else {
423 append opts " -DSQLITE_OS_UNIX=1"
424 }
425
drh8f455552015-01-07 14:41:18 +0000426 if {!$::TRACE} {
drhe43ff922014-12-23 20:41:13 +0000427 set n [string length $title]
drhe31dc592015-08-14 12:53:37 +0000428 PUTS -nonewline "${title}[string repeat . [expr {63-$n}]]"
drhd477eee2014-12-23 19:40:51 +0000429 flush stdout
430 }
drh96110de2010-09-06 18:44:14 +0000431
drh8f455552015-01-07 14:41:18 +0000432 set rc 0
drhd477eee2014-12-23 19:40:51 +0000433 set tm1 [clock seconds]
434 set origdir [pwd]
drh8f455552015-01-07 14:41:18 +0000435 trace_cmd file mkdir $dir
436 trace_cmd cd $dir
drh277b4e42014-12-29 02:55:58 +0000437 set errmsg {}
drhdb6bafa2015-01-09 21:54:58 +0000438 catch {file delete core}
drh8f455552015-01-07 14:41:18 +0000439 set rc [catch [configureCommand $configOpts]]
drhd477eee2014-12-23 19:40:51 +0000440 if {!$rc} {
mistachkin72840562014-12-23 20:22:57 +0000441 set rc [catch [makeCommand $testtarget $cflags $opts]]
drh277b4e42014-12-29 02:55:58 +0000442 count_tests_and_errors test.log rc errmsg
drhd477eee2014-12-23 19:40:51 +0000443 }
drh8f455552015-01-07 14:41:18 +0000444 trace_cmd cd $origdir
dan1c22a182010-09-13 11:29:02 +0000445 set tm2 [clock seconds]
446
drh8f455552015-01-07 14:41:18 +0000447 if {!$::TRACE} {
drh7203aed2015-01-01 18:54:23 +0000448 set hours [expr {($tm2-$tm1)/3600}]
drhe43ff922014-12-23 20:41:13 +0000449 set minutes [expr {(($tm2-$tm1)/60)%60}]
drhd477eee2014-12-23 19:40:51 +0000450 set seconds [expr {($tm2-$tm1)%60}]
drhe43ff922014-12-23 20:41:13 +0000451 set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
drhd477eee2014-12-23 19:40:51 +0000452 if {$rc} {
drhe31dc592015-08-14 12:53:37 +0000453 PUTS " FAIL $tm"
drhd477eee2014-12-23 19:40:51 +0000454 incr ::NERR
455 } else {
drhe31dc592015-08-14 12:53:37 +0000456 PUTS " Ok $tm"
drhd477eee2014-12-23 19:40:51 +0000457 }
drhe31dc592015-08-14 12:53:37 +0000458 if {$errmsg!=""} {PUTS " $errmsg"}
drhd477eee2014-12-23 19:40:51 +0000459 }
460}
461
mistachkin72840562014-12-23 20:22:57 +0000462# The following procedure returns the "configure" command to be exectued for
463# the current platform, which may be Windows (via MinGW, etc).
464#
drh8f455552015-01-07 14:41:18 +0000465proc configureCommand {opts} {
mistachkin00eb70d2015-04-04 00:02:07 +0000466 if {$::MSVC} return [list]; # This is not needed for MSVC.
drh8f455552015-01-07 14:41:18 +0000467 set result [list trace_cmd exec]
mistachkin72840562014-12-23 20:22:57 +0000468 if {$::tcl_platform(platform)=="windows"} {
469 lappend result sh
470 }
drh8f455552015-01-07 14:41:18 +0000471 lappend result $::SRCDIR/configure --enable-load-extension
472 foreach x $opts {lappend result $x}
473 lappend result >& test.log
mistachkin72840562014-12-23 20:22:57 +0000474}
475
476# The following procedure returns the "make" command to be executed for the
477# specified targets, compiler flags, and options.
478#
479proc makeCommand { targets cflags opts } {
mistachkin00eb70d2015-04-04 00:02:07 +0000480 set result [list trace_cmd exec]
481 if {$::MSVC} {
482 set nmakeDir [file nativename $::SRCDIR]
483 set nmakeFile [file join $nmakeDir Makefile.msc]
484 lappend result nmake /f $nmakeFile TOP=$nmakeDir clean
485 } else {
486 lappend result make clean
487 }
mistachkin72840562014-12-23 20:22:57 +0000488 foreach target $targets {
489 lappend result $target
490 }
491 lappend result CFLAGS=$cflags OPTS=$opts >>& test.log
492}
493
drh8f455552015-01-07 14:41:18 +0000494# The following procedure prints its arguments if ::TRACE is true.
495# And it executes the command of its arguments in the calling context
496# if ::DRYRUN is false.
drhd477eee2014-12-23 19:40:51 +0000497#
drh8f455552015-01-07 14:41:18 +0000498proc trace_cmd {args} {
499 if {$::TRACE} {
drhe31dc592015-08-14 12:53:37 +0000500 PUTS $args
drh8f455552015-01-07 14:41:18 +0000501 }
502 if {!$::DRYRUN} {
drhd477eee2014-12-23 19:40:51 +0000503 uplevel 1 $args
drh96110de2010-09-06 18:44:14 +0000504 }
505}
506
507
508# This proc processes the command line options passed to this script.
509# Currently the only option supported is "-makefile", default
510# "releasetest.mk". Set the ::MAKEFILE variable to the value of this
511# option.
512#
513proc process_options {argv} {
drhd477eee2014-12-23 19:40:51 +0000514 set ::SRCDIR [file normalize [file dirname [file dirname $::argv0]]]
515 set ::QUICK 0
mistachkin00eb70d2015-04-04 00:02:07 +0000516 set ::MSVC 0
drhd477eee2014-12-23 19:40:51 +0000517 set ::BUILDONLY 0
518 set ::DRYRUN 0
519 set ::EXEC exec
drh8f455552015-01-07 14:41:18 +0000520 set ::TRACE 0
drh0ef84d02015-04-24 17:50:37 +0000521 set ::WITHTCL {}
drh2eeb7ae2014-10-10 17:44:03 +0000522 set config {}
drh96110de2010-09-06 18:44:14 +0000523 set platform $::tcl_platform(os)-$::tcl_platform(machine)
524
525 for {set i 0} {$i < [llength $argv]} {incr i} {
drhd477eee2014-12-23 19:40:51 +0000526 set x [lindex $argv $i]
527 if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
drhf167a402015-01-07 18:44:59 +0000528 switch -glob -- $x {
drhd477eee2014-12-23 19:40:51 +0000529 -srcdir {
drh96110de2010-09-06 18:44:14 +0000530 incr i
drhd477eee2014-12-23 19:40:51 +0000531 set ::SRCDIR [file normalize [lindex $argv $i]]
drh96110de2010-09-06 18:44:14 +0000532 }
533
534 -platform {
535 incr i
536 set platform [lindex $argv $i]
537 }
538
539 -quick {
drhd477eee2014-12-23 19:40:51 +0000540 set ::QUICK 1
drh96110de2010-09-06 18:44:14 +0000541 }
drh5bfff9d2015-01-08 01:05:42 +0000542 -veryquick {
543 set ::QUICK 2
drh96110de2010-09-06 18:44:14 +0000544 }
drh2eeb7ae2014-10-10 17:44:03 +0000545
546 -config {
547 incr i
548 set config [lindex $argv $i]
549 }
drhd477eee2014-12-23 19:40:51 +0000550
mistachkin00eb70d2015-04-04 00:02:07 +0000551 -msvc {
552 set ::MSVC 1
553 }
554
drhd477eee2014-12-23 19:40:51 +0000555 -buildonly {
556 set ::BUILDONLY 1
557 }
558
559 -dryrun {
560 set ::DRYRUN 1
561 }
562
drh8f455552015-01-07 14:41:18 +0000563 -trace {
564 set ::TRACE 1
565 }
566
drhd477eee2014-12-23 19:40:51 +0000567 -info {
drhe31dc592015-08-14 12:53:37 +0000568 PUTS "Command-line Options:"
569 PUTS " --srcdir $::SRCDIR"
570 PUTS " --platform [list $platform]"
571 PUTS " --config [list $config]"
drh905da632015-06-10 18:53:09 +0000572 if {$::QUICK} {
drhe31dc592015-08-14 12:53:37 +0000573 if {$::QUICK==1} {PUTS " --quick"}
574 if {$::QUICK==2} {PUTS " --veryquick"}
drh905da632015-06-10 18:53:09 +0000575 }
drhe31dc592015-08-14 12:53:37 +0000576 if {$::MSVC} {PUTS " --msvc"}
577 if {$::BUILDONLY} {PUTS " --buildonly"}
578 if {$::DRYRUN} {PUTS " --dryrun"}
579 if {$::TRACE} {PUTS " --trace"}
580 PUTS "\nAvailable --platform options:"
drhd477eee2014-12-23 19:40:51 +0000581 foreach y [lsort [array names ::Platforms]] {
drhe31dc592015-08-14 12:53:37 +0000582 PUTS " [list $y]"
drhd477eee2014-12-23 19:40:51 +0000583 }
drhe31dc592015-08-14 12:53:37 +0000584 PUTS "\nAvailable --config options:"
drhd477eee2014-12-23 19:40:51 +0000585 foreach y [lsort [array names ::Configs]] {
drhe31dc592015-08-14 12:53:37 +0000586 PUTS " [list $y]"
drhd477eee2014-12-23 19:40:51 +0000587 }
588 exit
589 }
mistachkin00eb70d2015-04-04 00:02:07 +0000590
591 -g {
592 if {$::MSVC} {
593 lappend ::EXTRACONFIG -Zi
594 } else {
595 lappend ::EXTRACONFIG [lindex $argv $i]
596 }
597 }
598
drh0ef84d02015-04-24 17:50:37 +0000599 -with-tcl=* {
600 set ::WITHTCL -$x
601 }
602
drhf167a402015-01-07 18:44:59 +0000603 -D* -
drh5bfff9d2015-01-08 01:05:42 +0000604 -O* -
drhf167a402015-01-07 18:44:59 +0000605 -enable-* -
606 -disable-* -
607 *=* {
608 lappend ::EXTRACONFIG [lindex $argv $i]
609 }
mistachkin72840562014-12-23 20:22:57 +0000610
drh96110de2010-09-06 18:44:14 +0000611 default {
drhe31dc592015-08-14 12:53:37 +0000612 PUTS stderr ""
613 PUTS stderr [string trim $::USAGE_MESSAGE]
drh96110de2010-09-06 18:44:14 +0000614 exit -1
615 }
616 }
617 }
618
drh96110de2010-09-06 18:44:14 +0000619 if {0==[info exists ::Platforms($platform)]} {
drhe31dc592015-08-14 12:53:37 +0000620 PUTS "Unknown platform: $platform"
621 PUTS -nonewline "Set the -platform option to "
drh96110de2010-09-06 18:44:14 +0000622 set print [list]
623 foreach p [array names ::Platforms] {
624 lappend print "\"$p\""
625 }
626 lset print end "or [lindex $print end]"
drhe31dc592015-08-14 12:53:37 +0000627 PUTS "[join $print {, }]."
drh96110de2010-09-06 18:44:14 +0000628 exit
629 }
630
drh2eeb7ae2014-10-10 17:44:03 +0000631 if {$config!=""} {
drhe35626f2014-10-10 17:47:00 +0000632 if {[llength $config]==1} {lappend config fulltest}
drh2eeb7ae2014-10-10 17:44:03 +0000633 set ::CONFIGLIST $config
634 } else {
635 set ::CONFIGLIST $::Platforms($platform)
636 }
drhe31dc592015-08-14 12:53:37 +0000637 PUTS "Running the following test configurations for $platform:"
638 PUTS " [string trim $::CONFIGLIST]"
639 PUTS -nonewline "Flags:"
640 if {$::DRYRUN} {PUTS -nonewline " --dryrun"}
641 if {$::BUILDONLY} {PUTS -nonewline " --buildonly"}
642 if {$::MSVC} {PUTS -nonewline " --msvc"}
drh5bfff9d2015-01-08 01:05:42 +0000643 switch -- $::QUICK {
drhe31dc592015-08-14 12:53:37 +0000644 1 {PUTS -nonewline " --quick"}
645 2 {PUTS -nonewline " --veryquick"}
drh5bfff9d2015-01-08 01:05:42 +0000646 }
drhe31dc592015-08-14 12:53:37 +0000647 PUTS ""
drh96110de2010-09-06 18:44:14 +0000648}
649
650# Main routine.
651#
652proc main {argv} {
653
654 # Process any command line options.
drhf167a402015-01-07 18:44:59 +0000655 set ::EXTRACONFIG {}
drh96110de2010-09-06 18:44:14 +0000656 process_options $argv
drhe31dc592015-08-14 12:53:37 +0000657 PUTS [string repeat * 79]
drh96110de2010-09-06 18:44:14 +0000658
drh97876ee2014-12-24 23:35:36 +0000659 set ::NERR 0
660 set ::NTEST 0
drh277b4e42014-12-29 02:55:58 +0000661 set ::NTESTCASE 0
662 set ::NERRCASE 0
drh5bfff9d2015-01-08 01:05:42 +0000663 set ::SQLITE_VERSION {}
drhd477eee2014-12-23 19:40:51 +0000664 set STARTTIME [clock seconds]
drh96110de2010-09-06 18:44:14 +0000665 foreach {zConfig target} $::CONFIGLIST {
mistachkin00eb70d2015-04-04 00:02:07 +0000666 if {$::MSVC && ($zConfig eq "Sanitize" || "checksymbols" in $target
667 || "valgrindtest" in $target)} {
drhe31dc592015-08-14 12:53:37 +0000668 PUTS "Skipping $zConfig / $target for MSVC..."
mistachkin00eb70d2015-04-04 00:02:07 +0000669 continue
670 }
drh5bfff9d2015-01-08 01:05:42 +0000671 if {$target ne "checksymbols"} {
672 switch -- $::QUICK {
drh905da632015-06-10 18:53:09 +0000673 1 {set target quicktest}
drh5bfff9d2015-01-08 01:05:42 +0000674 2 {set target smoketest}
675 }
mistachkin00eb70d2015-04-04 00:02:07 +0000676 if {$::BUILDONLY} {
677 set target testfixture
678 if {$::MSVC} {append target .exe}
679 }
drh5bfff9d2015-01-08 01:05:42 +0000680 }
drhf167a402015-01-07 18:44:59 +0000681 set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]
drh96110de2010-09-06 18:44:14 +0000682
drhd477eee2014-12-23 19:40:51 +0000683 incr NTEST
drh96110de2010-09-06 18:44:14 +0000684 run_test_suite $zConfig $target $config_options
685
686 # If the configuration included the SQLITE_DEBUG option, then remove
687 # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
688 # add it and run veryquick.test.
drh5bfff9d2015-01-08 01:05:42 +0000689 if {$target!="checksymbols" && $target!="valgrindtest"
drhf3320712015-04-25 13:39:29 +0000690 && $target!="fuzzoomtest" && !$::BUILDONLY && $::QUICK<2} {
danb136e902012-12-10 10:22:48 +0000691 set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
drhbd41d562014-12-30 20:40:32 +0000692 set xtarget $target
drhaf700b32014-12-31 20:35:11 +0000693 regsub -all {fulltest[a-z]*} $xtarget test xtarget
drhf3320712015-04-25 13:39:29 +0000694 regsub -all {fuzzoomtest} $xtarget fuzztest xtarget
danb136e902012-12-10 10:22:48 +0000695 if {$debug_idx < 0} {
drhd477eee2014-12-23 19:40:51 +0000696 incr NTEST
drhbd41d562014-12-30 20:40:32 +0000697 append config_options " -DSQLITE_DEBUG=1"
698 run_test_suite "${zConfig}_debug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +0000699 } else {
drhd477eee2014-12-23 19:40:51 +0000700 incr NTEST
drhbd41d562014-12-30 20:40:32 +0000701 regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options
702 regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options
703 run_test_suite "${zConfig}_ndebug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +0000704 }
drh96110de2010-09-06 18:44:14 +0000705 }
drh96110de2010-09-06 18:44:14 +0000706 }
drh96110de2010-09-06 18:44:14 +0000707
drhd477eee2014-12-23 19:40:51 +0000708 set elapsetime [expr {[clock seconds]-$STARTTIME}]
drh97876ee2014-12-24 23:35:36 +0000709 set hr [expr {$elapsetime/3600}]
710 set min [expr {($elapsetime/60)%60}]
711 set sec [expr {$elapsetime%60}]
712 set etime [format (%02d:%02d:%02d) $hr $min $sec]
drhe31dc592015-08-14 12:53:37 +0000713 PUTS [string repeat * 79]
drhb1031f02015-09-10 15:20:49 +0000714 incr ::NERRCASE $::NERR
drhe31dc592015-08-14 12:53:37 +0000715 PUTS "$::NERRCASE failures out of $::NTESTCASE tests in $etime"
drh5bfff9d2015-01-08 01:05:42 +0000716 if {$::SQLITE_VERSION ne ""} {
drhe31dc592015-08-14 12:53:37 +0000717 PUTS "SQLite $::SQLITE_VERSION"
drh96110de2010-09-06 18:44:14 +0000718 }
719}
720
721main $argv