3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
17 #-------------------------------------------------------------------------
18 # test_suite NAME OPTIONS
20 # where available options are:
22 # -description TITLE (default "")
23 # -initialize SCRIPT (default "")
24 # -shutdown SCRIPT (default "")
25 # -presql SQL (default "")
26 # -files LIST-OF-FILES (default $::ALLTESTS)
27 # -prefix NAME (default "$::NAME.")
28 # -dbconfig SCRIPT (default "")
30 proc test_suite {name args} {
32 set default(-shutdown) ""
33 set default(-initialize) ""
34 set default(-presql) ""
35 set default(-description) "no description supplied (fixme)"
36 set default(-files) ""
37 set default(-prefix) "${name}."
38 set default(-dbconfig) ""
40 array set options [array get default]
41 if {[llength $args]%2} {
42 error "uneven number of options/switches passed to test_suite"
45 set o [array names options ${k}*]
46 if {[llength $o]>1} { error "ambiguous option: $k" }
47 if {[llength $o]==0} { error "unknown option: $k" }
48 set options([lindex $o 0]) $v
51 set ::testspec($name) [array get options]
52 lappend ::testsuitelist $name
55 #-------------------------------------------------------------------------
58 proc test_set {args} {
61 if {[string match -* $a]} {
63 -include { set isExclude 0 }
64 -exclude { set isExclude 1 }
66 error "Unknown switch: $a"
69 } elseif {$isExclude == 0} {
70 foreach f $a { set t($f) 1 }
72 foreach f $a { array unset t $f }
73 foreach f $a { array unset t */$f }
77 return [array names t]
80 #-------------------------------------------------------------------------
81 # Set up the following global list variables containing the names of
82 # various test scripts:
88 foreach f [glob $testdir/*.test] { lappend alltests [file tail $f] }
89 foreach f [glob -nocomplain $testdir/../ext/rtree/*.test] {
93 if {$::tcl_platform(platform)!="unix"} {
94 set alltests [test_set $alltests -exclude crash.test crash2.test]
96 set alltests [test_set $alltests -exclude {
97 all.test async.test quick.test veryquick.test
98 memleak.test permutations.test soak.test fts3.test
99 mallocAll.test rtree.test
102 set allquicktests [test_set $alltests -exclude {
103 async2.test async3.test backup_ioerr.test corrupt.test
104 corruptC.test crash.test crash2.test crash3.test crash4.test crash5.test
105 crash6.test crash7.test delete3.test e_fts3.test fts3rnd.test
106 fkey_malloc.test fuzz.test fuzz3.test fuzz_malloc.test in2.test loadext.test
107 misc7.test mutex2.test notify2.test onefile.test pagerfault2.test
108 savepoint4.test savepoint6.test select9.test
109 speed1.test speed1p.test speed2.test speed3.test speed4.test
110 speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
111 thread003.test thread004.test thread005.test trans2.test vacuum3.test
112 incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
113 vtab_err.test walslow.test walcrash.test walcrash3.test
114 walthread.test rtree3.test indexfault.test
116 if {[info exists ::env(QUICKTEST_INCLUDE)]} {
117 set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
120 #############################################################################
124 #-------------------------------------------------------------------------
125 # Define the generic test suites:
131 lappend ::testsuitelist xxx
133 test_suite "veryquick" -prefix "" -description {
134 "Very" quick test suite. Runs in less than 5 minutes on a workstation.
135 This test suite is the same as the "quick" tests, except that some files
136 that test malloc and IO errors are omitted.
138 test_set $allquicktests -exclude *malloc* *ioerr* *fault*
141 test_suite "valgrind" -prefix "" -description {
142 Run the "veryquick" test suite with a couple of multi-process tests (that
143 fail under valgrind) omitted.
145 test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test
149 unset -nocomplain ::G(valgrind)
152 test_suite "quick" -prefix "" -description {
153 Quick test suite. Runs in around 10 minutes on a workstation.
155 test_set $allquicktests
158 test_suite "full" -prefix "" -description {
159 Full test suite. Takes a long time.
163 unset -nocomplain ::G(isquick)
166 test_suite "threads" -prefix "" -description {
167 All multi-threaded tests.
169 notify2.test thread001.test thread002.test thread003.test
170 thread004.test thread005.test walthread.test
173 test_suite "fts3" -prefix "" -description {
174 All FTS3 tests except fts3rnd.test.
176 fts3aa.test fts3ab.test fts3ac.test fts3ad.test fts3ae.test
177 fts3af.test fts3ag.test fts3ah.test fts3ai.test fts3aj.test
178 fts3ak.test fts3al.test fts3am.test fts3an.test fts3ao.test
179 fts3atoken.test fts3b.test fts3c.test fts3cov.test fts3d.test
180 fts3defer.test fts3defer2.test fts3e.test fts3expr.test fts3expr2.test
181 fts3near.test fts3query.test fts3shared.test fts3snippet.test
183 fts3fault.test fts3malloc.test fts3matchinfo.test
184 fts3aux1.test fts3comp1.test fts3auto.test
185 fts4aa.test fts4content.test
186 fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test
187 fts3corrupt2.test fts3first.test fts4langid.test fts4merge.test
188 fts4check.test fts4unicode.test
191 test_suite "nofaultsim" -prefix "" -description {
192 "Very" quick test suite. Runs in less than 5 minutes on a workstation.
193 This test suite is the same as the "quick" tests, except that some files
194 that test malloc and IO errors are omitted.
196 test_set $allquicktests -exclude *malloc* *ioerr* *fault*
200 install_malloc_faultsim 0
202 autoinstall_test_functions
204 unset -nocomplain ::G(valgrind)
207 lappend ::testsuitelist xxx
208 #-------------------------------------------------------------------------
209 # Define the coverage related test suites:
213 test_suite "coverage-wal" -description {
214 Coverage tests for file wal.c.
216 wal.test wal2.test wal3.test walmode.test
217 walbak.test walhook.test walcrash2.test walcksum.test
218 walfault.test walbig.test walnoshm.test
222 test_suite "coverage-pager" -description {
223 Coverage tests for file pager.c.
225 pager1.test pager2.test pagerfault.test pagerfault2.test
226 walfault.test walbak.test journal2.test tkt-9d68c883.test
230 lappend ::testsuitelist xxx
231 #-------------------------------------------------------------------------
232 # Define the permutation test suites:
235 # Run some tests using pre-allocated page and scratch blocks.
237 test_suite "memsubsys1" -description {
238 Tests using pre-allocated page and scratch blocks
240 test_set $::allquicktests -exclude ioerr5.test malloc5.test
244 sqlite3_config_pagecache 4096 24
245 sqlite3_config_scratch 25000 1
247 autoinstall_test_functions
251 sqlite3_config_pagecache 0 0
252 sqlite3_config_scratch 0 0
254 autoinstall_test_functions
257 # Run some tests using pre-allocated page and scratch blocks. This time
258 # the allocations are too small to use in most cases.
260 # Both ioerr5.test and malloc5.test are excluded because they test the
261 # sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
262 # This functionality is disabled if a pre-allocated page block is provided.
264 test_suite "memsubsys2" -description {
265 Tests using small pre-allocated page and scratch blocks
267 test_set $::allquicktests -exclude ioerr5.test malloc5.test
271 sqlite3_config_pagecache 512 5
272 sqlite3_config_scratch 1000 1
274 autoinstall_test_functions
278 sqlite3_config_pagecache 0 0
279 sqlite3_config_scratch 0 0
281 autoinstall_test_functions
284 # Run all tests with the lookaside allocator disabled.
286 test_suite "nolookaside" -description {
287 OOM tests with lookaside disabled
291 sqlite3_config_lookaside 0 0
293 autoinstall_test_functions
297 sqlite3_config_lookaside 100 500
299 autoinstall_test_functions
300 } -files $::allquicktests
302 # Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
304 test_suite "singlethread" -description {
305 Tests run in SQLITE_CONFIG_SINGLETHREAD mode
309 catch {sqlite3_config singlethread}
311 autoinstall_test_functions
313 delete.test delete2.test insert.test rollback.test select1.test
314 select2.test trans.test update.test vacuum.test types.test
315 types2.test types3.test
319 catch {sqlite3_config serialized}
321 autoinstall_test_functions
324 test_suite "nomutex" -description {
325 Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
327 rename sqlite3 sqlite3_nomutex
328 proc sqlite3 {args} {
329 if {[string range [lindex $args 0] 0 0] ne "-"} {
330 lappend args -fullmutex 0 -nomutex 1
332 uplevel [concat sqlite3_nomutex $args]
335 delete.test delete2.test insert.test rollback.test select1.test
336 select2.test trans.test update.test vacuum.test types.test
337 types2.test types3.test
340 rename sqlite3_nomutex sqlite3
343 # Run some tests in SQLITE_CONFIG_MULTITHREAD mode.
345 test_suite "multithread" -description {
346 Tests run in SQLITE_CONFIG_MULTITHREAD mode
350 catch {sqlite3_config multithread}
352 autoinstall_test_functions
354 delete.test delete2.test insert.test rollback.test select1.test
355 select2.test trans.test update.test vacuum.test types.test
356 types2.test types3.test
360 catch {sqlite3_config serialized}
362 autoinstall_test_functions
365 # Run some tests in SQLITE_OPEN_FULLMUTEX mode.
367 test_suite "fullmutex" -description {
368 Tests run in SQLITE_OPEN_FULLMUTEX mode
370 rename sqlite3 sqlite3_fullmutex
371 proc sqlite3 {args} {
372 if {[string range [lindex $args 0] 0 0] ne "-"} {
373 lappend args -nomutex 0 -fullmutex 1
375 uplevel [concat sqlite3_fullmutex $args]
378 delete.test delete2.test insert.test rollback.test select1.test
379 select2.test trans.test update.test vacuum.test types.test
380 types2.test types3.test
383 rename sqlite3_fullmutex sqlite3
386 # Run some tests using the "onefile" demo.
388 test_suite "onefile" -description {
389 Run some tests using the "test_onefile.c" demo
391 rename sqlite3 sqlite3_onefile
392 proc sqlite3 {args} {
393 if {[string range [lindex $args 0] 0 0] ne "-"} {
396 uplevel [concat sqlite3_onefile $args]
399 conflict.test insert.test insert2.test insert3.test
400 rollback.test select1.test select2.test select3.test
403 rename sqlite3_onefile sqlite3
406 # Run some tests using UTF-16 databases.
408 test_suite "utf16" -description {
409 Run tests using UTF-16 databases
411 pragma encoding = 'UTF-16'
413 alter.test alter3.test
414 auth.test bind.test blob.test capi2.test capi3.test collate1.test
415 collate2.test collate3.test collate4.test collate5.test collate6.test
416 conflict.test date.test delete.test expr.test fkey1.test func.test
417 hook.test index.test insert2.test insert.test interrupt.test in.test
418 intpkey.test ioerr.test join2.test join.test lastinsert.test
419 laststmtchanges.test limit.test lock2.test lock.test main.test
420 memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test
421 null.test progress.test quote.test rowid.test select1.test select2.test
422 select3.test select4.test select5.test select6.test sort.test
423 subselect.test tableapi.test table.test temptable.test
424 trace.test trigger1.test trigger2.test trigger3.test
425 trigger4.test types2.test types.test unique.test update.test
426 vacuum.test view.test where.test
429 # Run some tests in exclusive locking mode.
431 test_suite "exclusive" -description {
432 Run tests in exclusive locking mode.
434 pragma locking_mode = 'exclusive'
436 rollback.test select1.test select2.test
437 malloc.test ioerr.test
440 # Run some tests in exclusive locking mode with truncated journals.
442 test_suite "exclusive-truncate" -description {
443 Run tests in exclusive locking mode and truncate journal mode.
445 pragma locking_mode = 'exclusive';
446 pragma journal_mode = TRUNCATE;
448 delete.test delete2.test insert.test rollback.test select1.test
449 select2.test update.test malloc.test ioerr.test
452 # Run some tests in persistent journal mode.
454 test_suite "persistent_journal" -description {
455 Run tests in persistent-journal mode.
457 pragma journal_mode = persist
459 delete.test delete2.test insert.test rollback.test select1.test
460 select2.test trans.test update.test vacuum.test
463 # Run some tests in truncating journal mode.
465 test_suite "truncate_journal" -description {
466 Run tests in persistent-journal mode.
468 pragma journal_mode = truncate
470 delete.test delete2.test insert.test rollback.test select1.test
471 select2.test trans.test update.test vacuum.test
472 malloc.test ioerr.test
475 # Run some error tests in persistent journal mode.
477 test_suite "persistent_journal_error" -description {
478 Run malloc.test and ioerr.test in persistent-journal mode.
480 pragma journal_mode = persist
482 malloc.test ioerr.test
485 # Run some tests in no journal mode.
487 test_suite "no_journal" -description {
488 Run tests in no-journal mode.
490 pragma journal_mode = persist
492 delete.test delete2.test insert.test rollback.test select1.test
493 select2.test trans.test update.test vacuum.test
496 # Run some error tests in no journal mode.
498 test_suite "no_journal_error" -description {
499 Run malloc.test and ioerr.test in no-journal mode.
501 pragma journal_mode = persist
503 malloc.test ioerr.test
506 # Run some crash-tests in autovacuum mode.
508 test_suite "autovacuum_crash" -description {
509 Run crash.test in autovacuum mode.
511 pragma auto_vacuum = 1
514 # Run some ioerr-tests in autovacuum mode.
516 test_suite "autovacuum_ioerr" -description {
517 Run ioerr.test in autovacuum mode.
519 pragma auto_vacuum = 1
522 # Run tests with an in-memory journal.
524 test_suite "inmemory_journal" -description {
525 Run tests with an in-memory journal file.
527 pragma journal_mode = 'memory'
528 } -files [test_set $::allquicktests -exclude {
529 # Exclude all tests that simulate IO errors.
530 autovacuum_ioerr2.test incrvacuum_ioerr.test ioerr.test
531 ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test
532 vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test
533 e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test
536 # Exclude test scripts that use tcl IO to access journal files or count
537 # the number of fsync() calls.
538 pager.test exclusive.test jrnlmode.test sync.test misc1.test
539 journal1.test conflict.test crash8.test tkt3457.test io.test
540 journal3.test 8_3_names.test
542 pager1.test async4.test corrupt.test filefmt.test pager2.test
543 corrupt5.test corruptA.test pageropt.test
545 # Exclude stmt.test, which expects sub-journals to use temporary files.
550 # WAL mode is different.
551 wal* tkt-2d1a5c67d.test backcompat.test
555 test_suite "memsys3" -description {
556 Run tests using the allocator in mem3.c.
557 } -files [test_set $::allquicktests -exclude {
558 autovacuum.test delete3.test manydb.test
559 bigrow.test incrblob2.test memdb.test
560 bitvec.test index2.test memsubsys1.test
561 capi3c.test ioerr.test memsubsys2.test
562 capi3.test join3.test pagesize.test
563 collate5.test limit.test backup_ioerr.test
567 sqlite3_reset_auto_extension
569 sqlite3_config_heap 25000000 0
570 sqlite3_config_lookaside 0 0
572 # If both memsys3 and memsys5 are enabled in the build, the call to
573 # [sqlite3_config_heap] will initialize the system to use memsys5.
574 # The following overrides this preference and installs the memsys3
576 sqlite3_install_memsys3
578 install_malloc_faultsim 1
580 autoinstall_test_functions
584 sqlite3_config_heap 0 0
585 sqlite3_config_lookaside 100 500
586 install_malloc_faultsim 1
588 autoinstall_test_functions
593 test_suite "memsys5" -description {
594 Run tests using the allocator in mem5.c.
595 } -files [test_set $::allquicktests -exclude {
596 autovacuum.test delete3.test manydb.test
597 bigrow.test incrblob2.test memdb.test
598 bitvec.test index2.test memsubsys1.test
599 capi3c.test ioerr.test memsubsys2.test
600 capi3.test join3.test pagesize.test
601 collate5.test limit.test zeroblob.test
605 sqlite3_config_heap 25000000 64
606 sqlite3_config_lookaside 0 0
607 install_malloc_faultsim 1
609 autoinstall_test_functions
613 sqlite3_config_heap 0 0
614 sqlite3_config_lookaside 100 500
615 install_malloc_faultsim 1
617 autoinstall_test_functions
620 test_suite "memsys5-2" -description {
621 Run tests using the allocator in mem5.c in a different configuration.
627 sqlite3_config_memstatus 0
628 sqlite3_config_heap 40000000 16
629 sqlite3_config_lookaside 0 0
630 install_malloc_faultsim 1
632 autoinstall_test_functions
636 sqlite3_config_heap 0 0
637 sqlite3_config_lookaside 100 500
638 install_malloc_faultsim 1
640 autoinstall_test_functions
644 ifcapable threadsafe {
645 test_suite "no_mutex_try" -description {
646 The sqlite3_mutex_try() interface always fails
648 test_set $::allquicktests -exclude mutex1.test mutex2.test
652 install_mutex_counters 1
653 set ::disable_mutex_try 1
655 autoinstall_test_functions
659 install_mutex_counters 0
661 autoinstall_test_functions
665 # run_tests "crash_safe_append" -description {
666 # Run crash.test with persistent journals on a SAFE_APPEND file-system.
668 # rename crashsql sa_crashsql
669 # proc crashsql {args} {
670 # set options [lrange $args 0 [expr {[llength $args]-2}]]
671 # lappend options -char safe_append
672 # set sql [lindex $args end]
674 # PRAGMA journal_mode=persistent;
677 # set fd [open test.db-journal w]
678 # puts $fd [string repeat 1234567890 100000]
680 # eval sa_crashsql $options
684 # rename sa_crashsql crashsql
685 # } -files crash.test
687 test_suite "safe_append" -description {
688 Run some tests on a SAFE_APPEND file-system.
690 rename sqlite3 sqlite3_safeappend
691 proc sqlite3 {args} {
692 if {[string range [lindex $args 0] 0 0] ne "-"} {
693 lappend args -vfs devsym
695 uplevel [concat sqlite3_safeappend $args]
697 sqlite3_simulate_device -char safe_append
700 rename sqlite3_shutdown sqlite3
702 test_set $::allquicktests shared_err.test -exclude async3.test
705 # The set of tests to run on the alternative-pcache
706 set perm-alt-pcache-testset {
709 delete.test delete2.test
711 insert.test insert2.test
714 select1.test select2.test
719 foreach discard_rate {0 10 50 90 100} {
720 test_suite "pcache${discard_rate}" -description "
721 Alternative pcache implementation with ${discard_rate}% random discard
725 sqlite3_config_alt_pcache 1 $discard_rate 1
727 autoinstall_test_functions
731 sqlite3_config_alt_pcache 0 0 0
732 sqlite3_config_lookaside 100 500
733 install_malloc_faultsim 1
735 autoinstall_test_functions
736 } -files ${perm-alt-pcache-testset}
739 test_suite "journaltest" -description {
740 Check that pages are synced before being written (test_journal.c).
743 register_jt_vfs -default ""
746 } -files [test_set $::allquicktests -exclude {
747 wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test
748 async4.test bigfile.test backcompat.test
751 if {[info commands register_demovfs] != ""} {
752 test_suite "demovfs" -description {
753 Check that the demovfs (code in test_demovfs.c) more or less works.
759 insert.test insert2.test insert3.test rollback.test
760 select1.test select2.test select3.test
764 test_suite "wal" -description {
765 Run tests with journal_mode=WAL
767 set ::G(savepoint6_iterations) 100
769 unset -nocomplain ::G(savepoint6_iterations)
771 savepoint.test savepoint2.test savepoint6.test
772 trans.test avtrans.test
774 fts3aa.test fts3ab.test fts3ac.test fts3ad.test
775 fts3ae.test fts3af.test fts3ag.test fts3ah.test
776 fts3ai.test fts3aj.test fts3ak.test fts3al.test
777 fts3am.test fts3an.test fts3ao.test fts3b.test
778 fts3c.test fts3d.test fts3e.test fts3query.test
781 test_suite "rtree" -description {
782 All R-tree related tests. Provides coverage of source file rtree.c.
783 } -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
785 test_suite "no_optimization" -description {
786 Run test scripts with optimizations disabled using the
787 sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) interface.
789 where.test where2.test where3.test where4.test where5.test
790 where6.test where7.test where8.test where9.test
791 whereA.test whereB.test wherelimit.test
792 select1.test select2.test select3.test select4.test select5.test
793 select7.test select8.test selectA.test selectC.test
795 optimization_control $::dbhandle all 0
798 test_suite "prepare" -description {
799 Run tests with the db connection using sqlite3_prepare() instead of _v2().
801 db_use_legacy_prepare $::dbhandle 1
802 #$::dbhandle cache size 0
804 test_set $allquicktests -exclude *malloc* *ioerr* *fault*
808 #############################################################################
810 # run_tests NAME OPTIONS
812 # where available options are:
818 # -files LIST-OF-FILES
821 proc run_tests {name args} {
822 array set options $args
824 set ::G(perm:name) $name
825 set ::G(perm:prefix) $options(-prefix)
826 set ::G(perm:presql) $options(-presql)
828 set ::G(perm:dbconfig) $options(-dbconfig)
830 uplevel $options(-initialize)
832 foreach file [lsort $options(-files)] {
833 if {[file tail $file] == $file} { set file [file join $::testdir $file] }
834 slave_test_file $file
837 uplevel $options(-shutdown)
840 unset ::G(perm:prefix)
841 unset ::G(perm:presql)
842 unset ::G(perm:dbconfig)
845 proc run_test_suite {name} {
846 if {[info exists ::testspec($name)]==0} {
847 error "No such test suite: $name"
849 uplevel run_tests $name $::testspec($name)
853 puts "Usage: $::argv0 TESTSUITE ?TESTFILE?"
855 puts "Available test-suites are:"
856 foreach k $::testsuitelist {
857 if {[info exists ::testspec($k)]==0} {
858 puts " ----------------------------------------"
861 array set o $::testspec($k)
862 puts "Test suite: \"$k\""
863 set d [string trim $o(-description)]
864 set d [regsub {\n *} $d "\n "]
872 if {[info script] == $argv0} {
874 if {[llength $argv]==0} {
877 set suite [lindex $argv 0]
878 if {[info exists ::testspec($suite)]==0} help
880 if {[llength $argv]>1} { set extra [list -files [lrange $argv 1 end]] }
881 eval run_tests $suite $::testspec($suite) $extra