Debian Codegraph @

test/testrunner_data.tcl

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