blob: 746fc9bb354cddfee376609419c113f9a7b77d0e [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)
drhd477eee2014-12-23 19:40:51 +000017 --buildonly (Just build testfixture - do not run)
mistachkin72840562014-12-23 20:22:57 +000018 --dryrun (Print what would have happened)
drhd477eee2014-12-23 19:40:51 +000019 --info (Show diagnostic info)
drh96110de2010-09-06 18:44:14 +000020
drhd477eee2014-12-23 19:40:51 +000021The default value for --srcdir is the parent of the directory holding
22this script.
drh96110de2010-09-06 18:44:14 +000023
drhd477eee2014-12-23 19:40:51 +000024The script determines the default value for --platform using the
mistachkin72840562014-12-23 20:22:57 +000025$tcl_platform(os) and $tcl_platform(machine) variables. Supported
drh96110de2010-09-06 18:44:14 +000026platforms are "Linux-x86", "Linux-x86_64" and "Darwin-i386".
27
drhd477eee2014-12-23 19:40:51 +000028Every test begins with a fresh run of the configure script at the top
29of the SQLite source tree.
drh96110de2010-09-06 18:44:14 +000030}
31
drh6aed1c42015-01-10 15:21:26 +000032# Omit comments (text between # and \n) in a long multi-line string.
33#
34proc strip_comments {in} {
35 regsub -all {#[^\n]*\n} $in {} out
36 return $out
37}
38
39array set ::Configs [strip_comments {
drh96110de2010-09-06 18:44:14 +000040 "Default" {
41 -O2
drhedb31cd2015-01-08 02:15:11 +000042 --disable-amalgamation --disable-shared
drh149735d2015-01-01 19:53:10 +000043 }
drh4081d5d2015-01-01 23:02:01 +000044 "Sanitize" {
drh149735d2015-01-01 19:53:10 +000045 CC=clang -fsanitize=undefined
drh4081d5d2015-01-01 23:02:01 +000046 -DSQLITE_ENABLE_STAT4
dan56089732011-04-06 12:37:09 +000047 }
drh0ede9eb2015-01-10 16:49:23 +000048 "Have-Not" {
49 # The "Have-Not" configuration sets all possible -UHAVE_feature options
50 # in order to verify that the code works even on platforms that lack
51 # these support services.
52 -DHAVE_FDATASYNC=0
53 -DHAVE_GMTIME_R=0
drh8567d402015-01-10 18:22:06 +000054 -DHAVE_ISNAN=0
drh0ede9eb2015-01-10 16:49:23 +000055 -DHAVE_LOCALTIME_R=0
56 -DHAVE_LOCALTIME_S=0
57 -DHAVE_MALLOC_USABLE_SIZE=0
58 -DHAVE_STRCHRNUL=0
59 -DHAVE_USLEEP=0
60 -DHAVE_UTIME=0
61 }
drh96110de2010-09-06 18:44:14 +000062 "Unlock-Notify" {
63 -O2
64 -DSQLITE_ENABLE_UNLOCK_NOTIFY
65 -DSQLITE_THREADSAFE
drh96110de2010-09-06 18:44:14 +000066 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
67 }
68 "Secure-Delete" {
69 -O2
70 -DSQLITE_SECURE_DELETE=1
71 -DSQLITE_SOUNDEX=1
72 }
73 "Update-Delete-Limit" {
74 -O2
75 -DSQLITE_DEFAULT_FILE_FORMAT=4
76 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
drh1a803842015-01-09 20:00:21 +000077 -DSQLITE_ENABLE_STMT_SCANSTATUS
drh96110de2010-09-06 18:44:14 +000078 }
danb136e902012-12-10 10:22:48 +000079 "Check-Symbols" {
80 -DSQLITE_MEMDEBUG=1
81 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
82 -DSQLITE_ENABLE_FTS3=1
83 -DSQLITE_ENABLE_RTREE=1
84 -DSQLITE_ENABLE_MEMSYS5=1
85 -DSQLITE_ENABLE_MEMSYS3=1
86 -DSQLITE_ENABLE_COLUMN_METADATA=1
87 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
88 -DSQLITE_SECURE_DELETE=1
89 -DSQLITE_SOUNDEX=1
90 -DSQLITE_ENABLE_ATOMIC_WRITE=1
danb136e902012-12-10 10:22:48 +000091 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
92 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
drh4081d5d2015-01-01 23:02:01 +000093 -DSQLITE_ENABLE_STAT4
drh1a803842015-01-09 20:00:21 +000094 -DSQLITE_ENABLE_STMT_SCANSTATUS
danb136e902012-12-10 10:22:48 +000095 }
drh96110de2010-09-06 18:44:14 +000096 "Debug-One" {
drh8f455552015-01-07 14:41:18 +000097 --disable-shared
drh96110de2010-09-06 18:44:14 +000098 -O2
99 -DSQLITE_DEBUG=1
100 -DSQLITE_MEMDEBUG=1
101 -DSQLITE_MUTEX_NOOP=1
102 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
103 -DSQLITE_ENABLE_FTS3=1
104 -DSQLITE_ENABLE_RTREE=1
105 -DSQLITE_ENABLE_MEMSYS5=1
106 -DSQLITE_ENABLE_MEMSYS3=1
107 -DSQLITE_ENABLE_COLUMN_METADATA=1
drh4081d5d2015-01-01 23:02:01 +0000108 -DSQLITE_ENABLE_STAT4
drhedb31cd2015-01-08 02:15:11 +0000109 -DSQLITE_MAX_ATTACHED=125
drh96110de2010-09-06 18:44:14 +0000110 }
drh96110de2010-09-06 18:44:14 +0000111 "Device-One" {
112 -O2
113 -DSQLITE_DEBUG=1
drh96110de2010-09-06 18:44:14 +0000114 -DSQLITE_DEFAULT_AUTOVACUUM=1
drh96110de2010-09-06 18:44:14 +0000115 -DSQLITE_DEFAULT_CACHE_SIZE=64
dan1c22a182010-09-13 11:29:02 +0000116 -DSQLITE_DEFAULT_PAGE_SIZE=1024
drh96110de2010-09-06 18:44:14 +0000117 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
dan1c22a182010-09-13 11:29:02 +0000118 -DSQLITE_DISABLE_LFS=1
drh96110de2010-09-06 18:44:14 +0000119 -DSQLITE_ENABLE_ATOMIC_WRITE=1
dan1c22a182010-09-13 11:29:02 +0000120 -DSQLITE_ENABLE_IOTRACE=1
121 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
122 -DSQLITE_MAX_PAGE_SIZE=4096
123 -DSQLITE_OMIT_LOAD_EXTENSION=1
124 -DSQLITE_OMIT_PROGRESS_CALLBACK=1
125 -DSQLITE_OMIT_VIRTUALTABLE=1
126 -DSQLITE_TEMP_STORE=3
127 }
128 "Device-Two" {
129 -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
130 -DSQLITE_DEFAULT_AUTOVACUUM=1
131 -DSQLITE_DEFAULT_CACHE_SIZE=1000
132 -DSQLITE_DEFAULT_LOCKING_MODE=0
133 -DSQLITE_DEFAULT_PAGE_SIZE=1024
134 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000
135 -DSQLITE_DISABLE_LFS=1
136 -DSQLITE_ENABLE_FTS3=1
137 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
138 -DSQLITE_ENABLE_RTREE=1
139 -DSQLITE_MAX_COMPOUND_SELECT=50
140 -DSQLITE_MAX_PAGE_SIZE=32768
dan1c22a182010-09-13 11:29:02 +0000141 -DSQLITE_OMIT_TRACE=1
142 -DSQLITE_TEMP_STORE=3
143 -DSQLITE_THREADSAFE=2
drh96110de2010-09-06 18:44:14 +0000144 }
145 "Locking-Style" {
146 -O2
147 -DSQLITE_ENABLE_LOCKING_STYLE=1
148 }
149 "OS-X" {
drh149735d2015-01-01 19:53:10 +0000150 -O1 # Avoid a compiler bug in gcc 4.2.1 build 5658
dan1c22a182010-09-13 11:29:02 +0000151 -DSQLITE_OMIT_LOAD_EXTENSION=1
152 -DSQLITE_DEFAULT_MEMSTATUS=0
153 -DSQLITE_THREADSAFE=2
154 -DSQLITE_OS_UNIX=1
drh96110de2010-09-06 18:44:14 +0000155 -DSQLITE_ENABLE_LOCKING_STYLE=1
dan1c22a182010-09-13 11:29:02 +0000156 -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
mistachkin72840562014-12-23 20:22:57 +0000163 -DSQLITE_DEBUG=1
dan1c22a182010-09-13 11:29:02 +0000164 -DSQLITE_PREFER_PROXY_LOCKING=1
drhc67d6502014-12-31 15:14:29 +0000165 -DSQLITE_ENABLE_API_ARMOR=1
drh96110de2010-09-06 18:44:14 +0000166 }
167 "Extra-Robustness" {
168 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
dan56089732011-04-06 12:37:09 +0000169 -DSQLITE_MAX_ATTACHED=62
drh96110de2010-09-06 18:44:14 +0000170 }
dan4dc3d732012-08-20 17:24:48 +0000171 "Devkit" {
172 -DSQLITE_DEFAULT_FILE_FORMAT=4
173 -DSQLITE_MAX_ATTACHED=30
174 -DSQLITE_ENABLE_COLUMN_METADATA
175 -DSQLITE_ENABLE_FTS4
176 -DSQLITE_ENABLE_FTS4_PARENTHESIS
177 -DSQLITE_DISABLE_FTS4_DEFERRED
178 -DSQLITE_ENABLE_RTREE
179 }
dand79d27a2014-08-12 14:06:13 +0000180 "No-lookaside" {
181 -DSQLITE_TEST_REALLOC_STRESS=1
182 -DSQLITE_OMIT_LOOKASIDE=1
183 -DHAVE_USLEEP=1
184 }
drh8a2a0f52015-01-07 14:09:41 +0000185 "Valgrind" {
186 -DSQLITE_ENABLE_STAT4
187 -DSQLITE_ENABLE_FTS4
188 -DSQLITE_ENABLE_RTREE
189 }
drh6aed1c42015-01-10 15:21:26 +0000190
191 # The next group of configurations are used only by the
192 # Failure-Detection platform. They are all the same, but we need
193 # different names for them all so that they results appear in separate
194 # subdirectories.
195 #
drhedb31cd2015-01-08 02:15:11 +0000196 Fail0 {-O0}
197 Fail2 {-O0}
198 Fail3 {-O0}
drhdb6bafa2015-01-09 21:54:58 +0000199 Fail4 {-O0}
drh6aed1c42015-01-10 15:21:26 +0000200}]
drh96110de2010-09-06 18:44:14 +0000201
drh6aed1c42015-01-10 15:21:26 +0000202array set ::Platforms [strip_comments {
drh96110de2010-09-06 18:44:14 +0000203 Linux-x86_64 {
danb136e902012-12-10 10:22:48 +0000204 "Check-Symbols" checksymbols
drhbd41d562014-12-30 20:40:32 +0000205 "Debug-One" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000206 "Have-Not" test
drh96110de2010-09-06 18:44:14 +0000207 "Secure-Delete" test
208 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
drh96110de2010-09-06 18:44:14 +0000209 "Update-Delete-Limit" test
drh96110de2010-09-06 18:44:14 +0000210 "Extra-Robustness" test
dan1c22a182010-09-13 11:29:02 +0000211 "Device-Two" test
dand79d27a2014-08-12 14:06:13 +0000212 "No-lookaside" test
dan5d510d42014-10-15 15:28:27 +0000213 "Devkit" test
drh8a2a0f52015-01-07 14:09:41 +0000214 "Sanitize" {QUICKTEST_OMIT=func4.test,nan.test test}
215 "Valgrind" valgrindtest
dan5d510d42014-10-15 15:28:27 +0000216 "Default" "threadtest fulltest"
drh96110de2010-09-06 18:44:14 +0000217 "Device-One" fulltest
218 }
dan1c22a182010-09-13 11:29:02 +0000219 Linux-i686 {
dan4dc3d732012-08-20 17:24:48 +0000220 "Devkit" test
drh0ede9eb2015-01-10 16:49:23 +0000221 "Have-Not" test
dan1c22a182010-09-13 11:29:02 +0000222 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
dan1c22a182010-09-13 11:29:02 +0000223 "Device-One" test
dand38bc1b2010-09-13 12:15:36 +0000224 "Device-Two" test
225 "Default" "threadtest fulltest"
dan1c22a182010-09-13 11:29:02 +0000226 }
drh96110de2010-09-06 18:44:14 +0000227 Darwin-i386 {
drhbd41d562014-12-30 20:40:32 +0000228 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000229 "Have-Not" test
dand38bc1b2010-09-13 12:15:36 +0000230 "OS-X" "threadtest fulltest"
drh96110de2010-09-06 18:44:14 +0000231 }
drhbcbac682014-12-31 18:55:09 +0000232 Darwin-x86_64 {
233 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000234 "Have-Not" test
drhbcbac682014-12-31 18:55:09 +0000235 "OS-X" "threadtest fulltest"
236 }
mistachkin72840562014-12-23 20:22:57 +0000237 "Windows NT-intel" {
drhbd41d562014-12-30 20:40:32 +0000238 "Default" "mptest fulltestonly"
drh0ede9eb2015-01-10 16:49:23 +0000239 "Have-Not" test
mistachkin72840562014-12-23 20:22:57 +0000240 }
drh6aed1c42015-01-10 15:21:26 +0000241
242 # The Failure-Detection platform runs various tests that deliberately
243 # fail. This is used as a test of this script to verify that this script
244 # correctly identifies failures.
245 #
drhedb31cd2015-01-08 02:15:11 +0000246 Failure-Detection {
247 Fail0 "TEST_FAILURE=0 test"
248 Sanitize "TEST_FAILURE=1 test"
249 Fail2 "TEST_FAILURE=2 valgrindtest"
250 Fail3 "TEST_FAILURE=3 valgrindtest"
drhdb6bafa2015-01-09 21:54:58 +0000251 Fail4 "TEST_FAILURE=4 test"
drhedb31cd2015-01-08 02:15:11 +0000252 }
drh6aed1c42015-01-10 15:21:26 +0000253}]
drh96110de2010-09-06 18:44:14 +0000254
dane7152dc2011-07-07 08:19:16 +0000255
drh96110de2010-09-06 18:44:14 +0000256# End of configuration section.
257#########################################################################
258#########################################################################
259
260foreach {key value} [array get ::Platforms] {
261 foreach {v t} $value {
262 if {0==[info exists ::Configs($v)]} {
263 puts stderr "No such configuration: \"$v\""
264 exit -1
265 }
266 }
267}
268
drh277b4e42014-12-29 02:55:58 +0000269# Open the file $logfile and look for a report on the number of errors
270# and the number of test cases run. Add these values to the global
271# $::NERRCASE and $::NTESTCASE variables.
272#
273# If any errors occur, then write into $errmsgVar the text of an appropriate
274# one-line error message to show on the output.
275#
276proc count_tests_and_errors {logfile rcVar errmsgVar} {
drhcb281a92014-12-29 19:54:10 +0000277 if {$::DRYRUN} return
drh277b4e42014-12-29 02:55:58 +0000278 upvar 1 $rcVar rc $errmsgVar errmsg
279 set fd [open $logfile rb]
280 set seen 0
281 while {![eof $fd]} {
282 set line [gets $fd]
drhbd41d562014-12-30 20:40:32 +0000283 if {[regexp {(\d+) errors out of (\d+) tests} $line all nerr ntest]} {
drh277b4e42014-12-29 02:55:58 +0000284 incr ::NERRCASE $nerr
285 incr ::NTESTCASE $ntest
286 set seen 1
287 if {$nerr>0} {
288 set rc 1
289 set errmsg $line
290 }
drh277b4e42014-12-29 02:55:58 +0000291 }
drh4081d5d2015-01-01 23:02:01 +0000292 if {[regexp {runtime error: +(.*)} $line all msg]} {
293 incr ::NERRCASE
294 if {$rc==0} {
295 set rc 1
296 set errmsg $msg
297 }
298 }
drh8a2a0f52015-01-07 14:09:41 +0000299 if {[regexp {ERROR SUMMARY: (\d+) errors.*} $line all cnt] && $cnt>0} {
300 incr ::NERRCASE
301 if {$rc==0} {
302 set rc 1
303 set errmsg $all
304 }
305 }
drh5bfff9d2015-01-08 01:05:42 +0000306 if {[regexp {^VERSION: 3\.\d+.\d+} $line]} {
307 set v [string range $line 9 end]
308 if {$::SQLITE_VERSION eq ""} {
309 set ::SQLITE_VERSION $v
310 } elseif {$::SQLITE_VERSION ne $v} {
311 set rc 1
312 set errmsg "version conflict: {$::SQLITE_VERSION} vs. {$v}"
313 }
314 }
drh277b4e42014-12-29 02:55:58 +0000315 }
316 close $fd
317 if {!$seen} {
318 set rc 1
319 set errmsg "Test did not complete"
drhdb6bafa2015-01-09 21:54:58 +0000320 if {[file readable core]} {
321 append errmsg " - core file exists"
322 }
drh277b4e42014-12-29 02:55:58 +0000323 }
324}
325
drh96110de2010-09-06 18:44:14 +0000326proc run_test_suite {name testtarget config} {
mistachkin72840562014-12-23 20:22:57 +0000327 # Tcl variable $opts is used to build up the value used to set the
drh96110de2010-09-06 18:44:14 +0000328 # OPTS Makefile variable. Variable $cflags holds the value for
329 # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
330 # CFLAGS is only passed to gcc.
331 #
drhd477eee2014-12-23 19:40:51 +0000332 set cflags "-g"
drh96110de2010-09-06 18:44:14 +0000333 set opts ""
drha780d8d2015-01-03 18:59:17 +0000334 set title ${name}($testtarget)
drh8f455552015-01-07 14:41:18 +0000335 set configOpts ""
drha780d8d2015-01-03 18:59:17 +0000336
drh149735d2015-01-01 19:53:10 +0000337 regsub -all {#[^\n]*\n} $config \n config
drh96110de2010-09-06 18:44:14 +0000338 foreach arg $config {
drh0ede9eb2015-01-10 16:49:23 +0000339 if {[regexp {^-[UD]} $arg]} {
drh96110de2010-09-06 18:44:14 +0000340 lappend opts $arg
drh0ede9eb2015-01-10 16:49:23 +0000341 } elseif {[regexp {^[A-Z]+=} $arg]} {
drh149735d2015-01-01 19:53:10 +0000342 lappend testtarget $arg
drh8f455552015-01-07 14:41:18 +0000343 } elseif {[regexp {^--(enable|disable)-} $arg]} {
344 lappend configOpts $arg
drh96110de2010-09-06 18:44:14 +0000345 } else {
346 lappend cflags $arg
347 }
348 }
349
350 set cflags [join $cflags " "]
351 set opts [join $opts " "]
352 append opts " -DSQLITE_NO_SYNC=1 -DHAVE_USLEEP"
353
354 # Set the sub-directory to use.
355 #
356 set dir [string tolower [string map {- _ " " _} $name]]
357
358 if {$::tcl_platform(platform)=="windows"} {
359 append opts " -DSQLITE_OS_WIN=1"
drh96110de2010-09-06 18:44:14 +0000360 } else {
361 append opts " -DSQLITE_OS_UNIX=1"
362 }
363
drh8f455552015-01-07 14:41:18 +0000364 if {!$::TRACE} {
drhe43ff922014-12-23 20:41:13 +0000365 set n [string length $title]
drhc67d6502014-12-31 15:14:29 +0000366 puts -nonewline "${title}[string repeat . [expr {63-$n}]]"
drhd477eee2014-12-23 19:40:51 +0000367 flush stdout
368 }
drh96110de2010-09-06 18:44:14 +0000369
drh8f455552015-01-07 14:41:18 +0000370 set rc 0
drhd477eee2014-12-23 19:40:51 +0000371 set tm1 [clock seconds]
372 set origdir [pwd]
drh8f455552015-01-07 14:41:18 +0000373 trace_cmd file mkdir $dir
374 trace_cmd cd $dir
drh277b4e42014-12-29 02:55:58 +0000375 set errmsg {}
drhdb6bafa2015-01-09 21:54:58 +0000376 catch {file delete core}
drh8f455552015-01-07 14:41:18 +0000377 set rc [catch [configureCommand $configOpts]]
drhd477eee2014-12-23 19:40:51 +0000378 if {!$rc} {
mistachkin72840562014-12-23 20:22:57 +0000379 set rc [catch [makeCommand $testtarget $cflags $opts]]
drh277b4e42014-12-29 02:55:58 +0000380 count_tests_and_errors test.log rc errmsg
drhd477eee2014-12-23 19:40:51 +0000381 }
drh8f455552015-01-07 14:41:18 +0000382 trace_cmd cd $origdir
dan1c22a182010-09-13 11:29:02 +0000383 set tm2 [clock seconds]
384
drh8f455552015-01-07 14:41:18 +0000385 if {!$::TRACE} {
drh7203aed2015-01-01 18:54:23 +0000386 set hours [expr {($tm2-$tm1)/3600}]
drhe43ff922014-12-23 20:41:13 +0000387 set minutes [expr {(($tm2-$tm1)/60)%60}]
drhd477eee2014-12-23 19:40:51 +0000388 set seconds [expr {($tm2-$tm1)%60}]
drhe43ff922014-12-23 20:41:13 +0000389 set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
drhd477eee2014-12-23 19:40:51 +0000390 if {$rc} {
391 puts " FAIL $tm"
392 incr ::NERR
drh277b4e42014-12-29 02:55:58 +0000393 if {$errmsg!=""} {puts " $errmsg"}
drhd477eee2014-12-23 19:40:51 +0000394 } else {
395 puts " Ok $tm"
396 }
397 }
398}
399
mistachkin72840562014-12-23 20:22:57 +0000400# The following procedure returns the "configure" command to be exectued for
401# the current platform, which may be Windows (via MinGW, etc).
402#
drh8f455552015-01-07 14:41:18 +0000403proc configureCommand {opts} {
404 set result [list trace_cmd exec]
mistachkin72840562014-12-23 20:22:57 +0000405 if {$::tcl_platform(platform)=="windows"} {
406 lappend result sh
407 }
drh8f455552015-01-07 14:41:18 +0000408 lappend result $::SRCDIR/configure --enable-load-extension
409 foreach x $opts {lappend result $x}
410 lappend result >& test.log
mistachkin72840562014-12-23 20:22:57 +0000411}
412
413# The following procedure returns the "make" command to be executed for the
414# specified targets, compiler flags, and options.
415#
416proc makeCommand { targets cflags opts } {
drh8f455552015-01-07 14:41:18 +0000417 set result [list trace_cmd exec make clean]
mistachkin72840562014-12-23 20:22:57 +0000418 foreach target $targets {
419 lappend result $target
420 }
421 lappend result CFLAGS=$cflags OPTS=$opts >>& test.log
422}
423
drh8f455552015-01-07 14:41:18 +0000424# The following procedure prints its arguments if ::TRACE is true.
425# And it executes the command of its arguments in the calling context
426# if ::DRYRUN is false.
drhd477eee2014-12-23 19:40:51 +0000427#
drh8f455552015-01-07 14:41:18 +0000428proc trace_cmd {args} {
429 if {$::TRACE} {
drhd477eee2014-12-23 19:40:51 +0000430 puts $args
drh8f455552015-01-07 14:41:18 +0000431 }
432 if {!$::DRYRUN} {
drhd477eee2014-12-23 19:40:51 +0000433 uplevel 1 $args
drh96110de2010-09-06 18:44:14 +0000434 }
435}
436
437
438# This proc processes the command line options passed to this script.
439# Currently the only option supported is "-makefile", default
440# "releasetest.mk". Set the ::MAKEFILE variable to the value of this
441# option.
442#
443proc process_options {argv} {
drhd477eee2014-12-23 19:40:51 +0000444 set ::SRCDIR [file normalize [file dirname [file dirname $::argv0]]]
445 set ::QUICK 0
446 set ::BUILDONLY 0
447 set ::DRYRUN 0
448 set ::EXEC exec
drh8f455552015-01-07 14:41:18 +0000449 set ::TRACE 0
drh2eeb7ae2014-10-10 17:44:03 +0000450 set config {}
drh96110de2010-09-06 18:44:14 +0000451 set platform $::tcl_platform(os)-$::tcl_platform(machine)
452
453 for {set i 0} {$i < [llength $argv]} {incr i} {
drhd477eee2014-12-23 19:40:51 +0000454 set x [lindex $argv $i]
455 if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
drhf167a402015-01-07 18:44:59 +0000456 switch -glob -- $x {
drhd477eee2014-12-23 19:40:51 +0000457 -srcdir {
drh96110de2010-09-06 18:44:14 +0000458 incr i
drhd477eee2014-12-23 19:40:51 +0000459 set ::SRCDIR [file normalize [lindex $argv $i]]
drh96110de2010-09-06 18:44:14 +0000460 }
461
462 -platform {
463 incr i
464 set platform [lindex $argv $i]
465 }
466
467 -quick {
drhd477eee2014-12-23 19:40:51 +0000468 set ::QUICK 1
drh96110de2010-09-06 18:44:14 +0000469 }
drh5bfff9d2015-01-08 01:05:42 +0000470 -veryquick {
471 set ::QUICK 2
472 }
drh2eeb7ae2014-10-10 17:44:03 +0000473
474 -config {
475 incr i
476 set config [lindex $argv $i]
477 }
drhd477eee2014-12-23 19:40:51 +0000478
479 -buildonly {
480 set ::BUILDONLY 1
481 }
482
483 -dryrun {
484 set ::DRYRUN 1
485 }
486
drh8f455552015-01-07 14:41:18 +0000487 -trace {
488 set ::TRACE 1
489 }
490
drhd477eee2014-12-23 19:40:51 +0000491 -info {
492 puts "Command-line Options:"
493 puts " --srcdir $::SRCDIR"
494 puts " --platform [list $platform]"
495 puts " --config [list $config]"
496 if {$::QUICK} {puts " --quick"}
497 if {$::BUILDONLY} {puts " --buildonly"}
498 if {$::DRYRUN} {puts " --dryrun"}
drh8f455552015-01-07 14:41:18 +0000499 if {$::TRACE} {puts " --trace"}
drhd477eee2014-12-23 19:40:51 +0000500 puts "\nAvailable --platform options:"
501 foreach y [lsort [array names ::Platforms]] {
502 puts " [list $y]"
503 }
504 puts "\nAvailable --config options:"
505 foreach y [lsort [array names ::Configs]] {
506 puts " [list $y]"
507 }
508 exit
509 }
drhf167a402015-01-07 18:44:59 +0000510 -g -
511 -D* -
drh5bfff9d2015-01-08 01:05:42 +0000512 -O* -
drhf167a402015-01-07 18:44:59 +0000513 -enable-* -
514 -disable-* -
515 *=* {
516 lappend ::EXTRACONFIG [lindex $argv $i]
517 }
mistachkin72840562014-12-23 20:22:57 +0000518
drh96110de2010-09-06 18:44:14 +0000519 default {
520 puts stderr ""
521 puts stderr [string trim $::USAGE_MESSAGE]
522 exit -1
523 }
524 }
525 }
526
drh96110de2010-09-06 18:44:14 +0000527 if {0==[info exists ::Platforms($platform)]} {
528 puts "Unknown platform: $platform"
529 puts -nonewline "Set the -platform option to "
530 set print [list]
531 foreach p [array names ::Platforms] {
532 lappend print "\"$p\""
533 }
534 lset print end "or [lindex $print end]"
535 puts "[join $print {, }]."
536 exit
537 }
538
drh2eeb7ae2014-10-10 17:44:03 +0000539 if {$config!=""} {
drhe35626f2014-10-10 17:47:00 +0000540 if {[llength $config]==1} {lappend config fulltest}
drh2eeb7ae2014-10-10 17:44:03 +0000541 set ::CONFIGLIST $config
542 } else {
543 set ::CONFIGLIST $::Platforms($platform)
544 }
drhd477eee2014-12-23 19:40:51 +0000545 puts "Running the following test configurations for $platform:"
drh96110de2010-09-06 18:44:14 +0000546 puts " [string trim $::CONFIGLIST]"
drhd477eee2014-12-23 19:40:51 +0000547 puts -nonewline "Flags:"
548 if {$::DRYRUN} {puts -nonewline " --dryrun"}
549 if {$::BUILDONLY} {puts -nonewline " --buildonly"}
drh5bfff9d2015-01-08 01:05:42 +0000550 switch -- $::QUICK {
551 1 {puts -nonewline " --quick"}
552 2 {puts -nonewline " --veryquick"}
553 }
drhd477eee2014-12-23 19:40:51 +0000554 puts ""
drh96110de2010-09-06 18:44:14 +0000555}
556
557# Main routine.
558#
559proc main {argv} {
560
561 # Process any command line options.
drhf167a402015-01-07 18:44:59 +0000562 set ::EXTRACONFIG {}
drh96110de2010-09-06 18:44:14 +0000563 process_options $argv
drhc67d6502014-12-31 15:14:29 +0000564 puts [string repeat * 79]
drh96110de2010-09-06 18:44:14 +0000565
drh97876ee2014-12-24 23:35:36 +0000566 set ::NERR 0
567 set ::NTEST 0
drh277b4e42014-12-29 02:55:58 +0000568 set ::NTESTCASE 0
569 set ::NERRCASE 0
drh5bfff9d2015-01-08 01:05:42 +0000570 set ::SQLITE_VERSION {}
drhd477eee2014-12-23 19:40:51 +0000571 set STARTTIME [clock seconds]
drh96110de2010-09-06 18:44:14 +0000572 foreach {zConfig target} $::CONFIGLIST {
drh5bfff9d2015-01-08 01:05:42 +0000573 if {$target ne "checksymbols"} {
574 switch -- $::QUICK {
575 1 {set target test}
576 2 {set target smoketest}
577 }
578 if {$::BUILDONLY} {set target testfixture}
579 }
drhf167a402015-01-07 18:44:59 +0000580 set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]
drh96110de2010-09-06 18:44:14 +0000581
drhd477eee2014-12-23 19:40:51 +0000582 incr NTEST
drh96110de2010-09-06 18:44:14 +0000583 run_test_suite $zConfig $target $config_options
584
585 # If the configuration included the SQLITE_DEBUG option, then remove
586 # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
587 # add it and run veryquick.test.
drh5bfff9d2015-01-08 01:05:42 +0000588 if {$target!="checksymbols" && $target!="valgrindtest"
589 && !$::BUILDONLY && $::QUICK<2} {
danb136e902012-12-10 10:22:48 +0000590 set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
drhbd41d562014-12-30 20:40:32 +0000591 set xtarget $target
drhaf700b32014-12-31 20:35:11 +0000592 regsub -all {fulltest[a-z]*} $xtarget test xtarget
danb136e902012-12-10 10:22:48 +0000593 if {$debug_idx < 0} {
drhd477eee2014-12-23 19:40:51 +0000594 incr NTEST
drhbd41d562014-12-30 20:40:32 +0000595 append config_options " -DSQLITE_DEBUG=1"
596 run_test_suite "${zConfig}_debug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +0000597 } else {
drhd477eee2014-12-23 19:40:51 +0000598 incr NTEST
drhbd41d562014-12-30 20:40:32 +0000599 regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options
600 regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options
601 run_test_suite "${zConfig}_ndebug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +0000602 }
drh96110de2010-09-06 18:44:14 +0000603 }
drh96110de2010-09-06 18:44:14 +0000604 }
drhd477eee2014-12-23 19:40:51 +0000605
606 set elapsetime [expr {[clock seconds]-$STARTTIME}]
drh97876ee2014-12-24 23:35:36 +0000607 set hr [expr {$elapsetime/3600}]
608 set min [expr {($elapsetime/60)%60}]
609 set sec [expr {$elapsetime%60}]
610 set etime [format (%02d:%02d:%02d) $hr $min $sec]
drhc67d6502014-12-31 15:14:29 +0000611 puts [string repeat * 79]
drh5bfff9d2015-01-08 01:05:42 +0000612 puts "$::NERRCASE failures out of $::NTESTCASE tests in $etime"
613 if {$::SQLITE_VERSION ne ""} {
614 puts "SQLite $::SQLITE_VERSION"
615 }
drh96110de2010-09-06 18:44:14 +0000616}
617
618main $argv