blob: 2bcf1aa511cfcfd9e4df2787f4542c27b320042c [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)
dane9e15052015-11-02 20:28:48 +000022 --jobs N (Use N processes - default 1)
drh7f8a93d2015-11-03 15:39:29 +000023 --progress (Show progress messages)
drh96110de2010-09-06 18:44:14 +000024
drhd477eee2014-12-23 19:40:51 +000025The default value for --srcdir is the parent of the directory holding
26this script.
drh96110de2010-09-06 18:44:14 +000027
drhd477eee2014-12-23 19:40:51 +000028The script determines the default value for --platform using the
mistachkin00eb70d2015-04-04 00:02:07 +000029$tcl_platform(os) and $tcl_platform(machine) variables. Supported
30platforms are "Linux-x86", "Linux-x86_64", "Darwin-i386",
31"Darwin-x86_64", "Windows NT-intel", and "Windows NT-amd64".
drh96110de2010-09-06 18:44:14 +000032
drhd477eee2014-12-23 19:40:51 +000033Every test begins with a fresh run of the configure script at the top
34of the SQLite source tree.
drh96110de2010-09-06 18:44:14 +000035}
36
drh4380ff82015-11-03 15:16:21 +000037# Return a timestamp of the form HH:MM:SS
38#
39proc now {} {
40 return [clock format [clock seconds] -format %H:%M:%S]
41}
42
drh6aed1c42015-01-10 15:21:26 +000043# Omit comments (text between # and \n) in a long multi-line string.
44#
45proc strip_comments {in} {
46 regsub -all {#[^\n]*\n} $in {} out
47 return $out
48}
49
50array set ::Configs [strip_comments {
drh96110de2010-09-06 18:44:14 +000051 "Default" {
52 -O2
drhedb31cd2015-01-08 02:15:11 +000053 --disable-amalgamation --disable-shared
drh96110de2010-09-06 18:44:14 +000054 }
drh4081d5d2015-01-01 23:02:01 +000055 "Sanitize" {
drh149735d2015-01-01 19:53:10 +000056 CC=clang -fsanitize=undefined
drh4081d5d2015-01-01 23:02:01 +000057 -DSQLITE_ENABLE_STAT4
dan56089732011-04-06 12:37:09 +000058 }
drh0ede9eb2015-01-10 16:49:23 +000059 "Have-Not" {
60 # The "Have-Not" configuration sets all possible -UHAVE_feature options
61 # in order to verify that the code works even on platforms that lack
62 # these support services.
63 -DHAVE_FDATASYNC=0
64 -DHAVE_GMTIME_R=0
drh8567d402015-01-10 18:22:06 +000065 -DHAVE_ISNAN=0
drh0ede9eb2015-01-10 16:49:23 +000066 -DHAVE_LOCALTIME_R=0
67 -DHAVE_LOCALTIME_S=0
68 -DHAVE_MALLOC_USABLE_SIZE=0
69 -DHAVE_STRCHRNUL=0
70 -DHAVE_USLEEP=0
71 -DHAVE_UTIME=0
drh96110de2010-09-06 18:44:14 +000072 }
73 "Unlock-Notify" {
74 -O2
75 -DSQLITE_ENABLE_UNLOCK_NOTIFY
76 -DSQLITE_THREADSAFE
drh96110de2010-09-06 18:44:14 +000077 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
78 }
79 "Secure-Delete" {
80 -O2
81 -DSQLITE_SECURE_DELETE=1
82 -DSQLITE_SOUNDEX=1
83 }
84 "Update-Delete-Limit" {
85 -O2
86 -DSQLITE_DEFAULT_FILE_FORMAT=4
87 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
drh1a803842015-01-09 20:00:21 +000088 -DSQLITE_ENABLE_STMT_SCANSTATUS
drh7f105792016-01-04 01:08:50 +000089 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS
90 -DSQLITE_ENABLE_CURSOR_HINTS
drhce1d9f52015-10-09 12:48:33 +000091 --enable-json1
drh96110de2010-09-06 18:44:14 +000092 }
danb136e902012-12-10 10:22:48 +000093 "Check-Symbols" {
94 -DSQLITE_MEMDEBUG=1
95 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
96 -DSQLITE_ENABLE_FTS3=1
97 -DSQLITE_ENABLE_RTREE=1
98 -DSQLITE_ENABLE_MEMSYS5=1
99 -DSQLITE_ENABLE_MEMSYS3=1
100 -DSQLITE_ENABLE_COLUMN_METADATA=1
101 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
102 -DSQLITE_SECURE_DELETE=1
103 -DSQLITE_SOUNDEX=1
104 -DSQLITE_ENABLE_ATOMIC_WRITE=1
danb136e902012-12-10 10:22:48 +0000105 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
106 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
drh4081d5d2015-01-01 23:02:01 +0000107 -DSQLITE_ENABLE_STAT4
drh1a803842015-01-09 20:00:21 +0000108 -DSQLITE_ENABLE_STMT_SCANSTATUS
drhce1d9f52015-10-09 12:48:33 +0000109 --enable-json1 --enable-fts5
danb136e902012-12-10 10:22:48 +0000110 }
drh96110de2010-09-06 18:44:14 +0000111 "Debug-One" {
drh8f455552015-01-07 14:41:18 +0000112 --disable-shared
drh96110de2010-09-06 18:44:14 +0000113 -O2
114 -DSQLITE_DEBUG=1
115 -DSQLITE_MEMDEBUG=1
116 -DSQLITE_MUTEX_NOOP=1
117 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
118 -DSQLITE_ENABLE_FTS3=1
119 -DSQLITE_ENABLE_RTREE=1
120 -DSQLITE_ENABLE_MEMSYS5=1
121 -DSQLITE_ENABLE_MEMSYS3=1
122 -DSQLITE_ENABLE_COLUMN_METADATA=1
drh4081d5d2015-01-01 23:02:01 +0000123 -DSQLITE_ENABLE_STAT4
drh03d69a62015-11-19 13:53:57 +0000124 -DSQLITE_ENABLE_HIDDEN_COLUMNS
drhedb31cd2015-01-08 02:15:11 +0000125 -DSQLITE_MAX_ATTACHED=125
drh96110de2010-09-06 18:44:14 +0000126 }
drhf3320712015-04-25 13:39:29 +0000127 "Fast-One" {
128 -O6
129 -DSQLITE_ENABLE_FTS4=1
130 -DSQLITE_ENABLE_RTREE=1
131 -DSQLITE_ENABLE_STAT4
drhcfb8f8d2015-07-23 20:44:49 +0000132 -DSQLITE_ENABLE_RBU
drh96110de2010-09-06 18:44:14 +0000133 -DSQLITE_MAX_ATTACHED=125
drh51675f22015-11-06 20:04:08 +0000134 -DLONGDOUBLE_TYPE=double
drh96110de2010-09-06 18:44:14 +0000135 }
drh96110de2010-09-06 18:44:14 +0000136 "Device-One" {
137 -O2
138 -DSQLITE_DEBUG=1
drh96110de2010-09-06 18:44:14 +0000139 -DSQLITE_DEFAULT_AUTOVACUUM=1
drh96110de2010-09-06 18:44:14 +0000140 -DSQLITE_DEFAULT_CACHE_SIZE=64
dan1c22a182010-09-13 11:29:02 +0000141 -DSQLITE_DEFAULT_PAGE_SIZE=1024
drh96110de2010-09-06 18:44:14 +0000142 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
dan1c22a182010-09-13 11:29:02 +0000143 -DSQLITE_DISABLE_LFS=1
drh96110de2010-09-06 18:44:14 +0000144 -DSQLITE_ENABLE_ATOMIC_WRITE=1
dan1c22a182010-09-13 11:29:02 +0000145 -DSQLITE_ENABLE_IOTRACE=1
146 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
147 -DSQLITE_MAX_PAGE_SIZE=4096
148 -DSQLITE_OMIT_LOAD_EXTENSION=1
149 -DSQLITE_OMIT_PROGRESS_CALLBACK=1
150 -DSQLITE_OMIT_VIRTUALTABLE=1
drh03d69a62015-11-19 13:53:57 +0000151 -DSQLITE_ENABLE_HIDDEN_COLUMNS
dan1c22a182010-09-13 11:29:02 +0000152 -DSQLITE_TEMP_STORE=3
drh64db1842015-10-09 13:29:27 +0000153 --enable-json1
dan1c22a182010-09-13 11:29:02 +0000154 }
155 "Device-Two" {
156 -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
157 -DSQLITE_DEFAULT_AUTOVACUUM=1
158 -DSQLITE_DEFAULT_CACHE_SIZE=1000
159 -DSQLITE_DEFAULT_LOCKING_MODE=0
160 -DSQLITE_DEFAULT_PAGE_SIZE=1024
161 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000
162 -DSQLITE_DISABLE_LFS=1
163 -DSQLITE_ENABLE_FTS3=1
164 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
165 -DSQLITE_ENABLE_RTREE=1
166 -DSQLITE_MAX_COMPOUND_SELECT=50
167 -DSQLITE_MAX_PAGE_SIZE=32768
dan1c22a182010-09-13 11:29:02 +0000168 -DSQLITE_OMIT_TRACE=1
169 -DSQLITE_TEMP_STORE=3
170 -DSQLITE_THREADSAFE=2
drhce1d9f52015-10-09 12:48:33 +0000171 --enable-json1 --enable-fts5
drh96110de2010-09-06 18:44:14 +0000172 }
173 "Locking-Style" {
174 -O2
175 -DSQLITE_ENABLE_LOCKING_STYLE=1
176 }
177 "OS-X" {
drh149735d2015-01-01 19:53:10 +0000178 -O1 # Avoid a compiler bug in gcc 4.2.1 build 5658
dan1c22a182010-09-13 11:29:02 +0000179 -DSQLITE_OMIT_LOAD_EXTENSION=1
180 -DSQLITE_DEFAULT_MEMSTATUS=0
181 -DSQLITE_THREADSAFE=2
182 -DSQLITE_OS_UNIX=1
drhc306e082015-10-08 23:37:00 +0000183 -DSQLITE_ENABLE_JSON1=1
drh96110de2010-09-06 18:44:14 +0000184 -DSQLITE_ENABLE_LOCKING_STYLE=1
dan1c22a182010-09-13 11:29:02 +0000185 -DUSE_PREAD=1
186 -DSQLITE_ENABLE_RTREE=1
187 -DSQLITE_ENABLE_FTS3=1
188 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
189 -DSQLITE_DEFAULT_CACHE_SIZE=1000
190 -DSQLITE_MAX_LENGTH=2147483645
191 -DSQLITE_MAX_VARIABLE_NUMBER=500000
mistachkin72840562014-12-23 20:22:57 +0000192 -DSQLITE_DEBUG=1
dan1c22a182010-09-13 11:29:02 +0000193 -DSQLITE_PREFER_PROXY_LOCKING=1
drhc67d6502014-12-31 15:14:29 +0000194 -DSQLITE_ENABLE_API_ARMOR=1
drhce1d9f52015-10-09 12:48:33 +0000195 --enable-json1 --enable-fts5
drh96110de2010-09-06 18:44:14 +0000196 }
197 "Extra-Robustness" {
198 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
dan56089732011-04-06 12:37:09 +0000199 -DSQLITE_MAX_ATTACHED=62
drh96110de2010-09-06 18:44:14 +0000200 }
dan4dc3d732012-08-20 17:24:48 +0000201 "Devkit" {
202 -DSQLITE_DEFAULT_FILE_FORMAT=4
203 -DSQLITE_MAX_ATTACHED=30
204 -DSQLITE_ENABLE_COLUMN_METADATA
205 -DSQLITE_ENABLE_FTS4
dane82126c2016-03-01 16:02:57 +0000206 -DSQLITE_ENABLE_FTS5
dan4dc3d732012-08-20 17:24:48 +0000207 -DSQLITE_ENABLE_FTS4_PARENTHESIS
208 -DSQLITE_DISABLE_FTS4_DEFERRED
209 -DSQLITE_ENABLE_RTREE
drhce1d9f52015-10-09 12:48:33 +0000210 --enable-json1 --enable-fts5
dan4dc3d732012-08-20 17:24:48 +0000211 }
dand79d27a2014-08-12 14:06:13 +0000212 "No-lookaside" {
213 -DSQLITE_TEST_REALLOC_STRESS=1
214 -DSQLITE_OMIT_LOOKASIDE=1
215 -DHAVE_USLEEP=1
216 }
drh8a2a0f52015-01-07 14:09:41 +0000217 "Valgrind" {
218 -DSQLITE_ENABLE_STAT4
219 -DSQLITE_ENABLE_FTS4
220 -DSQLITE_ENABLE_RTREE
drh03d69a62015-11-19 13:53:57 +0000221 -DSQLITE_ENABLE_HIDDEN_COLUMNS
drhce1d9f52015-10-09 12:48:33 +0000222 --enable-json1
drh8a2a0f52015-01-07 14:09:41 +0000223 }
drh96110de2010-09-06 18:44:14 +0000224
drh6aed1c42015-01-10 15:21:26 +0000225 # The next group of configurations are used only by the
226 # Failure-Detection platform. They are all the same, but we need
227 # different names for them all so that they results appear in separate
228 # subdirectories.
229 #
drhedb31cd2015-01-08 02:15:11 +0000230 Fail0 {-O0}
231 Fail2 {-O0}
232 Fail3 {-O0}
drhdb6bafa2015-01-09 21:54:58 +0000233 Fail4 {-O0}
drh8ea5eca2015-04-24 16:53:03 +0000234 FuzzFail1 {-O0}
235 FuzzFail2 {-O0}
drh6aed1c42015-01-10 15:21:26 +0000236}]
drh96110de2010-09-06 18:44:14 +0000237
drh6aed1c42015-01-10 15:21:26 +0000238array set ::Platforms [strip_comments {
drh96110de2010-09-06 18:44:14 +0000239 Linux-x86_64 {
danb136e902012-12-10 10:22:48 +0000240 "Check-Symbols" checksymbols
drh71258ab2015-11-04 16:34:58 +0000241 "Fast-One" fuzztest
drhbd41d562014-12-30 20:40:32 +0000242 "Debug-One" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000243 "Have-Not" test
drh96110de2010-09-06 18:44:14 +0000244 "Secure-Delete" test
245 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
drh96110de2010-09-06 18:44:14 +0000246 "Update-Delete-Limit" test
drh96110de2010-09-06 18:44:14 +0000247 "Extra-Robustness" test
dan1c22a182010-09-13 11:29:02 +0000248 "Device-Two" test
dand79d27a2014-08-12 14:06:13 +0000249 "No-lookaside" test
dan5d510d42014-10-15 15:28:27 +0000250 "Devkit" test
drh8a2a0f52015-01-07 14:09:41 +0000251 "Sanitize" {QUICKTEST_OMIT=func4.test,nan.test test}
drh96110de2010-09-06 18:44:14 +0000252 "Device-One" fulltest
drh71258ab2015-11-04 16:34:58 +0000253 "Default" "threadtest fulltest"
254 "Valgrind" valgrindtest
drh96110de2010-09-06 18:44:14 +0000255 }
dan1c22a182010-09-13 11:29:02 +0000256 Linux-i686 {
dan4dc3d732012-08-20 17:24:48 +0000257 "Devkit" test
drh0ede9eb2015-01-10 16:49:23 +0000258 "Have-Not" test
dan1c22a182010-09-13 11:29:02 +0000259 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
dan1c22a182010-09-13 11:29:02 +0000260 "Device-One" test
dand38bc1b2010-09-13 12:15:36 +0000261 "Device-Two" test
262 "Default" "threadtest fulltest"
dan1c22a182010-09-13 11:29:02 +0000263 }
drh96110de2010-09-06 18:44:14 +0000264 Darwin-i386 {
drhbd41d562014-12-30 20:40:32 +0000265 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000266 "Have-Not" test
dand38bc1b2010-09-13 12:15:36 +0000267 "OS-X" "threadtest fulltest"
drh96110de2010-09-06 18:44:14 +0000268 }
drhbcbac682014-12-31 18:55:09 +0000269 Darwin-x86_64 {
270 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000271 "Have-Not" test
drhbcbac682014-12-31 18:55:09 +0000272 "OS-X" "threadtest fulltest"
273 }
mistachkin72840562014-12-23 20:22:57 +0000274 "Windows NT-intel" {
drh0ede9eb2015-01-10 16:49:23 +0000275 "Have-Not" test
drh71258ab2015-11-04 16:34:58 +0000276 "Default" "mptest fulltestonly"
mistachkin72840562014-12-23 20:22:57 +0000277 }
mistachkin00eb70d2015-04-04 00:02:07 +0000278 "Windows NT-amd64" {
mistachkin00eb70d2015-04-04 00:02:07 +0000279 "Have-Not" test
drh71258ab2015-11-04 16:34:58 +0000280 "Default" "mptest fulltestonly"
mistachkin00eb70d2015-04-04 00:02:07 +0000281 }
drh6aed1c42015-01-10 15:21:26 +0000282
283 # The Failure-Detection platform runs various tests that deliberately
284 # fail. This is used as a test of this script to verify that this script
285 # correctly identifies failures.
286 #
drhedb31cd2015-01-08 02:15:11 +0000287 Failure-Detection {
288 Fail0 "TEST_FAILURE=0 test"
289 Sanitize "TEST_FAILURE=1 test"
290 Fail2 "TEST_FAILURE=2 valgrindtest"
291 Fail3 "TEST_FAILURE=3 valgrindtest"
drhdb6bafa2015-01-09 21:54:58 +0000292 Fail4 "TEST_FAILURE=4 test"
drh8ea5eca2015-04-24 16:53:03 +0000293 FuzzFail1 "TEST_FAILURE=5 test"
294 FuzzFail2 "TEST_FAILURE=5 valgrindtest"
drhedb31cd2015-01-08 02:15:11 +0000295 }
drh6aed1c42015-01-10 15:21:26 +0000296}]
drh96110de2010-09-06 18:44:14 +0000297
dane7152dc2011-07-07 08:19:16 +0000298
drh96110de2010-09-06 18:44:14 +0000299# End of configuration section.
300#########################################################################
301#########################################################################
302
mistachkinda9da562015-11-02 23:29:58 +0000303# Configuration verification: Check that each entry in the list of configs
dana7f65972015-11-02 18:32:00 +0000304# specified for each platforms exists.
305#
drh96110de2010-09-06 18:44:14 +0000306foreach {key value} [array get ::Platforms] {
307 foreach {v t} $value {
308 if {0==[info exists ::Configs($v)]} {
309 puts stderr "No such configuration: \"$v\""
310 exit -1
311 }
312 }
313}
314
drhd63fbb72015-11-13 12:52:34 +0000315# Output log. Disabled for slave interpreters.
drhe31dc592015-08-14 12:53:37 +0000316#
drhd63fbb72015-11-13 12:52:34 +0000317if {[lindex $argv end]!="--slave"} {
318 set LOG [open releasetest-out.txt w]
319 proc PUTS {txt} {
320 puts $txt
321 puts $::LOG $txt
322 flush $::LOG
drhe31dc592015-08-14 12:53:37 +0000323 }
drhd63fbb72015-11-13 12:52:34 +0000324 proc PUTSNNL {txt} {
325 puts -nonewline $txt
326 puts -nonewline $::LOG $txt
327 flush $::LOG
328 }
329 proc PUTSERR {txt} {
330 puts stderr $txt
331 puts $::LOG $txt
332 flush $::LOG
333 }
334 puts $LOG "$argv0 $argv"
335 set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]
336 puts $LOG "start-time: $tm0 UTC"
337} else {
338 proc PUTS {txt} {
339 puts $txt
340 }
341 proc PUTSNNL {txt} {
342 puts -nonewline $txt
343 }
344 proc PUTSERR {txt} {
345 puts stderr $txt
346 }
drhe31dc592015-08-14 12:53:37 +0000347}
drhe31dc592015-08-14 12:53:37 +0000348
drh277b4e42014-12-29 02:55:58 +0000349# Open the file $logfile and look for a report on the number of errors
350# and the number of test cases run. Add these values to the global
351# $::NERRCASE and $::NTESTCASE variables.
352#
353# If any errors occur, then write into $errmsgVar the text of an appropriate
354# one-line error message to show on the output.
355#
356proc count_tests_and_errors {logfile rcVar errmsgVar} {
drhcb281a92014-12-29 19:54:10 +0000357 if {$::DRYRUN} return
drh277b4e42014-12-29 02:55:58 +0000358 upvar 1 $rcVar rc $errmsgVar errmsg
359 set fd [open $logfile rb]
360 set seen 0
361 while {![eof $fd]} {
362 set line [gets $fd]
drhbd41d562014-12-30 20:40:32 +0000363 if {[regexp {(\d+) errors out of (\d+) tests} $line all nerr ntest]} {
drh277b4e42014-12-29 02:55:58 +0000364 incr ::NERRCASE $nerr
365 incr ::NTESTCASE $ntest
366 set seen 1
367 if {$nerr>0} {
368 set rc 1
369 set errmsg $line
370 }
drh277b4e42014-12-29 02:55:58 +0000371 }
drh4081d5d2015-01-01 23:02:01 +0000372 if {[regexp {runtime error: +(.*)} $line all msg]} {
drh36c25f72015-07-29 20:24:39 +0000373 # skip over "value is outside range" errors
374 if {[regexp {value .* is outside the range of representable} $line]} {
375 # noop
376 } else {
377 incr ::NERRCASE
378 if {$rc==0} {
379 set rc 1
380 set errmsg $msg
381 }
drh4081d5d2015-01-01 23:02:01 +0000382 }
383 }
mistachkin00eb70d2015-04-04 00:02:07 +0000384 if {[regexp {fatal error +(.*)} $line all msg]} {
385 incr ::NERRCASE
386 if {$rc==0} {
387 set rc 1
388 set errmsg $msg
389 }
390 }
drh8a2a0f52015-01-07 14:09:41 +0000391 if {[regexp {ERROR SUMMARY: (\d+) errors.*} $line all cnt] && $cnt>0} {
392 incr ::NERRCASE
393 if {$rc==0} {
394 set rc 1
395 set errmsg $all
396 }
397 }
drh5bfff9d2015-01-08 01:05:42 +0000398 if {[regexp {^VERSION: 3\.\d+.\d+} $line]} {
399 set v [string range $line 9 end]
400 if {$::SQLITE_VERSION eq ""} {
401 set ::SQLITE_VERSION $v
402 } elseif {$::SQLITE_VERSION ne $v} {
403 set rc 1
404 set errmsg "version conflict: {$::SQLITE_VERSION} vs. {$v}"
405 }
406 }
drh277b4e42014-12-29 02:55:58 +0000407 }
408 close $fd
mistachkin00eb70d2015-04-04 00:02:07 +0000409 if {$::BUILDONLY} {
drh7f8a93d2015-11-03 15:39:29 +0000410 incr ::NTESTCASE
411 if {$rc!=0} {
mistachkin00eb70d2015-04-04 00:02:07 +0000412 set errmsg "Build failed"
413 }
414 } elseif {!$seen} {
drh277b4e42014-12-29 02:55:58 +0000415 set rc 1
416 set errmsg "Test did not complete"
drhdb6bafa2015-01-09 21:54:58 +0000417 if {[file readable core]} {
418 append errmsg " - core file exists"
419 }
drh277b4e42014-12-29 02:55:58 +0000420 }
421}
422
dana7f65972015-11-02 18:32:00 +0000423#--------------------------------------------------------------------------
424# This command is invoked as the [main] routine for scripts run with the
mistachkinda9da562015-11-02 23:29:58 +0000425# "--slave" option.
dana7f65972015-11-02 18:32:00 +0000426#
427# For each test (i.e. "configure && make test" execution), the master
428# process spawns a process with the --slave option. It writes two lines
mistachkinda9da562015-11-02 23:29:58 +0000429# to the slaves stdin. The first contains a single boolean value - the
430# value of ::TRACE to use in the slave script. The second line contains a
dana7f65972015-11-02 18:32:00 +0000431# list in the same format as each element of the list passed to the
432# [run_all_test_suites] command in the master process.
433#
434# The slave then runs the "configure && make test" commands specified. It
435# exits successfully if the tests passes, or with a non-zero error code
436# otherwise.
437#
438proc run_slave_test {} {
439 # Read global vars configuration from stdin.
440 set V [gets stdin]
dand08a63a2015-11-02 20:52:20 +0000441 foreach {::TRACE ::MSVC ::DRYRUN} $V {}
dana7f65972015-11-02 18:32:00 +0000442
443 # Read the test-suite configuration from stdin.
444 set T [gets stdin]
mistachkinda9da562015-11-02 23:29:58 +0000445 foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
dana7f65972015-11-02 18:32:00 +0000446
447 # Create and switch to the test directory.
drh6653fbe2015-11-13 20:52:49 +0000448 set ::env(SQLITE_TMPDIR) [file normalize $dir]
dana7f65972015-11-02 18:32:00 +0000449 trace_cmd file mkdir $dir
450 trace_cmd cd $dir
451 catch {file delete core}
452 catch {file delete test.log}
453
454 # Run the "./configure && make" commands.
455 set rc 0
456 set rc [catch [configureCommand $configOpts]]
457 if {!$rc} {
mistachkin59189432015-11-02 21:05:56 +0000458 if {[info exists ::env(TCLSH_CMD)]} {
459 set savedEnv(TCLSH_CMD) $::env(TCLSH_CMD)
460 } else {
461 unset -nocomplain savedEnv(TCLSH_CMD)
462 }
463 set ::env(TCLSH_CMD) [file nativename [info nameofexecutable]]
mistachkinda9da562015-11-02 23:29:58 +0000464 set rc [catch [makeCommand $testtarget $makeOpts $cflags $opts]]
mistachkin59189432015-11-02 21:05:56 +0000465 if {[info exists savedEnv(TCLSH_CMD)]} {
466 set ::env(TCLSH_CMD) $savedEnv(TCLSH_CMD)
467 } else {
468 unset -nocomplain ::env(TCLSH_CMD)
469 }
dana7f65972015-11-02 18:32:00 +0000470 }
471
472 # Exis successfully if the test passed, or with a non-zero error code
473 # otherwise.
474 exit $rc
475}
476
mistachkinda9da562015-11-02 23:29:58 +0000477# This command is invoked in the master process each time a slave
dana7f65972015-11-02 18:32:00 +0000478# file-descriptor is readable.
479#
480proc slave_fileevent {fd T tm1} {
481 global G
mistachkinda9da562015-11-02 23:29:58 +0000482 foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
dana7f65972015-11-02 18:32:00 +0000483
484 if {[eof $fd]} {
485 fconfigure $fd -blocking 1
486 set rc [catch { close $fd }]
487
488 set errmsg {}
dane9e15052015-11-02 20:28:48 +0000489 set logfile [file join $dir test.log]
490 if {[file exists $logfile]} {
491 count_tests_and_errors [file join $dir test.log] rc errmsg
drh4380ff82015-11-03 15:16:21 +0000492 } elseif {$rc==0 && !$::DRYRUN} {
dane9e15052015-11-02 20:28:48 +0000493 set rc 1
494 set errmsg "no test.log file..."
495 }
dana7f65972015-11-02 18:32:00 +0000496
497 if {!$::TRACE} {
498 set tm2 [clock seconds]
499 set hours [expr {($tm2-$tm1)/3600}]
500 set minutes [expr {(($tm2-$tm1)/60)%60}]
501 set seconds [expr {($tm2-$tm1)%60}]
502 set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
503
504 if {$rc} {
505 set status FAIL
506 incr ::NERR
507 } else {
508 set status Ok
509 }
510
511 set n [string length $title]
drh7f8a93d2015-11-03 15:39:29 +0000512 if {$::PROGRESS_MSGS} {
513 PUTS "finished: ${title}[string repeat . [expr {53-$n}]] $status $tm"
514 } else {
515 PUTS "${title}[string repeat . [expr {63-$n}]] $status $tm"
516 }
dana7f65972015-11-02 18:32:00 +0000517 if {$errmsg!=""} {PUTS " $errmsg"}
518 flush stdout
519 }
520
521 incr G(nJob) -1
522 } else {
523 set line [gets $fd]
524 if {[string trim $line] != ""} {
525 puts "Trace : $title - \"$line\""
526 }
527 }
528}
529
530#--------------------------------------------------------------------------
531# The only argument passed to this function is a list of test-suites to
532# run. Each "test-suite" is itself a list consisting of the following
533# elements:
534#
535# * Test title (for display).
536# * The name of the directory to run the test in.
537# * The argument for [configureCommand]
538# * The first argument for [makeCommand]
539# * The second argument for [makeCommand]
540# * The third argument for [makeCommand]
mistachkinda9da562015-11-02 23:29:58 +0000541#
dana7f65972015-11-02 18:32:00 +0000542proc run_all_test_suites {alltests} {
543 global G
544 set tests $alltests
545
546 set G(nJob) 0
547
548 while {[llength $tests]>0 || $G(nJob)>0} {
549 if {$G(nJob)>=$::JOBS || [llength $tests]==0} {
550 vwait G(nJob)
551 }
552
553 if {[llength $tests]>0} {
554 set T [lindex $tests 0]
555 set tests [lrange $tests 1 end]
mistachkinda9da562015-11-02 23:29:58 +0000556 foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
drh7f8a93d2015-11-03 15:39:29 +0000557 if {$::PROGRESS_MSGS && !$::TRACE} {
dana7f65972015-11-02 18:32:00 +0000558 set n [string length $title]
drh4380ff82015-11-03 15:16:21 +0000559 PUTS "starting: ${title} at [now]"
dana7f65972015-11-02 18:32:00 +0000560 flush stdout
561 }
562
563 # Run the job.
564 #
565 set tm1 [clock seconds]
566 incr G(nJob)
mistachkin59189432015-11-02 21:05:56 +0000567 set script [file normalize [info script]]
568 set fd [open "|[info nameofexecutable] $script --slave" r+]
dana7f65972015-11-02 18:32:00 +0000569 fconfigure $fd -blocking 0
570 fileevent $fd readable [list slave_fileevent $fd $T $tm1]
dand08a63a2015-11-02 20:52:20 +0000571 puts $fd [list $::TRACE $::MSVC $::DRYRUN]
dana7f65972015-11-02 18:32:00 +0000572 puts $fd [list {*}$T]
573 flush $fd
574 }
575 }
576}
577
578proc add_test_suite {listvar name testtarget config} {
579 upvar $listvar alltests
580
mistachkin72840562014-12-23 20:22:57 +0000581 # Tcl variable $opts is used to build up the value used to set the
drh96110de2010-09-06 18:44:14 +0000582 # OPTS Makefile variable. Variable $cflags holds the value for
583 # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
584 # CFLAGS is only passed to gcc.
585 #
mistachkinda9da562015-11-02 23:29:58 +0000586 set makeOpts ""
mistachkin00eb70d2015-04-04 00:02:07 +0000587 set cflags [expr {$::MSVC ? "-Zi" : "-g"}]
drh96110de2010-09-06 18:44:14 +0000588 set opts ""
drha780d8d2015-01-03 18:59:17 +0000589 set title ${name}($testtarget)
drh0ef84d02015-04-24 17:50:37 +0000590 set configOpts $::WITHTCL
drha780d8d2015-01-03 18:59:17 +0000591
drh149735d2015-01-01 19:53:10 +0000592 regsub -all {#[^\n]*\n} $config \n config
drh96110de2010-09-06 18:44:14 +0000593 foreach arg $config {
drh0ede9eb2015-01-10 16:49:23 +0000594 if {[regexp {^-[UD]} $arg]} {
drh96110de2010-09-06 18:44:14 +0000595 lappend opts $arg
drh0ede9eb2015-01-10 16:49:23 +0000596 } elseif {[regexp {^[A-Z]+=} $arg]} {
drh149735d2015-01-01 19:53:10 +0000597 lappend testtarget $arg
drh8f455552015-01-07 14:41:18 +0000598 } elseif {[regexp {^--(enable|disable)-} $arg]} {
mistachkinda9da562015-11-02 23:29:58 +0000599 if {$::MSVC} {
600 if {$arg eq "--disable-amalgamation"} {
601 lappend makeOpts USE_AMALGAMATION=0
602 continue
603 }
604 if {$arg eq "--disable-shared"} {
605 lappend makeOpts USE_CRT_DLL=0 DYNAMIC_SHELL=0
606 continue
607 }
608 if {$arg eq "--enable-fts5"} {
609 lappend opts -DSQLITE_ENABLE_FTS5
610 continue
611 }
612 if {$arg eq "--enable-json1"} {
613 lappend opts -DSQLITE_ENABLE_JSON1
614 continue
615 }
mistachkin7d3bfa22015-11-03 06:23:33 +0000616 if {$arg eq "--enable-shared"} {
617 lappend makeOpts USE_CRT_DLL=1 DYNAMIC_SHELL=1
618 continue
619 }
mistachkinda9da562015-11-02 23:29:58 +0000620 }
drh8f455552015-01-07 14:41:18 +0000621 lappend configOpts $arg
drh96110de2010-09-06 18:44:14 +0000622 } else {
mistachkinda9da562015-11-02 23:29:58 +0000623 if {$::MSVC} {
624 if {$arg eq "-g"} {
625 lappend cflags -Zi
626 continue
627 }
628 if {[regexp -- {^-O(\d+)$} $arg all level]} then {
629 lappend makeOpts OPTIMIZATIONS=$level
630 continue
631 }
632 }
drh96110de2010-09-06 18:44:14 +0000633 lappend cflags $arg
634 }
635 }
636
mistachkinda9da562015-11-02 23:29:58 +0000637 # Disable sync to make testing faster.
638 #
639 lappend opts -DSQLITE_NO_SYNC=1
mistachkin00eb70d2015-04-04 00:02:07 +0000640
641 # Some configurations already set HAVE_USLEEP; in that case, skip it.
642 #
mistachkinda9da562015-11-02 23:29:58 +0000643 if {[lsearch -regexp $opts {^-DHAVE_USLEEP(?:=|$)}]==-1} {
644 lappend opts -DHAVE_USLEEP=1
645 }
646
647 # Add the define for this platform.
648 #
649 if {$::tcl_platform(platform)=="windows"} {
650 lappend opts -DSQLITE_OS_WIN=1
651 } else {
652 lappend opts -DSQLITE_OS_UNIX=1
mistachkin00eb70d2015-04-04 00:02:07 +0000653 }
drh96110de2010-09-06 18:44:14 +0000654
655 # Set the sub-directory to use.
656 #
657 set dir [string tolower [string map {- _ " " _} $name]]
658
mistachkinda9da562015-11-02 23:29:58 +0000659 # Join option lists into strings, using space as delimiter.
660 #
661 set makeOpts [join $makeOpts " "]
662 set cflags [join $cflags " "]
663 set opts [join $opts " "]
drh96110de2010-09-06 18:44:14 +0000664
mistachkinda9da562015-11-02 23:29:58 +0000665 lappend alltests [list \
666 $title $dir $configOpts $testtarget $makeOpts $cflags $opts]
drhd477eee2014-12-23 19:40:51 +0000667}
668
mistachkin72840562014-12-23 20:22:57 +0000669# The following procedure returns the "configure" command to be exectued for
670# the current platform, which may be Windows (via MinGW, etc).
671#
drh8f455552015-01-07 14:41:18 +0000672proc configureCommand {opts} {
mistachkin00eb70d2015-04-04 00:02:07 +0000673 if {$::MSVC} return [list]; # This is not needed for MSVC.
drh8f455552015-01-07 14:41:18 +0000674 set result [list trace_cmd exec]
mistachkin72840562014-12-23 20:22:57 +0000675 if {$::tcl_platform(platform)=="windows"} {
676 lappend result sh
677 }
drh8f455552015-01-07 14:41:18 +0000678 lappend result $::SRCDIR/configure --enable-load-extension
679 foreach x $opts {lappend result $x}
680 lappend result >& test.log
mistachkin72840562014-12-23 20:22:57 +0000681}
682
683# The following procedure returns the "make" command to be executed for the
684# specified targets, compiler flags, and options.
685#
mistachkinda9da562015-11-02 23:29:58 +0000686proc makeCommand { targets makeOpts cflags opts } {
mistachkin00eb70d2015-04-04 00:02:07 +0000687 set result [list trace_cmd exec]
688 if {$::MSVC} {
689 set nmakeDir [file nativename $::SRCDIR]
mistachkin98fea322015-11-03 02:47:11 +0000690 set nmakeFile [file nativename [file join $nmakeDir Makefile.msc]]
mistachkinda9da562015-11-02 23:29:58 +0000691 lappend result nmake /f $nmakeFile TOP=$nmakeDir
mistachkin00eb70d2015-04-04 00:02:07 +0000692 } else {
mistachkinda9da562015-11-02 23:29:58 +0000693 lappend result make
mistachkin00eb70d2015-04-04 00:02:07 +0000694 }
mistachkinda9da562015-11-02 23:29:58 +0000695 foreach makeOpt $makeOpts {
696 lappend result $makeOpt
697 }
698 lappend result clean
mistachkin72840562014-12-23 20:22:57 +0000699 foreach target $targets {
700 lappend result $target
701 }
702 lappend result CFLAGS=$cflags OPTS=$opts >>& test.log
703}
704
drh8f455552015-01-07 14:41:18 +0000705# The following procedure prints its arguments if ::TRACE is true.
706# And it executes the command of its arguments in the calling context
707# if ::DRYRUN is false.
drhd477eee2014-12-23 19:40:51 +0000708#
drh8f455552015-01-07 14:41:18 +0000709proc trace_cmd {args} {
710 if {$::TRACE} {
drhe31dc592015-08-14 12:53:37 +0000711 PUTS $args
drh8f455552015-01-07 14:41:18 +0000712 }
dana7f65972015-11-02 18:32:00 +0000713 set res ""
drh8f455552015-01-07 14:41:18 +0000714 if {!$::DRYRUN} {
dana7f65972015-11-02 18:32:00 +0000715 set res [uplevel 1 $args]
drh96110de2010-09-06 18:44:14 +0000716 }
dana7f65972015-11-02 18:32:00 +0000717 return $res
drh96110de2010-09-06 18:44:14 +0000718}
719
720
721# This proc processes the command line options passed to this script.
722# Currently the only option supported is "-makefile", default
723# "releasetest.mk". Set the ::MAKEFILE variable to the value of this
724# option.
725#
726proc process_options {argv} {
drhd477eee2014-12-23 19:40:51 +0000727 set ::SRCDIR [file normalize [file dirname [file dirname $::argv0]]]
drh7f8a93d2015-11-03 15:39:29 +0000728 set ::QUICK 0
729 set ::MSVC 0
730 set ::BUILDONLY 0
731 set ::DRYRUN 0
732 set ::TRACE 0
733 set ::JOBS 1
734 set ::PROGRESS_MSGS 0
735 set ::WITHTCL {}
drh2eeb7ae2014-10-10 17:44:03 +0000736 set config {}
drh96110de2010-09-06 18:44:14 +0000737 set platform $::tcl_platform(os)-$::tcl_platform(machine)
738
739 for {set i 0} {$i < [llength $argv]} {incr i} {
drhd477eee2014-12-23 19:40:51 +0000740 set x [lindex $argv $i]
741 if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
drhf167a402015-01-07 18:44:59 +0000742 switch -glob -- $x {
dana7f65972015-11-02 18:32:00 +0000743 -slave {
744 run_slave_test
745 exit
746 }
747
drhd477eee2014-12-23 19:40:51 +0000748 -srcdir {
drh96110de2010-09-06 18:44:14 +0000749 incr i
drhd477eee2014-12-23 19:40:51 +0000750 set ::SRCDIR [file normalize [lindex $argv $i]]
drh96110de2010-09-06 18:44:14 +0000751 }
752
753 -platform {
754 incr i
755 set platform [lindex $argv $i]
756 }
757
dana7f65972015-11-02 18:32:00 +0000758 -jobs {
759 incr i
760 set ::JOBS [lindex $argv $i]
761 }
762
drh7f8a93d2015-11-03 15:39:29 +0000763 -progress {
764 set ::PROGRESS_MSGS 1
765 }
766
drh96110de2010-09-06 18:44:14 +0000767 -quick {
drhd477eee2014-12-23 19:40:51 +0000768 set ::QUICK 1
drh96110de2010-09-06 18:44:14 +0000769 }
drh5bfff9d2015-01-08 01:05:42 +0000770 -veryquick {
771 set ::QUICK 2
drh96110de2010-09-06 18:44:14 +0000772 }
drh2eeb7ae2014-10-10 17:44:03 +0000773
774 -config {
775 incr i
776 set config [lindex $argv $i]
777 }
drhd477eee2014-12-23 19:40:51 +0000778
mistachkin00eb70d2015-04-04 00:02:07 +0000779 -msvc {
780 set ::MSVC 1
781 }
782
drhd477eee2014-12-23 19:40:51 +0000783 -buildonly {
784 set ::BUILDONLY 1
785 }
786
787 -dryrun {
788 set ::DRYRUN 1
789 }
790
drh8f455552015-01-07 14:41:18 +0000791 -trace {
792 set ::TRACE 1
793 }
794
drhd477eee2014-12-23 19:40:51 +0000795 -info {
drhe31dc592015-08-14 12:53:37 +0000796 PUTS "Command-line Options:"
797 PUTS " --srcdir $::SRCDIR"
798 PUTS " --platform [list $platform]"
799 PUTS " --config [list $config]"
drh905da632015-06-10 18:53:09 +0000800 if {$::QUICK} {
drhe31dc592015-08-14 12:53:37 +0000801 if {$::QUICK==1} {PUTS " --quick"}
802 if {$::QUICK==2} {PUTS " --veryquick"}
drh905da632015-06-10 18:53:09 +0000803 }
drhe31dc592015-08-14 12:53:37 +0000804 if {$::MSVC} {PUTS " --msvc"}
805 if {$::BUILDONLY} {PUTS " --buildonly"}
806 if {$::DRYRUN} {PUTS " --dryrun"}
807 if {$::TRACE} {PUTS " --trace"}
808 PUTS "\nAvailable --platform options:"
drhd477eee2014-12-23 19:40:51 +0000809 foreach y [lsort [array names ::Platforms]] {
drhe31dc592015-08-14 12:53:37 +0000810 PUTS " [list $y]"
drhd477eee2014-12-23 19:40:51 +0000811 }
drhe31dc592015-08-14 12:53:37 +0000812 PUTS "\nAvailable --config options:"
drhd477eee2014-12-23 19:40:51 +0000813 foreach y [lsort [array names ::Configs]] {
drhe31dc592015-08-14 12:53:37 +0000814 PUTS " [list $y]"
drhd477eee2014-12-23 19:40:51 +0000815 }
816 exit
817 }
mistachkin00eb70d2015-04-04 00:02:07 +0000818
819 -g {
mistachkinda9da562015-11-02 23:29:58 +0000820 lappend ::EXTRACONFIG [lindex $argv $i]
mistachkin00eb70d2015-04-04 00:02:07 +0000821 }
822
drh0ef84d02015-04-24 17:50:37 +0000823 -with-tcl=* {
824 set ::WITHTCL -$x
825 }
826
drhf167a402015-01-07 18:44:59 +0000827 -D* -
drh5bfff9d2015-01-08 01:05:42 +0000828 -O* -
drhf167a402015-01-07 18:44:59 +0000829 -enable-* -
830 -disable-* -
831 *=* {
832 lappend ::EXTRACONFIG [lindex $argv $i]
833 }
mistachkin72840562014-12-23 20:22:57 +0000834
drh96110de2010-09-06 18:44:14 +0000835 default {
drh573d88e2016-01-03 11:17:04 +0000836 PUTSERR ""
837 PUTSERR [string trim $::USAGE_MESSAGE]
drh96110de2010-09-06 18:44:14 +0000838 exit -1
839 }
840 }
841 }
842
drh96110de2010-09-06 18:44:14 +0000843 if {0==[info exists ::Platforms($platform)]} {
drhe31dc592015-08-14 12:53:37 +0000844 PUTS "Unknown platform: $platform"
drhd63fbb72015-11-13 12:52:34 +0000845 PUTSNNL "Set the -platform option to "
drh96110de2010-09-06 18:44:14 +0000846 set print [list]
847 foreach p [array names ::Platforms] {
848 lappend print "\"$p\""
849 }
850 lset print end "or [lindex $print end]"
drhe31dc592015-08-14 12:53:37 +0000851 PUTS "[join $print {, }]."
drh96110de2010-09-06 18:44:14 +0000852 exit
853 }
854
drh2eeb7ae2014-10-10 17:44:03 +0000855 if {$config!=""} {
drhe35626f2014-10-10 17:47:00 +0000856 if {[llength $config]==1} {lappend config fulltest}
drh2eeb7ae2014-10-10 17:44:03 +0000857 set ::CONFIGLIST $config
858 } else {
drh71258ab2015-11-04 16:34:58 +0000859 if {$::JOBS>1} {
860 set ::CONFIGLIST {}
861 foreach {target zConfig} [lreverse $::Platforms($platform)] {
862 append ::CONFIGLIST [format " %-25s %s\n" \
863 [list $zConfig] [list $target]]
864 }
865 } else {
866 set ::CONFIGLIST $::Platforms($platform)
867 }
drh2eeb7ae2014-10-10 17:44:03 +0000868 }
drhe31dc592015-08-14 12:53:37 +0000869 PUTS "Running the following test configurations for $platform:"
870 PUTS " [string trim $::CONFIGLIST]"
drhd63fbb72015-11-13 12:52:34 +0000871 PUTSNNL "Flags:"
872 if {$::PROGRESS_MSGS} {PUTSNNL " --progress"}
873 if {$::DRYRUN} {PUTSNNL " --dryrun"}
874 if {$::BUILDONLY} {PUTSNNL " --buildonly"}
875 if {$::MSVC} {PUTSNNL " --msvc"}
drh5bfff9d2015-01-08 01:05:42 +0000876 switch -- $::QUICK {
drhd63fbb72015-11-13 12:52:34 +0000877 1 {PUTSNNL " --quick"}
878 2 {PUTSNNL " --veryquick"}
drh5bfff9d2015-01-08 01:05:42 +0000879 }
drhd63fbb72015-11-13 12:52:34 +0000880 if {$::JOBS>1} {PUTSNNL " --jobs $::JOBS"}
drhe31dc592015-08-14 12:53:37 +0000881 PUTS ""
drh96110de2010-09-06 18:44:14 +0000882}
883
884# Main routine.
885#
886proc main {argv} {
887
888 # Process any command line options.
drhf167a402015-01-07 18:44:59 +0000889 set ::EXTRACONFIG {}
drh96110de2010-09-06 18:44:14 +0000890 process_options $argv
drhe31dc592015-08-14 12:53:37 +0000891 PUTS [string repeat * 79]
drh96110de2010-09-06 18:44:14 +0000892
drh97876ee2014-12-24 23:35:36 +0000893 set ::NERR 0
894 set ::NTEST 0
drh277b4e42014-12-29 02:55:58 +0000895 set ::NTESTCASE 0
896 set ::NERRCASE 0
drh5bfff9d2015-01-08 01:05:42 +0000897 set ::SQLITE_VERSION {}
drhd477eee2014-12-23 19:40:51 +0000898 set STARTTIME [clock seconds]
drh96110de2010-09-06 18:44:14 +0000899 foreach {zConfig target} $::CONFIGLIST {
mistachkin00eb70d2015-04-04 00:02:07 +0000900 if {$::MSVC && ($zConfig eq "Sanitize" || "checksymbols" in $target
901 || "valgrindtest" in $target)} {
drhe31dc592015-08-14 12:53:37 +0000902 PUTS "Skipping $zConfig / $target for MSVC..."
mistachkin00eb70d2015-04-04 00:02:07 +0000903 continue
904 }
drh5bfff9d2015-01-08 01:05:42 +0000905 if {$target ne "checksymbols"} {
906 switch -- $::QUICK {
drh905da632015-06-10 18:53:09 +0000907 1 {set target quicktest}
drh5bfff9d2015-01-08 01:05:42 +0000908 2 {set target smoketest}
909 }
mistachkin00eb70d2015-04-04 00:02:07 +0000910 if {$::BUILDONLY} {
911 set target testfixture
drh7f8a93d2015-11-03 15:39:29 +0000912 if {$::tcl_platform(platform)=="windows"} {
913 append target .exe
914 }
mistachkin00eb70d2015-04-04 00:02:07 +0000915 }
drh5bfff9d2015-01-08 01:05:42 +0000916 }
drhf167a402015-01-07 18:44:59 +0000917 set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]
drh96110de2010-09-06 18:44:14 +0000918
drhd477eee2014-12-23 19:40:51 +0000919 incr NTEST
dana7f65972015-11-02 18:32:00 +0000920 add_test_suite all $zConfig $target $config_options
drh96110de2010-09-06 18:44:14 +0000921
922 # If the configuration included the SQLITE_DEBUG option, then remove
923 # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
924 # add it and run veryquick.test.
drh5bfff9d2015-01-08 01:05:42 +0000925 if {$target!="checksymbols" && $target!="valgrindtest"
drhf3320712015-04-25 13:39:29 +0000926 && $target!="fuzzoomtest" && !$::BUILDONLY && $::QUICK<2} {
danb136e902012-12-10 10:22:48 +0000927 set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
drhbd41d562014-12-30 20:40:32 +0000928 set xtarget $target
drhaf700b32014-12-31 20:35:11 +0000929 regsub -all {fulltest[a-z]*} $xtarget test xtarget
drhf3320712015-04-25 13:39:29 +0000930 regsub -all {fuzzoomtest} $xtarget fuzztest xtarget
danb136e902012-12-10 10:22:48 +0000931 if {$debug_idx < 0} {
drhd477eee2014-12-23 19:40:51 +0000932 incr NTEST
drhbd41d562014-12-30 20:40:32 +0000933 append config_options " -DSQLITE_DEBUG=1"
dana7f65972015-11-02 18:32:00 +0000934 add_test_suite all "${zConfig}_debug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +0000935 } else {
drhd477eee2014-12-23 19:40:51 +0000936 incr NTEST
drhbd41d562014-12-30 20:40:32 +0000937 regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options
938 regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options
dana7f65972015-11-02 18:32:00 +0000939 add_test_suite all "${zConfig}_ndebug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +0000940 }
drh96110de2010-09-06 18:44:14 +0000941 }
drh96110de2010-09-06 18:44:14 +0000942 }
drh96110de2010-09-06 18:44:14 +0000943
dana7f65972015-11-02 18:32:00 +0000944 run_all_test_suites $all
945
drhd477eee2014-12-23 19:40:51 +0000946 set elapsetime [expr {[clock seconds]-$STARTTIME}]
drh97876ee2014-12-24 23:35:36 +0000947 set hr [expr {$elapsetime/3600}]
948 set min [expr {($elapsetime/60)%60}]
949 set sec [expr {$elapsetime%60}]
950 set etime [format (%02d:%02d:%02d) $hr $min $sec]
drh573d88e2016-01-03 11:17:04 +0000951 if {$::JOBS>1} {append etime " $::JOBS cores"}
952 if {[catch {exec hostname} HNAME]==0} {append etime " on $HNAME"}
drhe31dc592015-08-14 12:53:37 +0000953 PUTS [string repeat * 79]
drhb1031f02015-09-10 15:20:49 +0000954 incr ::NERRCASE $::NERR
drhe31dc592015-08-14 12:53:37 +0000955 PUTS "$::NERRCASE failures out of $::NTESTCASE tests in $etime"
drh5bfff9d2015-01-08 01:05:42 +0000956 if {$::SQLITE_VERSION ne ""} {
drhe31dc592015-08-14 12:53:37 +0000957 PUTS "SQLite $::SQLITE_VERSION"
drh96110de2010-09-06 18:44:14 +0000958 }
959}
960
961main $argv