interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / testrunner_data.tcl

720 lines · 21117 bytes Raw Blame History
1
2
3
4namespace eval trd {
5 variable tcltest
6 variable extra
7 variable all_configs
8 variable build
9
10
11 # Tcl tests to run for various builds.
12 #
13 set tcltest(linux.Fast-One) veryquick
14 set tcltest(linux.Debug-One) veryquick
15 set tcltest(linux.Debug-Two) veryquick
16 set tcltest(linux.Have-Not) veryquick
17 set tcltest(linux.Secure-Delete) veryquick
18 set tcltest(linux.Unlock-Notify) veryquick
19 set tcltest(linux.Update-Delete-Limit) veryquick
20 set tcltest(linux.Extra-Robustness) veryquick
21 set tcltest(linux.Device-Two) veryquick
22 set tcltest(linux.No-lookaside) veryquick
23 set tcltest(linux.Devkit) veryquick
24 set tcltest(linux.Apple) veryquick
25 set tcltest(linux.Android) veryquick
26 set tcltest(linux.Sanitize) veryquick
27 set tcltest(linux.Device-One) veryquick
28 set tcltest(linux.Default) all_plus_autovacuum_crash
29 set tcltest(linux.Valgrind) valgrind
30
31 set tcltest(osx.Locking-Style) veryquick
32 set tcltest(osx.Have-Not) veryquick
33 set tcltest(osx.Apple) all_less_no_mutex_try
34
35 set tcltest(win.Stdcall) veryquick
36 set tcltest(win.Have-Not) veryquick
37 set tcltest(win.Windows-Memdebug) veryquick
38 set tcltest(win.Windows-Win32Heap) veryquick
39 set tcltest(win.Windows-Sanitize) veryquick
40 set tcltest(win.Default) {full win_unc_locking}
41
42 # Extra [make xyz] tests that should be run for various builds.
43 #
44 set extra(linux.Check-Symbols) checksymbols
45 set extra(linux.Fast-One) {fuzztest sourcetest}
46 set extra(linux.Debug-One) {fuzztest sourcetest mptest}
47 set extra(linux.Debug-Two) {fuzztest sourcetest}
48 set extra(linux.Have-Not) {fuzztest sourcetest}
49 set extra(linux.Secure-Delete) {fuzztest sourcetest}
50 set extra(linux.Unlock-Notify) {fuzztest sourcetest}
51 set extra(linux.Update-Delete-Limit) {fuzztest sourcetest}
52 set extra(linux.Extra-Robustness) {fuzztest sourcetest}
53 set extra(linux.Device-Two) {fuzztest sourcetest threadtest}
54 set extra(linux.No-lookaside) {fuzztest sourcetest}
55 set extra(linux.Devkit) {fuzztest sourcetest}
56 set extra(linux.Android) {fuzztest sourcetest}
57 set extra(linux.Apple) {fuzztest sourcetest}
58 set extra(linux.Sanitize) {fuzztest sourcetest}
59 set extra(linux.Default) {fuzztest sourcetest threadtest}
60
61 set extra(osx.Apple) {fuzztest threadtest}
62 set extra(osx.Have-Not) {fuzztest sourcetest}
63 set extra(osx.Locking-Style) {mptest fuzztest sourcetest}
64
65 set extra(win.Default) mptest
66 set extra(win.Stdcall) {fuzztest sourcetest}
67 set extra(win.Windows-Memdebug) {fuzztest sourcetest}
68 set extra(win.Windows-Win32Heap) {fuzztest sourcetest}
69 set extra(win.Windows-Sanitize) fuzztest
70 set extra(win.Have-Not) {fuzztest sourcetest}
71
72 # The following mirrors the set of test suites invoked by "all.test".
73 #
74 set all_configs {
75 full no_optimization memsubsys1 memsubsys2 singlethread
76 multithread onefile utf16 exclusive persistent_journal
77 persistent_journal_error no_journal no_journal_error
78 autovacuum_ioerr no_mutex_try fullmutex journaltest
79 inmemory_journal pcache0 pcache10 pcache50 pcache90
80 pcache100 prepare mmap session_eec session_strm
81 }
82
83 #-----------------------------------------------------------------------
84 # Start of build() definitions.
85 #
86 set build(Default) {
87 -O2
88 --disable-amalgamation --disable-shared
89 --enable-session
90 -DSQLITE_ENABLE_RBU
91 -DSQLITE_ENABLE_STMT_SCANSTATUS
92 }
93
94 # These two are used by [testrunner.tcl mdevtest] (All-O0) and
95 # [testrunner.tcl sdevtest] (All-Sanitize).
96 #
97 set build(All-Debug) {
98 --with-debug --enable-all
99 -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES
100 -DSQLITE_ENABLE_NORMALIZE
101 }
102 set build(All-O0) {
103 -O0 --enable-all
104 }
105 set build(All-Sanitize) {
106 -DSQLITE_OMIT_LOOKASIDE=1
107 --enable-all -fsanitize=address,undefined -fno-sanitize-recover=undefined
108 }
109
110 set build(Sanitize) {
111 CC=clang -fsanitize=address,undefined -fno-sanitize-recover=undefined
112 -DSQLITE_ENABLE_STAT4
113 -DSQLITE_OMIT_LOOKASIDE=1
114 -DSQLITE_ENABLE_NORMALIZE
115 -DCONFIG_SLOWDOWN_FACTOR=5.0
116 -DSQLITE_ENABLE_RBU
117 --with-debug
118 --enable-all
119 }
120 set build(Stdcall) {
121 -DWITHOUT_JIMSH=1
122 -DUSE_STDCALL=1
123 -DSQLITE_USE_ONLY_WIN32=1
124 -O2
125 }
126
127 # The "Have-Not" configuration sets all possible -UHAVE_feature options
128 # in order to verify that the code works even on platforms that lack
129 # these support services.
130 set build(Have-Not) {
131 -DHAVE_FDATASYNC=0
132 -DHAVE_GMTIME_R=0
133 -DHAVE_ISNAN=0
134 -DHAVE_LOCALTIME_R=0
135 -DHAVE_LOCALTIME_S=0
136 -DHAVE_MALLOC_USABLE_SIZE=0
137 -DHAVE_STRCHRNUL=0
138 -DHAVE_USLEEP=0
139 -DHAVE_UTIME=0
140 -DHAVE_MREMAP=0
141 }
142 set build(Unlock-Notify) {
143 -O2
144 -DSQLITE_ENABLE_UNLOCK_NOTIFY
145 -DSQLITE_THREADSAFE
146 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
147 -DSQLITE_OMIT_AUTOINIT=1
148 }
149 set build(Secure-Delete) {
150 -O2
151 -DSQLITE_SECURE_DELETE=1
152 -DSQLITE_SOUNDEX=1
153 }
154 set build(Update-Delete-Limit) {
155 -O2
156 -DSQLITE_DEFAULT_FILE_FORMAT=4
157 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
158 -DSQLITE_ENABLE_STMT_SCANSTATUS
159 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS
160 -DSQLITE_ENABLE_CURSOR_HINTS
161 }
162 set build(Check-Symbols) {
163 -DSQLITE_MEMDEBUG=1
164 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
165 -DSQLITE_ENABLE_FTS3=1
166 -DSQLITE_ENABLE_RTREE=1
167 -DSQLITE_ENABLE_MEMSYS5=1
168 -DSQLITE_ENABLE_MEMSYS3=1
169 -DSQLITE_ENABLE_COLUMN_METADATA=1
170 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
171 -DSQLITE_SECURE_DELETE=1
172 -DSQLITE_SOUNDEX=1
173 -DSQLITE_ENABLE_ATOMIC_WRITE=1
174 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
175 -DSQLITE_ENABLE_NORMALIZE
176 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
177 -DSQLITE_ENABLE_STAT4
178 -DSQLITE_ENABLE_STMT_SCANSTATUS
179 --enable-fts5 --enable-session
180 }
181 set build(Debug-One) {
182 --disable-shared
183 -O2 -funsigned-char
184 -DSQLITE_DEBUG=1
185 -DSQLITE_MEMDEBUG=1
186 -DSQLITE_MUTEX_NOOP=1
187 -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
188 -DSQLITE_ENABLE_FTS3=1
189 -DSQLITE_ENABLE_RTREE=1
190 -DSQLITE_ENABLE_MEMSYS5=1
191 -DSQLITE_ENABLE_NORMALIZE
192 -DSQLITE_ENABLE_COLUMN_METADATA=1
193 -DSQLITE_ENABLE_STAT4
194 -DSQLITE_ENABLE_HIDDEN_COLUMNS
195 -DSQLITE_MAX_ATTACHED=125
196 -DSQLITE_MUTATION_TEST
197 -DSQLITE_THREAD_MISUSE_ABORT
198 --enable-fts5
199 }
200 set build(Debug-Two) {
201 -DSQLITE_DEFAULT_MEMSTATUS=0
202 -DSQLITE_MAX_EXPR_DEPTH=0
203 --with-debug
204 }
205 set build(Fast-One) {
206 -O6
207 -DSQLITE_ENABLE_FTS4=1
208 -DSQLITE_ENABLE_RTREE=1
209 -DSQLITE_ENABLE_STAT4
210 -DSQLITE_ENABLE_RBU
211 -DSQLITE_MAX_ATTACHED=125
212 -DSQLITE_MAX_MMAP_SIZE=12884901888
213 -DSQLITE_ENABLE_SORTER_MMAP=1
214 --enable-session
215 }
216 set build(Device-One) {
217 -O2
218 -DSQLITE_DEBUG=1
219 -DSQLITE_DEFAULT_AUTOVACUUM=1
220 -DSQLITE_DEFAULT_CACHE_SIZE=64
221 -DSQLITE_DEFAULT_PAGE_SIZE=1024
222 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32
223 -DSQLITE_DISABLE_LFS=1
224 -DSQLITE_ENABLE_ATOMIC_WRITE=1
225 -DSQLITE_ENABLE_IOTRACE=1
226 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
227 -DSQLITE_MAX_PAGE_SIZE=4096
228 -DSQLITE_OMIT_LOAD_EXTENSION=1
229 -DSQLITE_OMIT_PROGRESS_CALLBACK=1
230 -DSQLITE_OMIT_VIRTUALTABLE=1
231 -DSQLITE_ENABLE_HIDDEN_COLUMNS
232 -DSQLITE_TEMP_STORE=3
233 }
234 set build(Device-Two) {
235 -DSQLITE_4_BYTE_ALIGNED_MALLOC=1
236 -DSQLITE_DEFAULT_AUTOVACUUM=1
237 -DSQLITE_DEFAULT_CACHE_SIZE=1000
238 -DSQLITE_DEFAULT_LOCKING_MODE=0
239 -DSQLITE_DEFAULT_PAGE_SIZE=1024
240 -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000
241 -DSQLITE_DISABLE_LFS=1
242 -DSQLITE_ENABLE_FTS3=1
243 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
244 -DSQLITE_ENABLE_RTREE=1
245 -DSQLITE_MAX_COMPOUND_SELECT=50
246 -DSQLITE_MAX_PAGE_SIZE=32768
247 -DSQLITE_OMIT_TRACE=1
248 -DSQLITE_TEMP_STORE=3
249 -DSQLITE_THREADSAFE=2
250 --enable-fts5 --enable-session
251 }
252 set build(Locking-Style) {
253 -O2
254 -DSQLITE_ENABLE_LOCKING_STYLE=1
255 }
256 set build(Android) {
257 -Os
258 -DHAVE_USLEEP=1
259 -DSQLITE_HAVE_ISNAN
260 -DSQLITE_POWERSAFE_OVERWRITE=1
261 -DSQLITE_DEFAULT_FILE_FORMAT=4
262 -DSQLITE_DEFAULT_AUTOVACUUM=1
263 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1
264 -DSQLITE_ENABLE_FTS3
265 -DSQLITE_ENABLE_FTS3_BACKWARDS
266 -DSQLITE_ENABLE_FTS4
267 -DSQLITE_SECURE_DELETE
268 -DSQLITE_ENABLE_BATCH_ATOMIC_WRITE
269 -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD
270 -DSQLITE_ALLOW_ROWID_IN_VIEW
271 -DSQLITE_ENABLE_BYTECODE_VTAB
272 -Wno-unused-parameter
273 -Werror
274 -DUSE_PREAD64
275 -Dfdatasync=fdatasync
276 -DHAVE_MALLOC_H=1
277 -DHAVE_MALLOC_USABLE_SIZE
278 -DSQLITE_ENABLE_DBSTAT_VTAB
279 }
280 # Compile-options used by Android but omitted from these
281 # tests:
282 # -DNDEBUG=1
283 # -DSQLITE_DEFAULT_LEGACY_ALTER_TABLE
284 # -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576
285 # -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600
286 # -DSQLITE_OMIT_BUILTIN_TEST
287 # -DSQLITE_OMIT_LOAD_EXTENSION
288 # -DSQLITE_OMIT_COMPILEOPTION_DIAGS
289 #
290 set build(Apple) {
291 -Os
292 -DHAVE_GMTIME_R=1
293 -DHAVE_ISNAN=1
294 -DHAVE_LOCALTIME_R=1
295 -DHAVE_PREAD=1
296 -DHAVE_PWRITE=1
297 -DHAVE_UTIME=1
298 -DSQLITE_DEFAULT_CACHE_SIZE=1000
299 -DSQLITE_DEFAULT_CKPTFULLFSYNC=1
300 -DSQLITE_DEFAULT_MEMSTATUS=1
301 -DSQLITE_DEFAULT_PAGE_SIZE=1024
302 -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS=1
303 -DSQLITE_ENABLE_API_ARMOR=1
304 -DSQLITE_ENABLE_AUTO_PROFILE=1
305 -DSQLITE_ENABLE_FLOCKTIMEOUT=1
306 -DSQLITE_ENABLE_FTS3=1
307 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
308 -DSQLITE_ENABLE_FTS3_TOKENIZER=1
309 -DSQLITE_ENABLE_NORMALIZE=1
310 -DSQLITE_ENABLE_PERSIST_WAL=1
311 -DSQLITE_ENABLE_PURGEABLE_PCACHE=1
312 -DSQLITE_ENABLE_RTREE=1
313 -DSQLITE_ENABLE_SETLK_TIMEOUT=2
314 -DSQLITE_ENABLE_SNAPSHOT=1
315 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
316 -DSQLITE_MAX_LENGTH=2147483645
317 -DSQLITE_MAX_VARIABLE_NUMBER=500000
318 -DSQLITE_NO_SYNC=1
319 -DSQLITE_OMIT_AUTORESET=1
320 -DSQLITE_OMIT_LOAD_EXTENSION=1
321 -DSQLITE_PREFER_PROXY_LOCKING=1
322 -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
323 -DSQLITE_THREADSAFE=2
324 -DSQLITE_USE_URI=1
325 -DSQLITE_WRITE_WALFRAME_PREBUFFERED=1
326 -DUSE_GUARDED_FD=1
327 -DUSE_PREAD=1
328 --enable-fts5
329 }
330 set build(Extra-Robustness) {
331 -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
332 -DSQLITE_MAX_ATTACHED=62
333 }
334 set build(Devkit) {
335 -DSQLITE_DEFAULT_FILE_FORMAT=4
336 -DSQLITE_MAX_ATTACHED=30
337 -DSQLITE_ENABLE_COLUMN_METADATA
338 -DSQLITE_ENABLE_FTS4
339 -DSQLITE_ENABLE_FTS5
340 -DSQLITE_ENABLE_FTS4_PARENTHESIS
341 -DSQLITE_DISABLE_FTS4_DEFERRED
342 -DSQLITE_ENABLE_RTREE
343 --enable-fts5
344 }
345 set build(No-lookaside) {
346 -DSQLITE_TEST_REALLOC_STRESS=1
347 -DSQLITE_OMIT_LOOKASIDE=1
348 }
349 set build(Valgrind) {
350 -DSQLITE_ENABLE_STAT4
351 -DSQLITE_ENABLE_FTS4
352 -DSQLITE_ENABLE_RTREE
353 -DSQLITE_ENABLE_HIDDEN_COLUMNS
354 -DCONFIG_SLOWDOWN_FACTOR=8.0
355 }
356
357 set build(Windows-Memdebug) {
358 MEMDEBUG=1
359 DEBUG=3
360 }
361 set build(Windows-Win32Heap) {
362 WIN32HEAP=1
363 DEBUG=4
364 ENABLE_SETLK=1
365 }
366 set build(Windows-Sanitize) {
367 ASAN=1
368 }
369}
370
371
372#-------------------------------------------------------------------------
373proc trd_import {} {
374 uplevel {
375 variable ::trd::tcltest
376 variable ::trd::extra
377 variable ::trd::all_configs
378 variable ::trd::build
379 }
380}
381
382proc trd_builds {platform} {
383 trd_import
384
385 set klist [lsort -uniq [concat \
386 [array names tcltest ${platform}.*] \
387 [array names extra ${platform}.*] \
388 ]]
389 if {[llength $klist]==0} {
390 error "no such platform: $platform"
391 }
392
393 set ret ""
394 foreach k $klist {
395 foreach {p c} [split $k "."] {}
396 lappend ret $c
397 }
398 set ret
399}
400
401proc trd_configs {platform bld} {
402 trd_import
403
404 set clist [list]
405
406 if {[info exists tcltest($platform.$bld)]} {
407 set clist $tcltest($platform.$bld)
408 if {$clist=="all"} {
409 set clist $all_configs
410 } elseif {$clist=="all_plus_autovacuum_crash"} {
411 set clist [concat $all_configs autovacuum_crash]
412 } elseif {$clist=="all_less_no_mutex_try"} {
413 set idx [lsearch $all_configs no_mutex_try]
414 set clist [lreplace $all_configs $idx $idx]
415 }
416 }
417
418 set clist
419}
420
421proc trd_extras {platform bld} {
422 trd_import
423 if {[info exists extra($platform.$bld)]==0} { return [list] }
424 return $extra($platform.$bld)
425}
426
427# Usage:
428#
429# trd_fuzztest_data $buildname $bNoSan
430#
431# This returns data used by testrunner.tcl to run commands equivalent
432# to [make fuzztest]. The returned value is a list, which should be
433# interpreted as a sequence of pairs. The first element of each pair
434# is an interpreter name. The second element is a list of files.
435# testrunner.tcl automatically creates one job to build each interpreter,
436# and one to run each of the files with it once it has been built.
437#
438# In practice, the returned value looks like this:
439#
440# {
441# {fuzzcheck {$testdir/fuzzdata1.db $testdir/fuzzdata2.db ...}}
442# {{sessionfuzz run} $testdir/sessionfuzz-data1.db}
443# }
444#
445# where $testdir is replaced by the full-path to the test-directory (the
446# directory containing this file). "fuzzcheck" and "sessionfuzz" have .exe
447# extensions on windows.
448#
449proc trd_fuzztest_data {buildname bNoSan} {
450 set EXE ""
451 set lFuzzDb [glob [file join $::testdir fuzzdata*.db]]
452 set lSessionDb [glob [file join $::testdir sessionfuzz-data*.db]]
453 set sanBuilds {All-Debug Apple Have-Not Update-Delete-Limit}
454
455 if {$::tcl_platform(os) eq "Windows NT"} {
456 return [list fuzzcheck.exe $lFuzzDb]
457 } else {
458 set lRet [list [trd_get_bin_name fuzzcheck] $lFuzzDb]
459 if {$bNoSan==0 && [lsearch $sanBuilds $buildname]>=0} {
460 lappend lRet [trd_get_bin_name fuzzcheck-asan] $lFuzzDb
461 if {$::tcl_platform(os) ne "OpenBSD"} {
462 lappend lRet [trd_get_bin_name fuzzcheck-ubsan] $lFuzzDb
463 }
464 }
465 lappend lRet {sessionfuzz run} $lSessionDb
466 return $lRet
467 }
468}
469
470
471proc trd_all_configs {} {
472 trd_import
473 set all_configs
474}
475
476proc trimscript {text} {
477 set text [string map {"\n " "\n"} [string trim $text]]
478 set text [string map {"\n\n" "\n"} $text]
479 return $text
480}
481
482proc make_sh_script {srcdir opts cflags makeOpts configOpts {targets {}}} {
483
484 set tcldir [::tcl::pkgconfig get libdir,install]
485 set myopts ""
486 if {[info exists ::env(OPTS)]} {
487 append myopts "# From environment variable:\n"
488 append myopts "OPTS=\"$::env(OPTS)\"\n\n"
489 }
490 foreach o [lsort $opts] {
491 append myopts "OPTS=\"\$OPTS $o\"\n"
492 }
493
494 set out "set -e\n"
495 if {[llength $targets]==0} {
496 set out [trimscript {
497 if [ "$#" -lt 1 ] ; then
498 echo "Usage: $0 <target>"
499 exit -1
500 fi
501 }]\n
502 }
503 append out [trimscript [subst -nocommands {
504 SRCDIR="$srcdir"
505 TCLDIR="$tcldir"
506 if [ ! -f Makefile ] ; then
507 \$SRCDIR/configure --with-tcl=\$TCLDIR $configOpts
508 fi
509 $myopts
510 CFLAGS="$cflags"
511 }]]\n
512 if {[llength $targets]==0} {set targets {$*}}
513 append out [trimscript [subst -nocommands {
514 make $targets "CFLAGS=\$CFLAGS" "OPTS=\$OPTS" $makeOpts
515 }]]
516 return $out
517}
518
519# Generate the text of a *.bat script.
520#
521proc make_bat_file {srcdir opts cflags makeOpts {targets {}}} {
522 set srcdir [file nativename [file normalize $srcdir]]
523 set makefile $srcdir\\Makefile.msc
524 if {[llength $targets]==0} {
525 return [trimscript [subst -nocommands {
526 set TARGET=%1
527 set TMP=%CD%
528 nmake /f $makefile TOP="$srcdir" %TARGET% "CCOPTS=$cflags" "OPTS=$opts" $makeOpts
529 }]]
530 } else {
531 return [trimscript [subst -nocommands {
532 set TMP=%CD%
533 nmake /f $makefile TOP="$srcdir" $targets "CCOPTS=$cflags" "OPTS=$opts" $makeOpts
534 }]]
535 }
536}
537
538
539# Generate the text of a shell script.
540#
541proc make_script {cfg srcdir bMsvc {targets {}}} {
542 set opts [list] ;# OPTS value
543 set cflags [expr {$bMsvc ? "-Zi" : "-g"}] ;# CFLAGS value
544 set makeOpts [list] ;# Extra args for [make]
545 set configOpts [list] ;# Extra args for [configure]
546
547 # Define either SQLITE_OS_WIN or SQLITE_OS_UNIX, as appropriate.
548 if {$::tcl_platform(os) eq "Windows NT"} {
549 lappend opts -DSQLITE_OS_WIN=1
550 } else {
551 lappend opts -DSQLITE_OS_UNIX=1
552 }
553
554 # Unless the configuration specifies -DHAVE_USLEEP=0, set -DHAVE_USLEEP=1.
555 #
556 if {[lsearch $cfg "-DHAVE_USLEEP=0"]<0} {
557 lappend cfg -DHAVE_USLEEP=1
558 }
559
560 # Loop through the parameters of the nominated configuration, updating
561 # $opts, $cflags, $makeOpts and $configOpts along the way. Rules are as
562 # follows:
563 #
564 # 1. If the parameter begins with "-D", add it to $opts.
565 #
566 # 2. If the parameter begins with "--" add it to $configOpts. Unless
567 # this command is preparing a script for MSVC - then add an
568 # equivalent to $makeOpts or $opts.
569 #
570 # 3. If the parameter begins with "-" add it to $cflags. If in MSVC
571 # mode and the parameter is an -O<integer> option, instead add
572 # an OPTIMIZATIONS=<integer> switch to $makeOpts.
573 #
574 # 4. If none of the above apply, add the parameter to $makeOpts
575 #
576 foreach param $cfg {
577
578 if {[string range $param 0 1]=="-D"} {
579 lappend opts $param
580 continue
581 }
582
583 if {[string range $param 0 1]=="--"} {
584 if {$bMsvc==0} {
585 lappend configOpts $param
586 } else {
587
588 switch -- $param {
589 --disable-amalgamation {
590 lappend makeOpts USE_AMALGAMATION=0
591 }
592 --disable-shared {
593 lappend makeOpts USE_CRT_DLL=0 DYNAMIC_SHELL=0
594 }
595 --enable-fts5 {
596 lappend opts -DSQLITE_ENABLE_FTS5
597 }
598 --enable-shared {
599 lappend makeOpts USE_CRT_DLL=1 DYNAMIC_SHELL=1
600 }
601 --enable-session {
602 lappend opts -DSQLITE_ENABLE_PREUPDATE_HOOK
603 lappend opts -DSQLITE_ENABLE_SESSION
604 }
605 --enable-all {
606 }
607 --with-debug {
608 # lappend makeOpts OPTIMIZATIONS=0
609 lappend opts -DSQLITE_DEBUG
610 }
611 default {
612 error "Cannot translate $param for MSVC"
613 }
614 }
615 }
616
617 continue
618 }
619
620 if {[string range $param 0 0]=="-"} {
621
622 if {$bMsvc} {
623 if {[regexp -- {^-O(\d+)$} $param -> level]} {
624 lappend makeOpts OPTIMIZATIONS=$level
625 continue
626 }
627 if {$param eq "-fsanitize=address,undefined"} {
628 lappend makeOpts ASAN=1
629 continue
630 }
631 }
632
633 lappend cflags $param
634 continue
635 }
636
637 lappend makeOpts $param
638 }
639
640 if {$bMsvc==0} {
641 return [make_sh_script $srcdir $opts $cflags $makeOpts $configOpts $targets]
642 } else {
643 return [make_bat_file $srcdir $opts $cflags $makeOpts $targets]
644 }
645}
646
647# Usage:
648#
649# trd_buildscript CONFIG SRCDIR MSVC
650#
651# This command returns the full text of a script (either a shell script or
652# an ms-dos bat file) that may be used to build SQLite source code according
653# to a nominated configuration.
654#
655# Parameter CONFIG must be a configuration defined above in the ::trd::build
656# array. SRCDIR is the root directory of an SQLite source tree (the parent
657# directory of that containing this script). MSVC is a boolean - true to
658# use the MSVC compiler, false otherwise.
659#
660proc trd_buildscript {config srcdir bMsvc {targets {}}} {
661 trd_import
662
663 # Ensure that the named configuration exists.
664 if {![info exists build($config)]} {
665 if {$config!="help"} {
666 puts "No such build config: $config"
667 }
668 puts "Available configurations: [lsort [array names build]]"
669 flush stdout
670 exit 1
671 }
672
673 # Generate and return the script.
674 return [make_script $build($config) $srcdir $bMsvc $targets]
675}
676
677# Usage:
678#
679# trd_test_script_properties PATH
680#
681# The argument must be a path to a Tcl test script. This function scans the
682# first 100 lines of the script for lines that look like:
683#
684# TESTRUNNER: <properties>
685#
686# where <properties> is a list of identifiers, each of which defines a
687# property of the test script. Example properties are "slow" or "superslow".
688#
689proc trd_test_script_properties {path} {
690 # Use this global array as a cache:
691 global trd_test_script_properties_cache
692
693 if {![info exists trd_test_script_properties_cache($path)]} {
694 set fd [open $path]
695 set ret [list]
696 for {set line 0} {$line < 100 && ![eof $fd]} {incr line} {
697 set text [gets $fd]
698 if {[string match -nocase *testrunner:* $text]} {
699 regexp -nocase {.*testrunner:(.*)} $text -> properties
700 lappend ret {*}$properties
701 }
702 }
703 set trd_test_script_properties_cache($path) $ret
704 close $fd
705 }
706
707 set trd_test_script_properties_cache($path)
708}
709
710# Usage:
711#
712# trd_get_bin_name executable-file-name
713#
714# If the tcl platform is "unix", return $bin, else return
715# ${bin}.exe.
716proc trd_get_bin_name {bin} {
717 global tcl_platform
718 if {"unix" eq $tcl_platform(platform)} {return $bin}
719 return $bin.exe
720}