blob: 37f00eb4c005fd9460f8ff99ca8c2047fad66012 [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 --buildonly (Just build testfixture - do not run)
drheedeb922016-09-09 12:29:57 +000013 --config CONFIGNAME (Run only CONFIGNAME)
mistachkin72840562014-12-23 20:22:57 +000014 --dryrun (Print what would have happened)
drheedeb922016-09-09 12:29:57 +000015 -f|--force (Run even if uncommitted changes)
drhd477eee2014-12-23 19:40:51 +000016 --info (Show diagnostic info)
dane9e15052015-11-02 20:28:48 +000017 --jobs N (Use N processes - default 1)
dand562ec22016-09-12 09:28:21 +000018 --keep (Delete no files after each test run)
drheedeb922016-09-09 12:29:57 +000019 --msvc (Use MSVC as the compiler)
20 --platform PLATFORM (see below)
drh7f8a93d2015-11-03 15:39:29 +000021 --progress (Show progress messages)
drheedeb922016-09-09 12:29:57 +000022 --quick (Run "veryquick.test" only)
drheedeb922016-09-09 12:29:57 +000023 --veryquick (Run "make smoketest" only)
24 --with-tcl=DIR (Use TCL build at DIR)
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
drh4380ff82015-11-03 15:16:21 +000035# Return a timestamp of the form HH:MM:SS
36#
37proc now {} {
38 return [clock format [clock seconds] -format %H:%M:%S]
39}
40
drh6aed1c42015-01-10 15:21:26 +000041# Omit comments (text between # and \n) in a long multi-line string.
42#
43proc strip_comments {in} {
44 regsub -all {#[^\n]*\n} $in {} out
45 return $out
46}
47
48array set ::Configs [strip_comments {
drh96110de2010-09-06 18:44:14 +000049 "Default" {
50 -O2
drhedb31cd2015-01-08 02:15:11 +000051 --disable-amalgamation --disable-shared
drh5e18d402016-05-03 13:14:18 +000052 --enable-session
dan531230d2019-02-06 15:23:43 +000053 -DSQLITE_ENABLE_DESERIALIZE
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
drh5e18d402016-05-03 13:14:18 +000058 --enable-session
dan56089732011-04-06 12:37:09 +000059 }
drh8ef24b82016-08-01 15:00:00 +000060 "Stdcall" {
61 -DUSE_STDCALL=1
62 -O2
63 }
drh0ede9eb2015-01-10 16:49:23 +000064 "Have-Not" {
65 # The "Have-Not" configuration sets all possible -UHAVE_feature options
66 # in order to verify that the code works even on platforms that lack
67 # these support services.
68 -DHAVE_FDATASYNC=0
69 -DHAVE_GMTIME_R=0
drh8567d402015-01-10 18:22:06 +000070 -DHAVE_ISNAN=0
drh0ede9eb2015-01-10 16:49:23 +000071 -DHAVE_LOCALTIME_R=0
72 -DHAVE_LOCALTIME_S=0
73 -DHAVE_MALLOC_USABLE_SIZE=0
74 -DHAVE_STRCHRNUL=0
75 -DHAVE_USLEEP=0
76 -DHAVE_UTIME=0
drh96110de2010-09-06 18:44:14 +000077 }
78 "Unlock-Notify" {
79 -O2
80 -DSQLITE_ENABLE_UNLOCK_NOTIFY
81 -DSQLITE_THREADSAFE
drh96110de2010-09-06 18:44:14 +000082 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
dan1af016b2018-11-28 08:09:08 +000083 }
84 "User-Auth" {
85 -O2
dan67055842018-09-25 13:51:31 +000086 -DSQLITE_USER_AUTHENTICATION=1
drh96110de2010-09-06 18:44:14 +000087 }
88 "Secure-Delete" {
89 -O2
90 -DSQLITE_SECURE_DELETE=1
91 -DSQLITE_SOUNDEX=1
92 }
93 "Update-Delete-Limit" {
94 -O2
95 -DSQLITE_DEFAULT_FILE_FORMAT=4
96 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
drh1a803842015-01-09 20:00:21 +000097 -DSQLITE_ENABLE_STMT_SCANSTATUS
drh7f105792016-01-04 01:08:50 +000098 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS
99 -DSQLITE_ENABLE_CURSOR_HINTS
drhce1d9f52015-10-09 12:48:33 +0000100 --enable-json1
drh96110de2010-09-06 18:44:14 +0000101 }
danb136e902012-12-10 10:22:48 +0000102 "Check-Symbols" {
103 -DSQLITE_MEMDEBUG=1
104 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
105 -DSQLITE_ENABLE_FTS3=1
106 -DSQLITE_ENABLE_RTREE=1
107 -DSQLITE_ENABLE_MEMSYS5=1
108 -DSQLITE_ENABLE_MEMSYS3=1
109 -DSQLITE_ENABLE_COLUMN_METADATA=1
110 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
111 -DSQLITE_SECURE_DELETE=1
112 -DSQLITE_SOUNDEX=1
113 -DSQLITE_ENABLE_ATOMIC_WRITE=1
danb136e902012-12-10 10:22:48 +0000114 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
115 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
drh4081d5d2015-01-01 23:02:01 +0000116 -DSQLITE_ENABLE_STAT4
drh1a803842015-01-09 20:00:21 +0000117 -DSQLITE_ENABLE_STMT_SCANSTATUS
drh5e18d402016-05-03 13:14:18 +0000118 --enable-json1 --enable-fts5 --enable-session
danb136e902012-12-10 10:22:48 +0000119 }
drh96110de2010-09-06 18:44:14 +0000120 "Debug-One" {
drh8f455552015-01-07 14:41:18 +0000121 --disable-shared
drh2acd24d2017-09-18 00:18:31 +0000122 -O2 -funsigned-char
drh96110de2010-09-06 18:44:14 +0000123 -DSQLITE_DEBUG=1
124 -DSQLITE_MEMDEBUG=1
125 -DSQLITE_MUTEX_NOOP=1
126 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
127 -DSQLITE_ENABLE_FTS3=1
128 -DSQLITE_ENABLE_RTREE=1
129 -DSQLITE_ENABLE_MEMSYS5=1
drh96110de2010-09-06 18:44:14 +0000130 -DSQLITE_ENABLE_COLUMN_METADATA=1
drh4081d5d2015-01-01 23:02:01 +0000131 -DSQLITE_ENABLE_STAT4
drh03d69a62015-11-19 13:53:57 +0000132 -DSQLITE_ENABLE_HIDDEN_COLUMNS
drhedb31cd2015-01-08 02:15:11 +0000133 -DSQLITE_MAX_ATTACHED=125
drh2f65b2f2017-10-02 21:29:51 +0000134 -DSQLITE_MUTATION_TEST
dan466ea9b2018-06-13 11:11:13 +0000135 --enable-fts5 --enable-json1
drh96110de2010-09-06 18:44:14 +0000136 }
drhf3320712015-04-25 13:39:29 +0000137 "Fast-One" {
138 -O6
139 -DSQLITE_ENABLE_FTS4=1
140 -DSQLITE_ENABLE_RTREE=1
141 -DSQLITE_ENABLE_STAT4
drhcfb8f8d2015-07-23 20:44:49 +0000142 -DSQLITE_ENABLE_RBU
drh96110de2010-09-06 18:44:14 +0000143 -DSQLITE_MAX_ATTACHED=125
drh51675f22015-11-06 20:04:08 +0000144 -DLONGDOUBLE_TYPE=double
drh5e18d402016-05-03 13:14:18 +0000145 --enable-session
drh96110de2010-09-06 18:44:14 +0000146 }
drh96110de2010-09-06 18:44:14 +0000147 "Device-One" {
148 -O2
149 -DSQLITE_DEBUG=1
drh96110de2010-09-06 18:44:14 +0000150 -DSQLITE_DEFAULT_AUTOVACUUM=1
drh96110de2010-09-06 18:44:14 +0000151 -DSQLITE_DEFAULT_CACHE_SIZE=64
dan1c22a182010-09-13 11:29:02 +0000152 -DSQLITE_DEFAULT_PAGE_SIZE=1024
drh96110de2010-09-06 18:44:14 +0000153 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
dan1c22a182010-09-13 11:29:02 +0000154 -DSQLITE_DISABLE_LFS=1
drh96110de2010-09-06 18:44:14 +0000155 -DSQLITE_ENABLE_ATOMIC_WRITE=1
dan1c22a182010-09-13 11:29:02 +0000156 -DSQLITE_ENABLE_IOTRACE=1
157 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
158 -DSQLITE_MAX_PAGE_SIZE=4096
159 -DSQLITE_OMIT_LOAD_EXTENSION=1
160 -DSQLITE_OMIT_PROGRESS_CALLBACK=1
161 -DSQLITE_OMIT_VIRTUALTABLE=1
drh03d69a62015-11-19 13:53:57 +0000162 -DSQLITE_ENABLE_HIDDEN_COLUMNS
dan1c22a182010-09-13 11:29:02 +0000163 -DSQLITE_TEMP_STORE=3
drh64db1842015-10-09 13:29:27 +0000164 --enable-json1
dan1c22a182010-09-13 11:29:02 +0000165 }
166 "Device-Two" {
167 -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
168 -DSQLITE_DEFAULT_AUTOVACUUM=1
169 -DSQLITE_DEFAULT_CACHE_SIZE=1000
170 -DSQLITE_DEFAULT_LOCKING_MODE=0
171 -DSQLITE_DEFAULT_PAGE_SIZE=1024
172 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000
173 -DSQLITE_DISABLE_LFS=1
174 -DSQLITE_ENABLE_FTS3=1
175 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
176 -DSQLITE_ENABLE_RTREE=1
177 -DSQLITE_MAX_COMPOUND_SELECT=50
178 -DSQLITE_MAX_PAGE_SIZE=32768
dan1c22a182010-09-13 11:29:02 +0000179 -DSQLITE_OMIT_TRACE=1
180 -DSQLITE_TEMP_STORE=3
181 -DSQLITE_THREADSAFE=2
dan3a95c652018-03-28 20:29:04 +0000182 -DSQLITE_ENABLE_DESERIALIZE=1
drh5e18d402016-05-03 13:14:18 +0000183 --enable-json1 --enable-fts5 --enable-session
drh96110de2010-09-06 18:44:14 +0000184 }
185 "Locking-Style" {
186 -O2
187 -DSQLITE_ENABLE_LOCKING_STYLE=1
188 }
drh790b1512016-03-17 23:00:42 +0000189 "Apple" {
drh92b71752017-05-23 19:35:20 +0000190 -Os
drh790b1512016-03-17 23:00:42 +0000191 -DHAVE_GMTIME_R=1
192 -DHAVE_ISNAN=1
193 -DHAVE_LOCALTIME_R=1
194 -DHAVE_PREAD=1
195 -DHAVE_PWRITE=1
196 -DHAVE_USLEEP=1
197 -DHAVE_USLEEP=1
198 -DHAVE_UTIME=1
199 -DSQLITE_DEFAULT_CACHE_SIZE=1000
200 -DSQLITE_DEFAULT_CKPTFULLFSYNC=1
201 -DSQLITE_DEFAULT_MEMSTATUS=1
202 -DSQLITE_DEFAULT_PAGE_SIZE=1024
203 -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS=1
204 -DSQLITE_ENABLE_API_ARMOR=1
205 -DSQLITE_ENABLE_AUTO_PROFILE=1
206 -DSQLITE_ENABLE_FLOCKTIMEOUT=1
dan1c22a182010-09-13 11:29:02 +0000207 -DSQLITE_ENABLE_FTS3=1
208 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
drh790b1512016-03-17 23:00:42 +0000209 -DSQLITE_ENABLE_FTS3_TOKENIZER=1
210 if:os=="Darwin" -DSQLITE_ENABLE_LOCKING_STYLE=1
211 -DSQLITE_ENABLE_PERSIST_WAL=1
212 -DSQLITE_ENABLE_PURGEABLE_PCACHE=1
213 -DSQLITE_ENABLE_RTREE=1
214 -DSQLITE_ENABLE_SNAPSHOT=1
215 # -DSQLITE_ENABLE_SQLLOG=1
216 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
dan1c22a182010-09-13 11:29:02 +0000217 -DSQLITE_MAX_LENGTH=2147483645
218 -DSQLITE_MAX_VARIABLE_NUMBER=500000
drh9493caf2016-03-17 23:16:37 +0000219 # -DSQLITE_MEMDEBUG=1
drh790b1512016-03-17 23:00:42 +0000220 -DSQLITE_NO_SYNC=1
221 -DSQLITE_OMIT_AUTORESET=1
222 -DSQLITE_OMIT_LOAD_EXTENSION=1
dan1c22a182010-09-13 11:29:02 +0000223 -DSQLITE_PREFER_PROXY_LOCKING=1
drh790b1512016-03-17 23:00:42 +0000224 -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
225 -DSQLITE_THREADSAFE=2
226 -DSQLITE_USE_URI=1
227 -DSQLITE_WRITE_WALFRAME_PREBUFFERED=1
228 -DUSE_GUARDED_FD=1
229 -DUSE_PREAD=1
drhce1d9f52015-10-09 12:48:33 +0000230 --enable-json1 --enable-fts5
drh96110de2010-09-06 18:44:14 +0000231 }
232 "Extra-Robustness" {
233 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
dan56089732011-04-06 12:37:09 +0000234 -DSQLITE_MAX_ATTACHED=62
drh96110de2010-09-06 18:44:14 +0000235 }
dan4dc3d732012-08-20 17:24:48 +0000236 "Devkit" {
237 -DSQLITE_DEFAULT_FILE_FORMAT=4
238 -DSQLITE_MAX_ATTACHED=30
239 -DSQLITE_ENABLE_COLUMN_METADATA
240 -DSQLITE_ENABLE_FTS4
dane82126c2016-03-01 16:02:57 +0000241 -DSQLITE_ENABLE_FTS5
dan4dc3d732012-08-20 17:24:48 +0000242 -DSQLITE_ENABLE_FTS4_PARENTHESIS
243 -DSQLITE_DISABLE_FTS4_DEFERRED
244 -DSQLITE_ENABLE_RTREE
drhce1d9f52015-10-09 12:48:33 +0000245 --enable-json1 --enable-fts5
dan4dc3d732012-08-20 17:24:48 +0000246 }
dand79d27a2014-08-12 14:06:13 +0000247 "No-lookaside" {
248 -DSQLITE_TEST_REALLOC_STRESS=1
249 -DSQLITE_OMIT_LOOKASIDE=1
250 -DHAVE_USLEEP=1
251 }
drh8a2a0f52015-01-07 14:09:41 +0000252 "Valgrind" {
253 -DSQLITE_ENABLE_STAT4
254 -DSQLITE_ENABLE_FTS4
255 -DSQLITE_ENABLE_RTREE
drh03d69a62015-11-19 13:53:57 +0000256 -DSQLITE_ENABLE_HIDDEN_COLUMNS
drhce1d9f52015-10-09 12:48:33 +0000257 --enable-json1
drh8a2a0f52015-01-07 14:09:41 +0000258 }
drh96110de2010-09-06 18:44:14 +0000259
drh6aed1c42015-01-10 15:21:26 +0000260 # The next group of configurations are used only by the
261 # Failure-Detection platform. They are all the same, but we need
262 # different names for them all so that they results appear in separate
263 # subdirectories.
264 #
drhedb31cd2015-01-08 02:15:11 +0000265 Fail0 {-O0}
266 Fail2 {-O0}
267 Fail3 {-O0}
drhdb6bafa2015-01-09 21:54:58 +0000268 Fail4 {-O0}
drh8ea5eca2015-04-24 16:53:03 +0000269 FuzzFail1 {-O0}
270 FuzzFail2 {-O0}
drh6aed1c42015-01-10 15:21:26 +0000271}]
drh96110de2010-09-06 18:44:14 +0000272
drh6aed1c42015-01-10 15:21:26 +0000273array set ::Platforms [strip_comments {
drh96110de2010-09-06 18:44:14 +0000274 Linux-x86_64 {
danb136e902012-12-10 10:22:48 +0000275 "Check-Symbols" checksymbols
danf86ff132018-09-13 17:11:51 +0000276 "Fast-One" "fuzztest test"
drhbd41d562014-12-30 20:40:32 +0000277 "Debug-One" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000278 "Have-Not" test
drh96110de2010-09-06 18:44:14 +0000279 "Secure-Delete" test
280 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
dan1af016b2018-11-28 08:09:08 +0000281 "User-Auth" tcltest
drh96110de2010-09-06 18:44:14 +0000282 "Update-Delete-Limit" test
drh96110de2010-09-06 18:44:14 +0000283 "Extra-Robustness" test
dana082cd72019-07-04 16:05:26 +0000284 "Device-Two" "threadtest test"
dand79d27a2014-08-12 14:06:13 +0000285 "No-lookaside" test
dan5d510d42014-10-15 15:28:27 +0000286 "Devkit" test
drh790b1512016-03-17 23:00:42 +0000287 "Apple" test
drh8a2a0f52015-01-07 14:09:41 +0000288 "Sanitize" {QUICKTEST_OMIT=func4.test,nan.test test}
drh96110de2010-09-06 18:44:14 +0000289 "Device-One" fulltest
drh71258ab2015-11-04 16:34:58 +0000290 "Default" "threadtest fulltest"
291 "Valgrind" valgrindtest
drh96110de2010-09-06 18:44:14 +0000292 }
dan1c22a182010-09-13 11:29:02 +0000293 Linux-i686 {
dan4dc3d732012-08-20 17:24:48 +0000294 "Devkit" test
drh0ede9eb2015-01-10 16:49:23 +0000295 "Have-Not" test
dan1c22a182010-09-13 11:29:02 +0000296 "Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
dan1c22a182010-09-13 11:29:02 +0000297 "Device-One" test
dand38bc1b2010-09-13 12:15:36 +0000298 "Device-Two" test
299 "Default" "threadtest fulltest"
dan1c22a182010-09-13 11:29:02 +0000300 }
drh96110de2010-09-06 18:44:14 +0000301 Darwin-i386 {
drhbd41d562014-12-30 20:40:32 +0000302 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000303 "Have-Not" test
drh790b1512016-03-17 23:00:42 +0000304 "Apple" "threadtest fulltest"
drh96110de2010-09-06 18:44:14 +0000305 }
drhbcbac682014-12-31 18:55:09 +0000306 Darwin-x86_64 {
307 "Locking-Style" "mptest test"
drh0ede9eb2015-01-10 16:49:23 +0000308 "Have-Not" test
drh790b1512016-03-17 23:00:42 +0000309 "Apple" "threadtest fulltest"
drhbcbac682014-12-31 18:55:09 +0000310 }
mistachkin72840562014-12-23 20:22:57 +0000311 "Windows NT-intel" {
drh8ef24b82016-08-01 15:00:00 +0000312 "Stdcall" test
drh0ede9eb2015-01-10 16:49:23 +0000313 "Have-Not" test
drh71258ab2015-11-04 16:34:58 +0000314 "Default" "mptest fulltestonly"
mistachkin72840562014-12-23 20:22:57 +0000315 }
mistachkin00eb70d2015-04-04 00:02:07 +0000316 "Windows NT-amd64" {
drh8ef24b82016-08-01 15:00:00 +0000317 "Stdcall" test
mistachkin00eb70d2015-04-04 00:02:07 +0000318 "Have-Not" test
drh71258ab2015-11-04 16:34:58 +0000319 "Default" "mptest fulltestonly"
mistachkin00eb70d2015-04-04 00:02:07 +0000320 }
drh6aed1c42015-01-10 15:21:26 +0000321
322 # The Failure-Detection platform runs various tests that deliberately
323 # fail. This is used as a test of this script to verify that this script
324 # correctly identifies failures.
325 #
drhedb31cd2015-01-08 02:15:11 +0000326 Failure-Detection {
327 Fail0 "TEST_FAILURE=0 test"
328 Sanitize "TEST_FAILURE=1 test"
329 Fail2 "TEST_FAILURE=2 valgrindtest"
330 Fail3 "TEST_FAILURE=3 valgrindtest"
drhdb6bafa2015-01-09 21:54:58 +0000331 Fail4 "TEST_FAILURE=4 test"
drh8ea5eca2015-04-24 16:53:03 +0000332 FuzzFail1 "TEST_FAILURE=5 test"
333 FuzzFail2 "TEST_FAILURE=5 valgrindtest"
drhedb31cd2015-01-08 02:15:11 +0000334 }
drh6aed1c42015-01-10 15:21:26 +0000335}]
drh96110de2010-09-06 18:44:14 +0000336
dane7152dc2011-07-07 08:19:16 +0000337
drh96110de2010-09-06 18:44:14 +0000338# End of configuration section.
339#########################################################################
340#########################################################################
341
mistachkinda9da562015-11-02 23:29:58 +0000342# Configuration verification: Check that each entry in the list of configs
dana7f65972015-11-02 18:32:00 +0000343# specified for each platforms exists.
344#
drh96110de2010-09-06 18:44:14 +0000345foreach {key value} [array get ::Platforms] {
346 foreach {v t} $value {
347 if {0==[info exists ::Configs($v)]} {
348 puts stderr "No such configuration: \"$v\""
349 exit -1
350 }
351 }
352}
353
drhd63fbb72015-11-13 12:52:34 +0000354# Output log. Disabled for slave interpreters.
drhe31dc592015-08-14 12:53:37 +0000355#
drhd63fbb72015-11-13 12:52:34 +0000356if {[lindex $argv end]!="--slave"} {
357 set LOG [open releasetest-out.txt w]
358 proc PUTS {txt} {
359 puts $txt
360 puts $::LOG $txt
361 flush $::LOG
drhe31dc592015-08-14 12:53:37 +0000362 }
drhd63fbb72015-11-13 12:52:34 +0000363 proc PUTSNNL {txt} {
364 puts -nonewline $txt
365 puts -nonewline $::LOG $txt
366 flush $::LOG
367 }
368 proc PUTSERR {txt} {
369 puts stderr $txt
370 puts $::LOG $txt
371 flush $::LOG
372 }
373 puts $LOG "$argv0 $argv"
374 set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]
375 puts $LOG "start-time: $tm0 UTC"
376} else {
377 proc PUTS {txt} {
378 puts $txt
379 }
380 proc PUTSNNL {txt} {
381 puts -nonewline $txt
382 }
383 proc PUTSERR {txt} {
384 puts stderr $txt
385 }
drhe31dc592015-08-14 12:53:37 +0000386}
drhe31dc592015-08-14 12:53:37 +0000387
drh277b4e42014-12-29 02:55:58 +0000388# Open the file $logfile and look for a report on the number of errors
389# and the number of test cases run. Add these values to the global
390# $::NERRCASE and $::NTESTCASE variables.
391#
392# If any errors occur, then write into $errmsgVar the text of an appropriate
393# one-line error message to show on the output.
394#
395proc count_tests_and_errors {logfile rcVar errmsgVar} {
drhcb281a92014-12-29 19:54:10 +0000396 if {$::DRYRUN} return
drh277b4e42014-12-29 02:55:58 +0000397 upvar 1 $rcVar rc $errmsgVar errmsg
398 set fd [open $logfile rb]
399 set seen 0
400 while {![eof $fd]} {
401 set line [gets $fd]
drhbd41d562014-12-30 20:40:32 +0000402 if {[regexp {(\d+) errors out of (\d+) tests} $line all nerr ntest]} {
drh277b4e42014-12-29 02:55:58 +0000403 incr ::NERRCASE $nerr
404 incr ::NTESTCASE $ntest
405 set seen 1
406 if {$nerr>0} {
407 set rc 1
408 set errmsg $line
409 }
drh277b4e42014-12-29 02:55:58 +0000410 }
drh4081d5d2015-01-01 23:02:01 +0000411 if {[regexp {runtime error: +(.*)} $line all msg]} {
drh36c25f72015-07-29 20:24:39 +0000412 # skip over "value is outside range" errors
413 if {[regexp {value .* is outside the range of representable} $line]} {
414 # noop
drh9a50f4c2019-10-02 19:44:42 +0000415 } elseif {[regexp {overflow: .* cannot be represented} $line]} {
416 # noop
drh36c25f72015-07-29 20:24:39 +0000417 } else {
418 incr ::NERRCASE
419 if {$rc==0} {
420 set rc 1
421 set errmsg $msg
422 }
drh4081d5d2015-01-01 23:02:01 +0000423 }
424 }
mistachkin00eb70d2015-04-04 00:02:07 +0000425 if {[regexp {fatal error +(.*)} $line all msg]} {
426 incr ::NERRCASE
427 if {$rc==0} {
428 set rc 1
429 set errmsg $msg
430 }
431 }
drh8a2a0f52015-01-07 14:09:41 +0000432 if {[regexp {ERROR SUMMARY: (\d+) errors.*} $line all cnt] && $cnt>0} {
433 incr ::NERRCASE
434 if {$rc==0} {
435 set rc 1
436 set errmsg $all
437 }
438 }
drh5bfff9d2015-01-08 01:05:42 +0000439 if {[regexp {^VERSION: 3\.\d+.\d+} $line]} {
440 set v [string range $line 9 end]
441 if {$::SQLITE_VERSION eq ""} {
442 set ::SQLITE_VERSION $v
443 } elseif {$::SQLITE_VERSION ne $v} {
444 set rc 1
445 set errmsg "version conflict: {$::SQLITE_VERSION} vs. {$v}"
446 }
447 }
drh277b4e42014-12-29 02:55:58 +0000448 }
449 close $fd
mistachkin00eb70d2015-04-04 00:02:07 +0000450 if {$::BUILDONLY} {
drh7f8a93d2015-11-03 15:39:29 +0000451 incr ::NTESTCASE
452 if {$rc!=0} {
mistachkin00eb70d2015-04-04 00:02:07 +0000453 set errmsg "Build failed"
454 }
455 } elseif {!$seen} {
drh277b4e42014-12-29 02:55:58 +0000456 set rc 1
457 set errmsg "Test did not complete"
drhdb6bafa2015-01-09 21:54:58 +0000458 if {[file readable core]} {
459 append errmsg " - core file exists"
460 }
drh277b4e42014-12-29 02:55:58 +0000461 }
462}
463
dana7f65972015-11-02 18:32:00 +0000464#--------------------------------------------------------------------------
465# This command is invoked as the [main] routine for scripts run with the
mistachkinda9da562015-11-02 23:29:58 +0000466# "--slave" option.
dana7f65972015-11-02 18:32:00 +0000467#
468# For each test (i.e. "configure && make test" execution), the master
469# process spawns a process with the --slave option. It writes two lines
mistachkinda9da562015-11-02 23:29:58 +0000470# to the slaves stdin. The first contains a single boolean value - the
471# value of ::TRACE to use in the slave script. The second line contains a
dana7f65972015-11-02 18:32:00 +0000472# list in the same format as each element of the list passed to the
473# [run_all_test_suites] command in the master process.
474#
475# The slave then runs the "configure && make test" commands specified. It
476# exits successfully if the tests passes, or with a non-zero error code
477# otherwise.
478#
479proc run_slave_test {} {
480 # Read global vars configuration from stdin.
481 set V [gets stdin]
dand562ec22016-09-12 09:28:21 +0000482 foreach {::TRACE ::MSVC ::DRYRUN ::KEEPFILES} $V {}
dana7f65972015-11-02 18:32:00 +0000483
484 # Read the test-suite configuration from stdin.
485 set T [gets stdin]
mistachkinda9da562015-11-02 23:29:58 +0000486 foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
dana7f65972015-11-02 18:32:00 +0000487
488 # Create and switch to the test directory.
dand562ec22016-09-12 09:28:21 +0000489 set normaldir [file normalize $dir]
490 set ::env(SQLITE_TMPDIR) $normaldir
dana7f65972015-11-02 18:32:00 +0000491 trace_cmd file mkdir $dir
492 trace_cmd cd $dir
493 catch {file delete core}
494 catch {file delete test.log}
495
496 # Run the "./configure && make" commands.
497 set rc 0
498 set rc [catch [configureCommand $configOpts]]
499 if {!$rc} {
mistachkin59189432015-11-02 21:05:56 +0000500 if {[info exists ::env(TCLSH_CMD)]} {
501 set savedEnv(TCLSH_CMD) $::env(TCLSH_CMD)
502 } else {
503 unset -nocomplain savedEnv(TCLSH_CMD)
504 }
505 set ::env(TCLSH_CMD) [file nativename [info nameofexecutable]]
dan112e1742019-04-16 10:51:29 +0000506
507 # Create a file called "makecommand.sh" containing the text of
508 # the make command line.
509 catch {
510 set cmd [makeCommand $testtarget $makeOpts $cflags $opts]
511 set fd [open makecommand.sh w]
512 foreach e $cmd {
513 if {[string first " " $e]>=0} {
514 puts -nonewline $fd "\"$e\""
515 } else {
516 puts -nonewline $fd $e
517 }
518 puts -nonewline $fd " "
519 }
520 puts $fd ""
521 close $fd
522 } msg
523
524 # Run the make command.
525 set rc [catch {trace_cmd exec {*}$cmd >>& test.log} msg]
mistachkin59189432015-11-02 21:05:56 +0000526 if {[info exists savedEnv(TCLSH_CMD)]} {
527 set ::env(TCLSH_CMD) $savedEnv(TCLSH_CMD)
528 } else {
529 unset -nocomplain ::env(TCLSH_CMD)
530 }
dana7f65972015-11-02 18:32:00 +0000531 }
532
dand562ec22016-09-12 09:28:21 +0000533 # Clean up lots of extra files if --keep was not specified.
534 if {$::KEEPFILES==0} { cleanup $normaldir }
535
dana7f65972015-11-02 18:32:00 +0000536 # Exis successfully if the test passed, or with a non-zero error code
537 # otherwise.
538 exit $rc
539}
540
mistachkinda9da562015-11-02 23:29:58 +0000541# This command is invoked in the master process each time a slave
dana7f65972015-11-02 18:32:00 +0000542# file-descriptor is readable.
543#
544proc slave_fileevent {fd T tm1} {
545 global G
mistachkinda9da562015-11-02 23:29:58 +0000546 foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
dana7f65972015-11-02 18:32:00 +0000547
548 if {[eof $fd]} {
549 fconfigure $fd -blocking 1
550 set rc [catch { close $fd }]
551
552 set errmsg {}
dane9e15052015-11-02 20:28:48 +0000553 set logfile [file join $dir test.log]
554 if {[file exists $logfile]} {
555 count_tests_and_errors [file join $dir test.log] rc errmsg
drh4380ff82015-11-03 15:16:21 +0000556 } elseif {$rc==0 && !$::DRYRUN} {
dane9e15052015-11-02 20:28:48 +0000557 set rc 1
558 set errmsg "no test.log file..."
559 }
dana7f65972015-11-02 18:32:00 +0000560
561 if {!$::TRACE} {
562 set tm2 [clock seconds]
563 set hours [expr {($tm2-$tm1)/3600}]
564 set minutes [expr {(($tm2-$tm1)/60)%60}]
565 set seconds [expr {($tm2-$tm1)%60}]
566 set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]
567
568 if {$rc} {
569 set status FAIL
570 incr ::NERR
571 } else {
572 set status Ok
573 }
574
575 set n [string length $title]
drh7f8a93d2015-11-03 15:39:29 +0000576 if {$::PROGRESS_MSGS} {
577 PUTS "finished: ${title}[string repeat . [expr {53-$n}]] $status $tm"
578 } else {
579 PUTS "${title}[string repeat . [expr {63-$n}]] $status $tm"
580 }
dana7f65972015-11-02 18:32:00 +0000581 if {$errmsg!=""} {PUTS " $errmsg"}
582 flush stdout
583 }
584
585 incr G(nJob) -1
586 } else {
587 set line [gets $fd]
588 if {[string trim $line] != ""} {
589 puts "Trace : $title - \"$line\""
590 }
591 }
592}
593
594#--------------------------------------------------------------------------
595# The only argument passed to this function is a list of test-suites to
596# run. Each "test-suite" is itself a list consisting of the following
597# elements:
598#
599# * Test title (for display).
600# * The name of the directory to run the test in.
601# * The argument for [configureCommand]
602# * The first argument for [makeCommand]
603# * The second argument for [makeCommand]
604# * The third argument for [makeCommand]
mistachkinda9da562015-11-02 23:29:58 +0000605#
dana7f65972015-11-02 18:32:00 +0000606proc run_all_test_suites {alltests} {
607 global G
608 set tests $alltests
609
610 set G(nJob) 0
611
612 while {[llength $tests]>0 || $G(nJob)>0} {
613 if {$G(nJob)>=$::JOBS || [llength $tests]==0} {
614 vwait G(nJob)
615 }
616
617 if {[llength $tests]>0} {
618 set T [lindex $tests 0]
619 set tests [lrange $tests 1 end]
mistachkinda9da562015-11-02 23:29:58 +0000620 foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}
drh7f8a93d2015-11-03 15:39:29 +0000621 if {$::PROGRESS_MSGS && !$::TRACE} {
dana7f65972015-11-02 18:32:00 +0000622 set n [string length $title]
drh4380ff82015-11-03 15:16:21 +0000623 PUTS "starting: ${title} at [now]"
dana7f65972015-11-02 18:32:00 +0000624 flush stdout
625 }
626
627 # Run the job.
628 #
629 set tm1 [clock seconds]
630 incr G(nJob)
mistachkin59189432015-11-02 21:05:56 +0000631 set script [file normalize [info script]]
632 set fd [open "|[info nameofexecutable] $script --slave" r+]
dana7f65972015-11-02 18:32:00 +0000633 fconfigure $fd -blocking 0
634 fileevent $fd readable [list slave_fileevent $fd $T $tm1]
dand562ec22016-09-12 09:28:21 +0000635 puts $fd [list $::TRACE $::MSVC $::DRYRUN $::KEEPFILES]
dana7f65972015-11-02 18:32:00 +0000636 puts $fd [list {*}$T]
637 flush $fd
638 }
639 }
640}
641
642proc add_test_suite {listvar name testtarget config} {
643 upvar $listvar alltests
644
mistachkin72840562014-12-23 20:22:57 +0000645 # Tcl variable $opts is used to build up the value used to set the
drh96110de2010-09-06 18:44:14 +0000646 # OPTS Makefile variable. Variable $cflags holds the value for
647 # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but
648 # CFLAGS is only passed to gcc.
649 #
mistachkinda9da562015-11-02 23:29:58 +0000650 set makeOpts ""
mistachkin00eb70d2015-04-04 00:02:07 +0000651 set cflags [expr {$::MSVC ? "-Zi" : "-g"}]
drh96110de2010-09-06 18:44:14 +0000652 set opts ""
drha780d8d2015-01-03 18:59:17 +0000653 set title ${name}($testtarget)
drh0ef84d02015-04-24 17:50:37 +0000654 set configOpts $::WITHTCL
drh790b1512016-03-17 23:00:42 +0000655 set skip 0
drha780d8d2015-01-03 18:59:17 +0000656
drh149735d2015-01-01 19:53:10 +0000657 regsub -all {#[^\n]*\n} $config \n config
drh96110de2010-09-06 18:44:14 +0000658 foreach arg $config {
drh790b1512016-03-17 23:00:42 +0000659 if {$skip} {
660 set skip 0
661 continue
662 }
drh0ede9eb2015-01-10 16:49:23 +0000663 if {[regexp {^-[UD]} $arg]} {
drh96110de2010-09-06 18:44:14 +0000664 lappend opts $arg
drh0ede9eb2015-01-10 16:49:23 +0000665 } elseif {[regexp {^[A-Z]+=} $arg]} {
drh149735d2015-01-01 19:53:10 +0000666 lappend testtarget $arg
drh790b1512016-03-17 23:00:42 +0000667 } elseif {[regexp {^if:([a-z]+)(.*)} $arg all key tail]} {
668 # Arguments of the form 'if:os=="Linux"' will cause the subsequent
669 # argument to be skipped if the $tcl_platform(os) is not "Linux", for
670 # example...
671 set skip [expr !(\$::tcl_platform($key)$tail)]
drh8f455552015-01-07 14:41:18 +0000672 } elseif {[regexp {^--(enable|disable)-} $arg]} {
mistachkinda9da562015-11-02 23:29:58 +0000673 if {$::MSVC} {
674 if {$arg eq "--disable-amalgamation"} {
675 lappend makeOpts USE_AMALGAMATION=0
676 continue
677 }
678 if {$arg eq "--disable-shared"} {
679 lappend makeOpts USE_CRT_DLL=0 DYNAMIC_SHELL=0
680 continue
681 }
682 if {$arg eq "--enable-fts5"} {
683 lappend opts -DSQLITE_ENABLE_FTS5
684 continue
685 }
686 if {$arg eq "--enable-json1"} {
687 lappend opts -DSQLITE_ENABLE_JSON1
688 continue
689 }
mistachkin7d3bfa22015-11-03 06:23:33 +0000690 if {$arg eq "--enable-shared"} {
691 lappend makeOpts USE_CRT_DLL=1 DYNAMIC_SHELL=1
692 continue
693 }
mistachkinda9da562015-11-02 23:29:58 +0000694 }
drh8f455552015-01-07 14:41:18 +0000695 lappend configOpts $arg
drh96110de2010-09-06 18:44:14 +0000696 } else {
mistachkinda9da562015-11-02 23:29:58 +0000697 if {$::MSVC} {
698 if {$arg eq "-g"} {
699 lappend cflags -Zi
700 continue
701 }
702 if {[regexp -- {^-O(\d+)$} $arg all level]} then {
703 lappend makeOpts OPTIMIZATIONS=$level
704 continue
705 }
706 }
drh96110de2010-09-06 18:44:14 +0000707 lappend cflags $arg
708 }
709 }
710
mistachkinda9da562015-11-02 23:29:58 +0000711 # Disable sync to make testing faster.
712 #
713 lappend opts -DSQLITE_NO_SYNC=1
mistachkin00eb70d2015-04-04 00:02:07 +0000714
715 # Some configurations already set HAVE_USLEEP; in that case, skip it.
716 #
mistachkinda9da562015-11-02 23:29:58 +0000717 if {[lsearch -regexp $opts {^-DHAVE_USLEEP(?:=|$)}]==-1} {
718 lappend opts -DHAVE_USLEEP=1
719 }
720
721 # Add the define for this platform.
722 #
723 if {$::tcl_platform(platform)=="windows"} {
724 lappend opts -DSQLITE_OS_WIN=1
725 } else {
726 lappend opts -DSQLITE_OS_UNIX=1
mistachkin00eb70d2015-04-04 00:02:07 +0000727 }
drh96110de2010-09-06 18:44:14 +0000728
729 # Set the sub-directory to use.
730 #
731 set dir [string tolower [string map {- _ " " _} $name]]
732
mistachkinda9da562015-11-02 23:29:58 +0000733 # Join option lists into strings, using space as delimiter.
734 #
735 set makeOpts [join $makeOpts " "]
736 set cflags [join $cflags " "]
737 set opts [join $opts " "]
drh96110de2010-09-06 18:44:14 +0000738
mistachkinda9da562015-11-02 23:29:58 +0000739 lappend alltests [list \
740 $title $dir $configOpts $testtarget $makeOpts $cflags $opts]
drhd477eee2014-12-23 19:40:51 +0000741}
742
mistachkin72840562014-12-23 20:22:57 +0000743# The following procedure returns the "configure" command to be exectued for
744# the current platform, which may be Windows (via MinGW, etc).
745#
drh8f455552015-01-07 14:41:18 +0000746proc configureCommand {opts} {
mistachkin00eb70d2015-04-04 00:02:07 +0000747 if {$::MSVC} return [list]; # This is not needed for MSVC.
drh8f455552015-01-07 14:41:18 +0000748 set result [list trace_cmd exec]
mistachkin72840562014-12-23 20:22:57 +0000749 if {$::tcl_platform(platform)=="windows"} {
750 lappend result sh
751 }
drh8f455552015-01-07 14:41:18 +0000752 lappend result $::SRCDIR/configure --enable-load-extension
753 foreach x $opts {lappend result $x}
754 lappend result >& test.log
mistachkin72840562014-12-23 20:22:57 +0000755}
756
757# The following procedure returns the "make" command to be executed for the
758# specified targets, compiler flags, and options.
759#
mistachkinda9da562015-11-02 23:29:58 +0000760proc makeCommand { targets makeOpts cflags opts } {
dan112e1742019-04-16 10:51:29 +0000761 set result [list]
mistachkin00eb70d2015-04-04 00:02:07 +0000762 if {$::MSVC} {
763 set nmakeDir [file nativename $::SRCDIR]
mistachkin98fea322015-11-03 02:47:11 +0000764 set nmakeFile [file nativename [file join $nmakeDir Makefile.msc]]
mistachkinda9da562015-11-02 23:29:58 +0000765 lappend result nmake /f $nmakeFile TOP=$nmakeDir
mistachkin992fdfc2018-01-05 19:27:19 +0000766 set tclDir [file nativename [file normalize \
767 [file dirname [file dirname [info nameofexecutable]]]]]
768 lappend result "TCLDIR=$tclDir"
drh8ef24b82016-08-01 15:00:00 +0000769 if {[regexp {USE_STDCALL=1} $cflags]} {
770 lappend result USE_STDCALL=1
771 }
mistachkin00eb70d2015-04-04 00:02:07 +0000772 } else {
mistachkinda9da562015-11-02 23:29:58 +0000773 lappend result make
mistachkin00eb70d2015-04-04 00:02:07 +0000774 }
mistachkinda9da562015-11-02 23:29:58 +0000775 foreach makeOpt $makeOpts {
776 lappend result $makeOpt
777 }
778 lappend result clean
mistachkin72840562014-12-23 20:22:57 +0000779 foreach target $targets {
780 lappend result $target
781 }
dan112e1742019-04-16 10:51:29 +0000782 lappend result CFLAGS=$cflags OPTS=$opts
mistachkin72840562014-12-23 20:22:57 +0000783}
784
drh8f455552015-01-07 14:41:18 +0000785# The following procedure prints its arguments if ::TRACE is true.
786# And it executes the command of its arguments in the calling context
787# if ::DRYRUN is false.
drhd477eee2014-12-23 19:40:51 +0000788#
drh8f455552015-01-07 14:41:18 +0000789proc trace_cmd {args} {
790 if {$::TRACE} {
drhe31dc592015-08-14 12:53:37 +0000791 PUTS $args
drh8f455552015-01-07 14:41:18 +0000792 }
dana7f65972015-11-02 18:32:00 +0000793 set res ""
drh8f455552015-01-07 14:41:18 +0000794 if {!$::DRYRUN} {
dana7f65972015-11-02 18:32:00 +0000795 set res [uplevel 1 $args]
drh96110de2010-09-06 18:44:14 +0000796 }
dana7f65972015-11-02 18:32:00 +0000797 return $res
drh96110de2010-09-06 18:44:14 +0000798}
799
800
801# This proc processes the command line options passed to this script.
802# Currently the only option supported is "-makefile", default
803# "releasetest.mk". Set the ::MAKEFILE variable to the value of this
804# option.
805#
806proc process_options {argv} {
drhd477eee2014-12-23 19:40:51 +0000807 set ::SRCDIR [file normalize [file dirname [file dirname $::argv0]]]
drh7f8a93d2015-11-03 15:39:29 +0000808 set ::QUICK 0
809 set ::MSVC 0
810 set ::BUILDONLY 0
811 set ::DRYRUN 0
812 set ::TRACE 0
813 set ::JOBS 1
814 set ::PROGRESS_MSGS 0
815 set ::WITHTCL {}
drheedeb922016-09-09 12:29:57 +0000816 set ::FORCE 0
dand562ec22016-09-12 09:28:21 +0000817 set ::KEEPFILES 0 ;# Keep extra files after test run
drh2eeb7ae2014-10-10 17:44:03 +0000818 set config {}
drh96110de2010-09-06 18:44:14 +0000819 set platform $::tcl_platform(os)-$::tcl_platform(machine)
820
821 for {set i 0} {$i < [llength $argv]} {incr i} {
drhd477eee2014-12-23 19:40:51 +0000822 set x [lindex $argv $i]
823 if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}
drhf167a402015-01-07 18:44:59 +0000824 switch -glob -- $x {
dana7f65972015-11-02 18:32:00 +0000825 -slave {
826 run_slave_test
827 exit
828 }
829
drhfe376582016-09-09 13:23:36 +0000830 # Undocumented legacy option: --srcdir DIRECTORY
831 #
832 # DIRECTORY is the root of the SQLite checkout. This sets the
833 # SRCDIR global variable. But that variable is already set
834 # automatically so there really is no reason to have this option.
835 #
drhd477eee2014-12-23 19:40:51 +0000836 -srcdir {
drh96110de2010-09-06 18:44:14 +0000837 incr i
drhd477eee2014-12-23 19:40:51 +0000838 set ::SRCDIR [file normalize [lindex $argv $i]]
drh96110de2010-09-06 18:44:14 +0000839 }
840
841 -platform {
842 incr i
843 set platform [lindex $argv $i]
844 }
845
dana7f65972015-11-02 18:32:00 +0000846 -jobs {
847 incr i
848 set ::JOBS [lindex $argv $i]
849 }
850
drh7f8a93d2015-11-03 15:39:29 +0000851 -progress {
852 set ::PROGRESS_MSGS 1
853 }
854
drh96110de2010-09-06 18:44:14 +0000855 -quick {
drhd477eee2014-12-23 19:40:51 +0000856 set ::QUICK 1
drh96110de2010-09-06 18:44:14 +0000857 }
drh5bfff9d2015-01-08 01:05:42 +0000858 -veryquick {
859 set ::QUICK 2
drh96110de2010-09-06 18:44:14 +0000860 }
drh2eeb7ae2014-10-10 17:44:03 +0000861
862 -config {
863 incr i
864 set config [lindex $argv $i]
865 }
drhd477eee2014-12-23 19:40:51 +0000866
mistachkin00eb70d2015-04-04 00:02:07 +0000867 -msvc {
868 set ::MSVC 1
869 }
870
drhd477eee2014-12-23 19:40:51 +0000871 -buildonly {
872 set ::BUILDONLY 1
873 }
874
875 -dryrun {
876 set ::DRYRUN 1
877 }
878
drheedeb922016-09-09 12:29:57 +0000879 -force -
880 -f {
881 set ::FORCE 1
882 }
883
drh8f455552015-01-07 14:41:18 +0000884 -trace {
885 set ::TRACE 1
886 }
887
drhd477eee2014-12-23 19:40:51 +0000888 -info {
drhe31dc592015-08-14 12:53:37 +0000889 PUTS "Command-line Options:"
890 PUTS " --srcdir $::SRCDIR"
891 PUTS " --platform [list $platform]"
892 PUTS " --config [list $config]"
drh905da632015-06-10 18:53:09 +0000893 if {$::QUICK} {
drhe31dc592015-08-14 12:53:37 +0000894 if {$::QUICK==1} {PUTS " --quick"}
895 if {$::QUICK==2} {PUTS " --veryquick"}
drh905da632015-06-10 18:53:09 +0000896 }
drhe31dc592015-08-14 12:53:37 +0000897 if {$::MSVC} {PUTS " --msvc"}
898 if {$::BUILDONLY} {PUTS " --buildonly"}
899 if {$::DRYRUN} {PUTS " --dryrun"}
900 if {$::TRACE} {PUTS " --trace"}
901 PUTS "\nAvailable --platform options:"
drhd477eee2014-12-23 19:40:51 +0000902 foreach y [lsort [array names ::Platforms]] {
drhe31dc592015-08-14 12:53:37 +0000903 PUTS " [list $y]"
drhd477eee2014-12-23 19:40:51 +0000904 }
drhe31dc592015-08-14 12:53:37 +0000905 PUTS "\nAvailable --config options:"
drhd477eee2014-12-23 19:40:51 +0000906 foreach y [lsort [array names ::Configs]] {
drhe31dc592015-08-14 12:53:37 +0000907 PUTS " [list $y]"
drhd477eee2014-12-23 19:40:51 +0000908 }
909 exit
910 }
mistachkin00eb70d2015-04-04 00:02:07 +0000911
912 -g {
mistachkinda9da562015-11-02 23:29:58 +0000913 lappend ::EXTRACONFIG [lindex $argv $i]
mistachkin00eb70d2015-04-04 00:02:07 +0000914 }
915
dand562ec22016-09-12 09:28:21 +0000916 -keep {
917 set ::KEEPFILES 1
918 }
919
drh0ef84d02015-04-24 17:50:37 +0000920 -with-tcl=* {
921 set ::WITHTCL -$x
922 }
923
drhf167a402015-01-07 18:44:59 +0000924 -D* -
drh5bfff9d2015-01-08 01:05:42 +0000925 -O* -
drhf167a402015-01-07 18:44:59 +0000926 -enable-* -
927 -disable-* -
928 *=* {
929 lappend ::EXTRACONFIG [lindex $argv $i]
930 }
mistachkin72840562014-12-23 20:22:57 +0000931
drh96110de2010-09-06 18:44:14 +0000932 default {
drh573d88e2016-01-03 11:17:04 +0000933 PUTSERR ""
934 PUTSERR [string trim $::USAGE_MESSAGE]
drh96110de2010-09-06 18:44:14 +0000935 exit -1
936 }
937 }
938 }
939
drh96110de2010-09-06 18:44:14 +0000940 if {0==[info exists ::Platforms($platform)]} {
drhe31dc592015-08-14 12:53:37 +0000941 PUTS "Unknown platform: $platform"
drhd63fbb72015-11-13 12:52:34 +0000942 PUTSNNL "Set the -platform option to "
drh96110de2010-09-06 18:44:14 +0000943 set print [list]
944 foreach p [array names ::Platforms] {
945 lappend print "\"$p\""
946 }
947 lset print end "or [lindex $print end]"
drhe31dc592015-08-14 12:53:37 +0000948 PUTS "[join $print {, }]."
drh96110de2010-09-06 18:44:14 +0000949 exit
950 }
951
drh2eeb7ae2014-10-10 17:44:03 +0000952 if {$config!=""} {
drhe35626f2014-10-10 17:47:00 +0000953 if {[llength $config]==1} {lappend config fulltest}
drh2eeb7ae2014-10-10 17:44:03 +0000954 set ::CONFIGLIST $config
955 } else {
drh71258ab2015-11-04 16:34:58 +0000956 if {$::JOBS>1} {
957 set ::CONFIGLIST {}
958 foreach {target zConfig} [lreverse $::Platforms($platform)] {
959 append ::CONFIGLIST [format " %-25s %s\n" \
960 [list $zConfig] [list $target]]
961 }
962 } else {
963 set ::CONFIGLIST $::Platforms($platform)
964 }
drh2eeb7ae2014-10-10 17:44:03 +0000965 }
drhe31dc592015-08-14 12:53:37 +0000966 PUTS "Running the following test configurations for $platform:"
967 PUTS " [string trim $::CONFIGLIST]"
drhd63fbb72015-11-13 12:52:34 +0000968 PUTSNNL "Flags:"
969 if {$::PROGRESS_MSGS} {PUTSNNL " --progress"}
970 if {$::DRYRUN} {PUTSNNL " --dryrun"}
971 if {$::BUILDONLY} {PUTSNNL " --buildonly"}
972 if {$::MSVC} {PUTSNNL " --msvc"}
drh5bfff9d2015-01-08 01:05:42 +0000973 switch -- $::QUICK {
drhd63fbb72015-11-13 12:52:34 +0000974 1 {PUTSNNL " --quick"}
975 2 {PUTSNNL " --veryquick"}
drh5bfff9d2015-01-08 01:05:42 +0000976 }
drhd63fbb72015-11-13 12:52:34 +0000977 if {$::JOBS>1} {PUTSNNL " --jobs $::JOBS"}
drhe31dc592015-08-14 12:53:37 +0000978 PUTS ""
drh96110de2010-09-06 18:44:14 +0000979}
980
drh2c331832016-09-09 13:17:26 +0000981# Check to see if there are uncommitted changes in the SQLite source
982# checkout. Exit if there are. Except: Do nothing if the --force
983# flag is used. Also, ignore this test if the fossil binary is
984# unavailable, or if the source tree is not a valid fossil checkout.
drh1fbd0082016-09-08 23:12:08 +0000985#
986proc check_uncommitted {} {
drheedeb922016-09-09 12:29:57 +0000987 if {$::FORCE} return
988 set pwd [pwd]
989 cd $::SRCDIR
drh1fbd0082016-09-08 23:12:08 +0000990 if {[catch {exec fossil changes} res]==0 && [string trim $res]!=""} {
drheedeb922016-09-09 12:29:57 +0000991 puts "ERROR: The check-out contains uncommitted changes:"
drh1fbd0082016-09-08 23:12:08 +0000992 puts $res
drheedeb922016-09-09 12:29:57 +0000993 puts "Use the -f or --force options to override"
994 exit 1
drh1fbd0082016-09-08 23:12:08 +0000995 }
drheedeb922016-09-09 12:29:57 +0000996 cd $pwd
drh1fbd0082016-09-08 23:12:08 +0000997}
998
dand562ec22016-09-12 09:28:21 +0000999# A test run has just finished in directory $dir. This command deletes all
1000# non-essential files from the directory. Specifically, everything except
1001#
1002# * The "testfixture" and "sqlite3" binaries,
1003# * The "test-out.log" and "test.log" log files.
1004#
1005proc cleanup {dir} {
1006 set K(testfixture) 1
1007 set K(testfixture.exe) 1
1008 set K(sqlite3) 1
1009 set K(sqlite3.exe) 1
1010 set K(test-out.txt) 1
1011 set K(test.log) 1
1012
1013 foreach f [glob -nocomplain [file join $dir *]] {
1014 set tail [file tail $f]
1015 if {[info exists K($tail)]==0} {
1016 file delete -force $f
1017 }
1018 }
1019}
1020
drh1fbd0082016-09-08 23:12:08 +00001021
drh96110de2010-09-06 18:44:14 +00001022# Main routine.
1023#
1024proc main {argv} {
1025
1026 # Process any command line options.
drhf167a402015-01-07 18:44:59 +00001027 set ::EXTRACONFIG {}
drh96110de2010-09-06 18:44:14 +00001028 process_options $argv
drh1fbd0082016-09-08 23:12:08 +00001029 if {!$::DRYRUN} check_uncommitted
drhe31dc592015-08-14 12:53:37 +00001030 PUTS [string repeat * 79]
drh96110de2010-09-06 18:44:14 +00001031
drh97876ee2014-12-24 23:35:36 +00001032 set ::NERR 0
1033 set ::NTEST 0
drh277b4e42014-12-29 02:55:58 +00001034 set ::NTESTCASE 0
1035 set ::NERRCASE 0
drh5bfff9d2015-01-08 01:05:42 +00001036 set ::SQLITE_VERSION {}
drhd477eee2014-12-23 19:40:51 +00001037 set STARTTIME [clock seconds]
drh96110de2010-09-06 18:44:14 +00001038 foreach {zConfig target} $::CONFIGLIST {
mistachkin00eb70d2015-04-04 00:02:07 +00001039 if {$::MSVC && ($zConfig eq "Sanitize" || "checksymbols" in $target
1040 || "valgrindtest" in $target)} {
drhe31dc592015-08-14 12:53:37 +00001041 PUTS "Skipping $zConfig / $target for MSVC..."
mistachkin00eb70d2015-04-04 00:02:07 +00001042 continue
1043 }
drh5bfff9d2015-01-08 01:05:42 +00001044 if {$target ne "checksymbols"} {
1045 switch -- $::QUICK {
drh905da632015-06-10 18:53:09 +00001046 1 {set target quicktest}
drh5bfff9d2015-01-08 01:05:42 +00001047 2 {set target smoketest}
1048 }
mistachkin00eb70d2015-04-04 00:02:07 +00001049 if {$::BUILDONLY} {
1050 set target testfixture
drh7f8a93d2015-11-03 15:39:29 +00001051 if {$::tcl_platform(platform)=="windows"} {
1052 append target .exe
1053 }
mistachkin00eb70d2015-04-04 00:02:07 +00001054 }
drh5bfff9d2015-01-08 01:05:42 +00001055 }
drhf167a402015-01-07 18:44:59 +00001056 set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]
drh96110de2010-09-06 18:44:14 +00001057
drhd477eee2014-12-23 19:40:51 +00001058 incr NTEST
dana7f65972015-11-02 18:32:00 +00001059 add_test_suite all $zConfig $target $config_options
drh96110de2010-09-06 18:44:14 +00001060
1061 # If the configuration included the SQLITE_DEBUG option, then remove
1062 # it and run veryquick.test. If it did not include the SQLITE_DEBUG option
1063 # add it and run veryquick.test.
drh5bfff9d2015-01-08 01:05:42 +00001064 if {$target!="checksymbols" && $target!="valgrindtest"
drhf3320712015-04-25 13:39:29 +00001065 && $target!="fuzzoomtest" && !$::BUILDONLY && $::QUICK<2} {
danb136e902012-12-10 10:22:48 +00001066 set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]
drhbd41d562014-12-30 20:40:32 +00001067 set xtarget $target
drhaf700b32014-12-31 20:35:11 +00001068 regsub -all {fulltest[a-z]*} $xtarget test xtarget
drhf3320712015-04-25 13:39:29 +00001069 regsub -all {fuzzoomtest} $xtarget fuzztest xtarget
danb136e902012-12-10 10:22:48 +00001070 if {$debug_idx < 0} {
drhd477eee2014-12-23 19:40:51 +00001071 incr NTEST
drhdc6de472017-05-25 11:39:50 +00001072 append config_options " -DSQLITE_DEBUG=1 -DSQLITE_EXTRA_IFNULLROW=1"
dana7f65972015-11-02 18:32:00 +00001073 add_test_suite all "${zConfig}_debug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +00001074 } else {
drhd477eee2014-12-23 19:40:51 +00001075 incr NTEST
drhbd41d562014-12-30 20:40:32 +00001076 regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options
1077 regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options
dana7f65972015-11-02 18:32:00 +00001078 add_test_suite all "${zConfig}_ndebug" $xtarget $config_options
danb136e902012-12-10 10:22:48 +00001079 }
drh96110de2010-09-06 18:44:14 +00001080 }
drh96110de2010-09-06 18:44:14 +00001081 }
drh96110de2010-09-06 18:44:14 +00001082
dana7f65972015-11-02 18:32:00 +00001083 run_all_test_suites $all
1084
drhd477eee2014-12-23 19:40:51 +00001085 set elapsetime [expr {[clock seconds]-$STARTTIME}]
drh97876ee2014-12-24 23:35:36 +00001086 set hr [expr {$elapsetime/3600}]
1087 set min [expr {($elapsetime/60)%60}]
1088 set sec [expr {$elapsetime%60}]
1089 set etime [format (%02d:%02d:%02d) $hr $min $sec]
drh573d88e2016-01-03 11:17:04 +00001090 if {$::JOBS>1} {append etime " $::JOBS cores"}
1091 if {[catch {exec hostname} HNAME]==0} {append etime " on $HNAME"}
drhe31dc592015-08-14 12:53:37 +00001092 PUTS [string repeat * 79]
drhb1031f02015-09-10 15:20:49 +00001093 incr ::NERRCASE $::NERR
drhe31dc592015-08-14 12:53:37 +00001094 PUTS "$::NERRCASE failures out of $::NTESTCASE tests in $etime"
drh5bfff9d2015-01-08 01:05:42 +00001095 if {$::SQLITE_VERSION ne ""} {
drhe31dc592015-08-14 12:53:37 +00001096 PUTS "SQLite $::SQLITE_VERSION"
drh96110de2010-09-06 18:44:14 +00001097 }
1098}
1099
1100main $argv