Modify the new "--append" option to the .archive so that it takes a filename
[sqlite.git] / test / permutations.test
blobc1d28d4e09a24013c03991a8b0fca19a99e7f0f5
1 # 2008 June 21
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
15 db close
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"
43   }
44   foreach {k v} $args {
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
49   }
51   set     ::testspec($name) [array get options]
52   lappend ::testsuitelist $name
55 #-------------------------------------------------------------------------
56 # test_set ARGS...
58 proc test_set {args} {
59   set isExclude 0
60   foreach a $args {
61     if {[string match -* $a]} {
62       switch -- $a {
63         -include { set isExclude 0 }
64         -exclude { set isExclude 1 }
65         default {
66           error "Unknown switch: $a"
67         }
68       }
69     } elseif {$isExclude == 0} {
70       foreach f $a { set t($f) 1 }
71     } else {
72       foreach f $a { array unset t $f }
73       foreach f $a { array unset t */$f }
74     }
75   }
77   return [array names t]
80 #-------------------------------------------------------------------------
81 # Set up the following global list variables containing the names of 
82 # various test scripts:
84 #   $alltests
85 #   $allquicktests
87 set alltests [list]
88 foreach f [glob $testdir/*.test] { lappend alltests [file tail $f] }
89 foreach f [glob -nocomplain            \
90     $testdir/../ext/rtree/*.test       \
91     $testdir/../ext/fts5/test/*.test   \
92     $testdir/../ext/expert/*.test      \
93     $testdir/../ext/lsm1/test/*.test   \
94 ] {
95   lappend alltests $f 
97 foreach f [glob -nocomplain $testdir/../ext/session/*.test] { 
98   lappend alltests $f 
101 if {$::tcl_platform(platform)!="unix"} {
102   set alltests [test_set $alltests -exclude crash.test crash2.test]
104 set alltests [test_set $alltests -exclude {
105   all.test        async.test         quick.test  veryquick.test
106   memleak.test    permutations.test  soak.test   fts3.test
107   mallocAll.test  rtree.test         full.test   extraquick.test
108   session.test
111 set allquicktests [test_set $alltests -exclude {
112   async2.test async3.test backup_ioerr.test corrupt.test
113   corruptC.test crash.test crash2.test crash3.test crash4.test crash5.test
114   crash6.test crash7.test delete3.test e_fts3.test fts3rnd.test
115   fkey_malloc.test fuzz.test fuzz3.test fuzz_malloc.test in2.test loadext.test
116   misc7.test mutex2.test notify2.test onefile.test pagerfault2.test 
117   savepoint4.test savepoint6.test select9.test 
118   speed1.test speed1p.test speed2.test speed3.test speed4.test 
119   speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
120   thread003.test thread004.test thread005.test trans2.test vacuum3.test 
121   incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
122   vtab_err.test walslow.test walcrash.test walcrash3.test
123   walthread.test rtree3.test indexfault.test securedel2.test
124   sort3.test sort4.test fts4growth.test fts4growth2.test
125   bigsort.test rbu.test walprotocol.test mmap4.test fuzzer2.test
126   walcrash2.test e_fkey.test backup.test
128   fts4merge.test fts4merge2.test fts4merge4.test fts4check.test
129   fts3cov.test fts3snippet.test fts3corrupt2.test fts3an.test
130   fts3defer.test fts4langid.test fts3sort.test fts5unicode.test
132   rtree4.test
134 if {[info exists ::env(QUICKTEST_INCLUDE)]} {
135   set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
137 if {[info exists ::env(QUICKTEST_OMIT)]} {
138   foreach x [split $::env(QUICKTEST_OMIT) ,] {
139     regsub -all \\y$x\\y $allquicktests {} allquicktests
140   }
143 # If the TEST_FAILURE environment variable is set, it means that we what to
144 # deliberately provoke test failures in order to test the test infrastructure.
145 # Only the main.test module is needed for this.
147 if {[info exists ::env(TEST_FAILURE)]} {
148   set allquicktests main.test
151 #############################################################################
152 # Start of tests
155 #-------------------------------------------------------------------------
156 # Define the generic test suites:
158 #   veryquick
159 #   quick
160 #   full
162 lappend ::testsuitelist xxx
164 test_suite "veryquick" -prefix "" -description {
165   "Very" quick test suite. Runs in minutes on a workstation.
166   This test suite is the same as the "quick" tests, except that some files
167   that test malloc and IO errors are omitted.
168 } -files [
169   test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
170       *fts5corrupt* *fts5big* *fts5aj*
173 test_suite "extraquick" -prefix "" -description {
174   "Extra" quick test suite. Runs in a few minutes on a workstation.
175   This test suite is the same as the "veryquick" tests, except that
176   slower tests are omitted.
177 } -files [
178   test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
179      wal3.test fts4merge* sort2.test mmap1.test walcrash* \
180      percentile.test where8m.test walcksum.test savepoint3.test \
181      fuzzer1.test fuzzer3.test fts3expr3.test
184 test_suite "mmap" -prefix "mm-" -description {
185   Similar to veryquick. Except with memory mapping enabled.
186 } -presql {
187   pragma mmap_size = 268435456;
188 } -files [
189   test_set $allquicktests -exclude *malloc* *ioerr* *fault* -include malloc.test
192 test_suite "valgrind" -prefix "" -description {
193   Run the "veryquick" test suite with a couple of multi-process tests (that
194   fail under valgrind) omitted.
195 } -files [
196   test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err* wal.test \
197               shell*.test crash8.test atof1.test selectG.test \
198               tkt-fc62af4523.test numindex1.test corruptK.test
199 ] -initialize {
200   set ::G(valgrind) 1
201 } -shutdown {
202   unset -nocomplain ::G(valgrind)
205 test_suite "valgrind-nolookaside" -prefix "" -description {
206   Run the "veryquick" test suite with a couple of multi-process tests (that
207   fail under valgrind) omitted.
208 } -files [
209   test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err* \
210       wal.test atof1.test
211 ] -initialize {
212   set ::G(valgrind) 1
213   catch {db close}
214   sqlite3_shutdown
215   sqlite3_config_lookaside 0 0
216   sqlite3_initialize
217   autoinstall_test_functions
218 } -shutdown {
219   catch {db close}
220   sqlite3_shutdown
221   sqlite3_config_lookaside 100 500
222   sqlite3_initialize
223   autoinstall_test_functions
224   unset -nocomplain ::G(valgrind)
228 test_suite "quick" -prefix "" -description {
229   Quick test suite. Runs in around 10 minutes on a workstation.
230 } -files [
231   test_set $allquicktests
234 test_suite "full" -prefix "" -description {
235   Full test suite. Takes a long time.
236 } -files [ 
237   test_set $alltests 
238 ] -initialize {
239   unset -nocomplain ::G(isquick)
242 test_suite "threads" -prefix "" -description {
243   All multi-threaded tests.
244 } -files {
245   notify2.test   thread001.test thread002.test thread003.test 
246   thread004.test thread005.test walthread.test
249 test_suite "fts3" -prefix "" -description {
250   All FTS3 tests except fts3rnd.test.
251 } -files {
252   fts3aa.test fts3ab.test fts3ac.test fts3ad.test
253   fts3ae.test fts3af.test fts3ag.test fts3ah.test
254   fts3ai.test fts3aj.test fts3ak.test fts3al.test
255   fts3am.test fts3an.test fts3ao.test fts3atoken.test
256   fts3auto.test fts3aux1.test fts3aux2.test fts3b.test
257   fts3comp1.test fts3conf.test fts3corrupt2.test fts3corrupt.test
258   fts3cov.test fts3c.test fts3defer2.test fts3defer3.test
259   fts3defer.test fts3drop.test fts3d.test fts3e.test
260   fts3expr2.test fts3expr3.test fts3expr4.test fts3expr5.test
261   fts3expr.test fts3fault2.test fts3fault.test fts3first.test
262   fts3join.test fts3malloc.test fts3matchinfo.test fts3near.test
263   fts3offsets.test fts3prefix2.test fts3prefix.test fts3query.test
264   fts3shared.test fts3snippet.test fts3sort.test fts3tok1.test
265   fts3tok_err.test fts3varint.test fts4aa.test fts4check.test
266   fts4content.test fts4docid.test fts4growth2.test fts4growth.test
267   fts4incr.test fts4langid.test fts4lastrowid.test fts4merge2.test
268   fts4merge4.test fts4merge.test fts4noti.test fts4onepass.test 
269   fts4opt.test fts4unicode.test
270   fts3corrupt3.test
271   fts3misc.test
274 test_suite "fts5" -prefix "" -description {
275   All FTS5 tests.
276 } -files [glob -nocomplain $::testdir/../ext/fts5/test/*.test]
278 test_suite "fts5-light" -prefix "" -description {
279   All FTS5 tests.
280 } -files [
281   test_set \
282       [glob -nocomplain $::testdir/../ext/fts5/test/*.test] \
283       -exclude *corrupt* *fault* *big* *fts5aj*
286 test_suite "lsm1" -prefix "" -description {
287   All LSM1 tests.
288 } -files [glob -nocomplain $::testdir/../ext/lsm1/test/*.test]
290 test_suite "nofaultsim" -prefix "" -description {
291   "Very" quick test suite. Runs in less than 5 minutes on a workstation. 
292   This test suite is the same as the "quick" tests, except that some files
293   that test malloc and IO errors are omitted.
294 } -files [
295   test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err*
296 ] -initialize {
297   catch {db close}
298   sqlite3_shutdown
299   install_malloc_faultsim 0
300   sqlite3_initialize
301   autoinstall_test_functions
302 } -shutdown {
303   unset -nocomplain ::G(valgrind)
306 test_suite "queryplanner" -prefix "" -description {
307   Tests of the query planner and query optimizer
308 } -files {
309   alter2.test alter3.test alter4.test alter.test analyze3.test
310   analyze4.test analyze5.test analyze6.test analyze7.test analyze8.test
311   analyze.test attach2.test attach3.test attach4.test
312   attach.test autoinc.test autoindex1.test between.test cast.test
313   check.test closure01.test coalesce.test collate1.test collate2.test
314   collate3.test collate4.test collate5.test collate6.test collate7.test
315   collate8.test collate9.test collateA.test colmeta.test colname.test
316   conflict.test count.test coveridxscan.test createtab.test cse.test
317   date.test dbstatus2.test dbstatus.test default.test delete2.test
318   delete3.test delete.test descidx1.test descidx2.test descidx3.test
319   distinctagg.test distinct.test e_createtable.test e_delete.test
320   e_droptrigger.test e_dropview.test e_expr.test e_insert.test
321   eqp.test e_reindex.test e_resolve.test e_select2.test e_select.test
322   e_update.test exists.test expr.test fkey1.test fkey2.test fkey3.test
323   fkey4.test fkey5.test func2.test func3.test func.test 
324   in3.test in4.test in5.test index2.test index3.test
325   index4.test index5.test indexedby.test index.test
326   insert2.test insert3.test insert4.test insert5.test insert.test
327   instr.test in.test intpkey.test join2.test join3.test join4.test
328   join5.test join6.test join.test like2.test like.test limit.test
329   minmax2.test minmax3.test minmax4.test minmax.test misc1.test misc2.test
330   misc3.test misc4.test misc5.test misc6.test misc7.test orderby1.test
331   orderby2.test orderby3.test orderby4.test randexpr1.test regexp1.test
332   reindex.test rowhash.test rowid.test schema2.test schema3.test
333   schema4.test schema5.test schema.test
334   select1.test select2.test select3.test select4.test select5.test
335   select6.test select7.test select8.test select9.test selectA.test
336   selectB.test selectC.test selectD.test selectE.test sidedelete.test
337   sort.test spellfix.test subquery2.test subquery.test subselect.test
338   substr.test tkt-02a8e81d44.test tkt1435.test tkt1443.test tkt1444.test
339   tkt1449.test tkt1473.test tkt1501.test tkt1512.test tkt1514.test
340   tkt1536.test tkt1537.test tkt1567.test tkt1644.test tkt1667.test
341   tkt1873.test tkt2141.test tkt2192.test tkt2213.test tkt2251.test
342   tkt2285.test tkt2332.test tkt2339.test tkt2391.test tkt2409.test
343   tkt2450.test tkt2565.test tkt2640.test tkt2643.test tkt2686.test
344   tkt-26ff0c2d1e.test tkt2767.test tkt2817.test tkt2820.test tkt2822.test
345   tkt2832.test tkt2854.test tkt2920.test tkt2927.test tkt2942.test
346   tkt-2a5629202f.test tkt-2d1a5c67d.test tkt-2ea2425d34.test tkt3080.test
347   tkt3093.test tkt3121.test tkt-31338dca7e.test tkt-313723c356.test
348   tkt3201.test tkt3292.test tkt3298.test tkt3334.test tkt3346.test
349   tkt3357.test tkt3419.test tkt3424.test tkt3442.test tkt3457.test
350   tkt3461.test tkt3493.test tkt3508.test tkt3522.test tkt3527.test
351   tkt3541.test tkt3554.test tkt3581.test tkt35xx.test tkt3630.test
352   tkt3718.test tkt3731.test tkt3757.test tkt3761.test tkt3762.test
353   tkt3773.test tkt3791.test tkt3793.test tkt3810.test tkt3824.test
354   tkt3832.test tkt3838.test tkt3841.test tkt-385a5b56b9.test tkt3871.test
355   tkt3879.test tkt-38cb5df375.test tkt3911.test tkt3918.test tkt3922.test
356   tkt3929.test tkt3935.test tkt3992.test tkt3997.test tkt-3998683a16.test
357   tkt-3a77c9714e.test tkt-3fe897352e.test tkt4018.test tkt-4a03edc4c8.test
358   tkt-4dd95f6943.test tkt-54844eea3f.test tkt-5d863f876e.test
359   tkt-5e10420e8d.test tkt-5ee23731f.test tkt-6bfb98dfc0.test
360   tkt-752e1646fc.test tkt-78e04e52ea.test tkt-7a31705a7e6.test
361   tkt-7bbfb7d442.test tkt-80ba201079.test tkt-80e031a00f.test
362   tkt-8454a207b9.test tkt-91e2e8ba6f.test tkt-94c04eaadb.test
363   tkt-9d68c883.test tkt-a7b7803e.test tkt-b1d3a2e531.test
364   tkt-b351d95f9.test tkt-b72787b1.test tkt-bd484a090c.test
365   tkt-bdc6bbbb38.test tkt-c48d99d690.test tkt-cbd054fa6b.test
366   tkt-d11f09d36e.test tkt-d635236375.test tkt-d82e3f3721.test
367   tkt-f3e5abed55.test tkt-f777251dc7a.test tkt-f7b4edec.test
368   tkt-f973c7ac31.test tkt-fa7bf5ec.test tkt-fc62af4523.test
369   tkt-fc7bd6358f.test trigger1.test trigger2.test trigger3.test
370   trigger4.test trigger5.test trigger6.test trigger7.test trigger8.test
371   trigger9.test triggerA.test triggerB.test triggerC.test triggerD.test
372   types2.test types3.test types.test unique.test unordered.test
373   update.test view.test vtab1.test vtab2.test vtab3.test vtab4.test
374   vtab5.test vtab6.test vtab7.test vtab8.test vtab9.test vtab_alter.test
375   vtabA.test vtabB.test vtabC.test vtabD.test vtabE.test
376   vtabF.test where2.test where3.test where4.test where5.test where6.test
377   where7.test where8m.test where8.test where9.test whereA.test whereB.test
378   whereC.test whereD.test whereE.test whereF.test wherelimit.test
379   where.test
382 test_suite "vfslog" -prefix "" -description {
383   "Vfslog" quick test suite. Like "veryquick" except does not omits
384   a few tests that do not work with a version 1 VFS. And the quota* tests,
385   which do not work with a VFS that uses the pVfs argument passed to
386   sqlite3_vfs methods.
387 } -files [
388   test_set $allquicktests -exclude *malloc* *ioerr* *fault* oserror.test \
389   pager1.test syscall.test sysfault.test tkt3457.test quota* superlock* \
390   wal* mmap*
393 test_suite "atomic-batch-write" -prefix "" -description {
394   Like veryquick.test, but must be run on a file-system that supports
395   atomic-batch-writes. Tests that depend on the journal file being present
396   are omitted.
397 } -files [
398   test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
399       *fts5corrupt* *fts5big* *fts5aj*  \
400       crash8.test delete_db.test        \
401       exclusive.test journal3.test      \
402       journal1.test                     \
403       jrnlmode.test jrnlmode2.test      \
404       lock4.test pager1.test            \
405       pager3.test sharedA.test          \
406       symlink.test stmt.test            \
407       sync.test sync2.test              \
408       tempdb.test tkt3457.test          \
409       vacuum5.test wal2.test            \
410       walmode.test zerodamage.test
411 ] -initialize {
412   if {[atomic_batch_write test.db]==0} {
413     error "File system does NOT support atomic-batch-write"
414   }
417 lappend ::testsuitelist xxx
418 #-------------------------------------------------------------------------
419 # Define the coverage related test suites:
421 #   coverage-wal
423 test_suite "coverage-wal" -description {
424   Coverage tests for file wal.c.
425 } -files {
426   wal.test       wal2.test     wal3.test       walmode.test    
427   walbak.test    walhook.test  walcrash2.test  walcksum.test
428   walfault.test  walbig.test   walnoshm.test
429   wal5.test
432 test_suite "coverage-pager" -description {
433   Coverage tests for file pager.c.
434 } -files {
435   pager1.test    pager2.test  pagerfault.test  pagerfault2.test
436   walfault.test  walbak.test  journal2.test    tkt-9d68c883.test
439 test_suite "coverage-analyze" -description {
440   Coverage tests for file analyze.c.
441 } -files {
442   analyze3.test analyze4.test analyze5.test analyze6.test
443   analyze7.test analyze8.test analyze9.test analyzeA.test
444   analyze.test analyzeB.test mallocA.test
447 test_suite "coverage-sorter" -description {
448   Coverage tests for file vdbesort.c.
449 } -files {
450   sort.test sortfault.test
454 lappend ::testsuitelist xxx
455 #-------------------------------------------------------------------------
456 # Define the permutation test suites:
459 # Run some tests using pre-allocated page blocks.
461 # mmap1.test is excluded because a good number of its tests depend on 
462 # the page-cache being larger than the database. But this permutation
463 # causes the effective limit on the page-cache to be just 24 pages.
465 test_suite "memsubsys1" -description {
466   Tests using pre-allocated page blocks
467 } -files [
468   test_set $::allquicktests -exclude ioerr5.test malloc5.test mmap1.test
469 ] -initialize {
470   test_set_config_pagecache 4096 24
471   catch {db close}
472   sqlite3_shutdown
473   sqlite3_initialize
474   autoinstall_test_functions
475 } -shutdown {
476   test_restore_config_pagecache
477   catch {db close}
478   sqlite3_shutdown
479   sqlite3_initialize
480   autoinstall_test_functions
483 # Run some tests using pre-allocated page blocks. This time
484 # the allocations are too small to use in most cases.
486 # Both ioerr5.test and malloc5.test are excluded because they test the
487 # sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
488 # This functionality is disabled if a pre-allocated page block is provided.
490 test_suite "memsubsys2" -description {
491   Tests using small pre-allocated page blocks
492 } -files [
493   test_set $::allquicktests -exclude ioerr5.test malloc5.test
494 ] -initialize {
495   test_set_config_pagecache 512 5
496   catch {db close}
497   sqlite3_shutdown
498   sqlite3_initialize
499   autoinstall_test_functions
500 } -shutdown {
501   test_restore_config_pagecache
502   catch {db close}
503   sqlite3_shutdown
504   sqlite3_initialize
505   autoinstall_test_functions
508 # Run all tests with the lookaside allocator disabled.
510 test_suite "nolookaside" -description {
511   OOM tests with lookaside disabled
512 } -initialize {
513   catch {db close}
514   sqlite3_shutdown
515   sqlite3_config_lookaside 0 0
516   sqlite3_initialize
517   autoinstall_test_functions
518 } -shutdown {
519   catch {db close}
520   sqlite3_shutdown
521   sqlite3_config_lookaside 100 500
522   sqlite3_initialize
523   autoinstall_test_functions
524 } -files $::allquicktests
526 # Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
528 test_suite "singlethread" -description {
529   Tests run in SQLITE_CONFIG_SINGLETHREAD mode
530 } -initialize {
531   catch {db close}
532   sqlite3_shutdown
533   catch {sqlite3_config singlethread}
534   sqlite3_initialize
535   autoinstall_test_functions
536 } -files {
537   delete.test   delete2.test  insert.test  rollback.test  select1.test
538   select2.test  trans.test    update.test  vacuum.test    types.test
539   types2.test   types3.test
540 } -shutdown {
541   catch {db close}
542   sqlite3_shutdown
543   catch {sqlite3_config serialized}
544   sqlite3_initialize
545   autoinstall_test_functions
548 test_suite "nomutex" -description {
549   Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
550 } -initialize {
551   rename sqlite3 sqlite3_nomutex
552   proc sqlite3 {args} {
553     if {[string range [lindex $args 0] 0 0] ne "-"} {
554       lappend args -fullmutex 0 -nomutex 1
555     }
556     uplevel [concat sqlite3_nomutex $args]
557   }
558 } -files {
559   delete.test   delete2.test  insert.test  rollback.test  select1.test
560   select2.test  trans.test    update.test  vacuum.test    types.test
561   types2.test   types3.test
562 } -shutdown {
563   rename sqlite3 {}
564   rename sqlite3_nomutex sqlite3
567 # Run some tests in SQLITE_CONFIG_MULTITHREAD mode.
569 test_suite "multithread" -description {
570   Tests run in SQLITE_CONFIG_MULTITHREAD mode
571 } -initialize {
572   catch {db close}
573   sqlite3_shutdown
574   catch {sqlite3_config multithread}
575   sqlite3_initialize
576   autoinstall_test_functions
577 } -files {
578   delete.test   delete2.test  insert.test  rollback.test  select1.test
579   select2.test  trans.test    update.test  vacuum.test    types.test
580   types2.test   types3.test   sort4.test
581 } -shutdown {
582   catch {db close}
583   sqlite3_shutdown
584   catch {sqlite3_config serialized}
585   sqlite3_initialize
586   autoinstall_test_functions
589 # Run some tests in SQLITE_OPEN_FULLMUTEX mode.
591 test_suite "fullmutex" -description {
592   Tests run in SQLITE_OPEN_FULLMUTEX mode
593 } -initialize {
594   rename sqlite3 sqlite3_fullmutex
595   proc sqlite3 {args} {
596     if {[string range [lindex $args 0] 0 0] ne "-"} {
597       lappend args -nomutex 0 -fullmutex 1
598     }
599     uplevel [concat sqlite3_fullmutex $args]
600   }
601 } -files {
602   delete.test   delete2.test  insert.test  rollback.test  select1.test
603   select2.test  trans.test    update.test  vacuum.test    types.test
604   types2.test   types3.test
605 } -shutdown {
606   rename sqlite3 {}
607   rename sqlite3_fullmutex sqlite3
610 # Run some tests using the "onefile" demo.
612 test_suite "onefile" -description {
613   Run some tests using the "test_onefile.c" demo
614 } -initialize {
615   rename sqlite3 sqlite3_onefile
616   proc sqlite3 {args} {
617     if {[string range [lindex $args 0] 0 0] ne "-"} {
618       lappend args -vfs fs
619     }
620     uplevel [concat sqlite3_onefile $args]
621   }
622 } -files {
623   conflict.test  insert.test   insert2.test  insert3.test
624   rollback.test  select1.test  select2.test  select3.test
625 } -shutdown {
626   rename sqlite3 {}
627   rename sqlite3_onefile sqlite3
630 # Run some tests using UTF-16 databases.
632 test_suite "utf16" -description {
633   Run tests using UTF-16 databases
634 } -presql {
635   pragma encoding = 'UTF-16'
636 } -files {
637     alter.test alter3.test
638     analyze.test analyze3.test analyze4.test analyze5.test analyze6.test
639     analyze7.test analyze8.test analyze9.test analyzeA.test analyzeB.test
640     auth.test bind.test blob.test capi2.test capi3.test collate1.test
641     collate2.test collate3.test collate4.test collate5.test collate6.test
642     conflict.test date.test delete.test expr.test fkey1.test func.test
643     hook.test index.test insert2.test insert.test interrupt.test in.test
644     intpkey.test ioerr.test join2.test join.test lastinsert.test
645     laststmtchanges.test limit.test lock2.test lock.test main.test 
646     memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test
647     null.test progress.test quote.test rowid.test select1.test select2.test
648     select3.test select4.test select5.test select6.test sort.test 
649     subselect.test tableapi.test table.test temptable.test
650     trace.test trigger1.test trigger2.test trigger3.test
651     trigger4.test types2.test types.test unique.test update.test
652     vacuum.test view.test where.test
653     bestindex1.test
656 # Run some tests in exclusive locking mode.
658 test_suite "exclusive" -description {
659   Run tests in exclusive locking mode.
660 } -presql {
661   pragma locking_mode = 'exclusive'
662 } -files {
663   rollback.test select1.test select2.test 
664   malloc.test ioerr.test
667 # Run some tests in exclusive locking mode with truncated journals.
669 test_suite "exclusive-truncate" -description {
670   Run tests in exclusive locking mode and truncate journal mode.
671 } -presql {
672   pragma locking_mode = 'exclusive';
673   pragma journal_mode = TRUNCATE;
674 } -files {
675   delete.test delete2.test insert.test rollback.test select1.test
676   select2.test update.test malloc.test ioerr.test
679 # Run some tests in persistent journal mode.
681 test_suite "persistent_journal" -description {
682   Run tests in persistent-journal mode.
683 } -presql {
684   pragma journal_mode = persist
685 } -files {
686   delete.test delete2.test insert.test rollback.test select1.test
687   select2.test trans.test update.test vacuum.test 
690 # Run some tests in truncating journal mode.
692 test_suite "truncate_journal" -description {
693   Run tests in persistent-journal mode.
694 } -presql {
695   pragma journal_mode = truncate
696 } -files {
697   delete.test delete2.test insert.test rollback.test select1.test
698   select2.test trans.test update.test vacuum.test 
699   malloc.test ioerr.test
702 # Run some error tests in persistent journal mode.
704 test_suite "persistent_journal_error" -description {
705   Run malloc.test and ioerr.test in persistent-journal mode.
706 } -presql {
707   pragma journal_mode = persist
708 } -files {
709   malloc.test ioerr.test
712 # Run some tests in no journal mode.
714 test_suite "no_journal" -description {
715   Run tests in no-journal mode.
716 } -presql {
717   pragma journal_mode = persist
718 } -files {
719   delete.test delete2.test insert.test rollback.test select1.test
720   select2.test trans.test update.test vacuum.test 
723 # Run some error tests in no journal mode.
725 test_suite "no_journal_error" -description {
726   Run malloc.test and ioerr.test in no-journal mode.
727 } -presql {
728   pragma journal_mode = persist
729 } -files {
730   malloc.test ioerr.test
733 # Run some crash-tests in autovacuum mode.
735 test_suite "autovacuum_crash" -description {
736   Run crash.test in autovacuum mode.
737 } -presql {
738   pragma auto_vacuum = 1
739 } -files crash.test
741 # Run some ioerr-tests in autovacuum mode.
743 test_suite "autovacuum_ioerr" -description {
744   Run ioerr.test in autovacuum mode.
745 } -presql {
746   pragma auto_vacuum = 1
747 } -files ioerr.test
749 # Run tests with an in-memory journal.
751 test_suite "inmemory_journal" -description {
752   Run tests with an in-memory journal file.
753 } -presql {
754   pragma journal_mode = 'memory'
755 } -files [test_set $::allquicktests -exclude {
756   # Exclude all tests that simulate IO errors.
757   autovacuum_ioerr2.test cffault.test incrvacuum_ioerr.test ioerr.test
758   ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test
759   vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test
760   e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test
761   fts3snippet.test mmapfault.test sessionfault.test sessionfault2.test
763   # Exclude test scripts that use tcl IO to access journal files or count
764   # the number of fsync() calls.
765   pager.test exclusive.test jrnlmode.test sync.test misc1.test 
766   journal1.test conflict.test crash8.test tkt3457.test io.test
767   journal3.test 8_3_names.test
769   pager1.test async4.test corrupt.test filefmt.test pager2.test
770   corrupt5.test corruptA.test pageropt.test
772   # Exclude stmt.test, which expects sub-journals to use temporary files.
773   stmt.test symlink.test
775   zerodamage.test
777   # WAL mode is different.
778   wal* tkt-2d1a5c67d.test backcompat.test e_wal* rowallock.test
780   # This test does not work as the "PRAGMA journal_mode = memory"
781   # statement switches the database out of wal mode at inopportune
782   # times.
783   snapshot_fault.test
784   
785   # This test assumes a journal file is created on disk.
786   delete_db.test
787   
788   # This test depends on a successful recovery from the pager error 
789   # state. Which is not possible with an in-memory journal
790   fts5fault1.test
793 ifcapable mem3 {
794   test_suite "memsys3" -description {
795     Run tests using the allocator in mem3.c.
796   } -files [test_set $::allquicktests -exclude {
797     autovacuum.test           delete3.test              manydb.test
798     bigrow.test               incrblob2.test            memdb.test
799     bitvec.test               index2.test               memsubsys1.test
800     capi3c.test               ioerr.test                memsubsys2.test
801     capi3.test                join3.test                pagesize.test
802     collate5.test             limit.test                backup_ioerr.test
803     backup_malloc.test
804   }] -initialize {
805     catch {db close}
806     sqlite3_reset_auto_extension
807     sqlite3_shutdown
808     sqlite3_config_heap 25000000 0
809     sqlite3_config_lookaside 0 0
810     ifcapable mem5 {
811       # If both memsys3 and memsys5 are enabled in the build, the call to
812       # [sqlite3_config_heap] will initialize the system to use memsys5.
813       # The following overrides this preference and installs the memsys3
814       # allocator.
815       sqlite3_install_memsys3
816     }
817     install_malloc_faultsim 1 
818     sqlite3_initialize
819     autoinstall_test_functions
820   } -shutdown {
821     catch {db close}
822     sqlite3_shutdown
823     sqlite3_config_heap 0 0
824     sqlite3_config_lookaside 100 500
825     install_malloc_faultsim 1 
826     sqlite3_initialize
827     autoinstall_test_functions
828   }
831 ifcapable mem5 {
832   test_suite "memsys5" -description {
833     Run tests using the allocator in mem5.c.
834   } -files [test_set $::allquicktests -exclude {
835     autovacuum.test           delete3.test              manydb.test
836     bigrow.test               incrblob2.test            memdb.test
837     bitvec.test               index2.test               memsubsys1.test
838     capi3c.test               ioerr.test                memsubsys2.test
839     capi3.test                join3.test                pagesize.test
840     collate5.test             limit.test                zeroblob.test
841   }] -initialize {
842     catch {db close}
843     sqlite3_shutdown
844     sqlite3_config_heap 25000000 64
845     sqlite3_config_lookaside 0 0
846     install_malloc_faultsim 1 
847     sqlite3_initialize
848     autoinstall_test_functions
849   } -shutdown {
850     catch {db close}
851     sqlite3_shutdown
852     sqlite3_config_heap 0 0
853     sqlite3_config_lookaside 100 500
854     install_malloc_faultsim 1 
855     sqlite3_initialize
856     autoinstall_test_functions
857   }
859   test_suite "memsys5-2" -description {
860     Run tests using the allocator in mem5.c in a different configuration.
861   } -files {
862     select1.test 
863   } -initialize {
864     catch {db close}
865     sqlite3_shutdown
866     sqlite3_config_memstatus 0
867     sqlite3_config_heap 40000000 16
868     sqlite3_config_lookaside 0 0
869     install_malloc_faultsim 1 
870     sqlite3_initialize
871     autoinstall_test_functions
872   } -shutdown {
873     catch {db close}
874     sqlite3_shutdown
875     sqlite3_config_heap 0 0
876     sqlite3_config_lookaside 100 500
877     install_malloc_faultsim 1 
878     sqlite3_initialize
879     autoinstall_test_functions
880   }
883 ifcapable threadsafe {
884   test_suite "no_mutex_try" -description {
885      The sqlite3_mutex_try() interface always fails
886   } -files [
887     test_set $::allquicktests -exclude mutex1.test mutex2.test
888   ] -initialize {
889     catch {db close}
890     sqlite3_shutdown
891     install_mutex_counters 1
892     set ::disable_mutex_try 1
893     sqlite3_initialize
894     autoinstall_test_functions
895   } -shutdown {
896     catch {db close}
897     sqlite3_shutdown
898     install_mutex_counters 0
899     sqlite3_initialize
900     autoinstall_test_functions
901   }
904 # run_tests "crash_safe_append" -description {
905 #   Run crash.test with persistent journals on a SAFE_APPEND file-system.
906 # } -initialize {
907 #   rename crashsql sa_crashsql
908 #   proc crashsql {args} {
909 #     set options [lrange $args 0 [expr {[llength $args]-2}]]
910 #     lappend options -char safe_append
911 #     set sql [lindex $args end]
912 #     lappend options "
913 #       PRAGMA journal_mode=persistent;
914 #       $sql
915 #     "
916 #     set fd [open test.db-journal w]
917 #     puts $fd [string repeat 1234567890 100000]
918 #     close $fd
919 #     eval sa_crashsql $options
920 #   }
921 # } -shutdown {
922 #   rename crashsql {}
923 #   rename sa_crashsql crashsql
924 # } -files crash.test
926 test_suite "safe_append" -description {
927   Run some tests on a SAFE_APPEND file-system.
928 } -initialize {
929   rename sqlite3 sqlite3_safeappend
930   proc sqlite3 {args} {
931     if {[string range [lindex $args 0] 0 0] ne "-"} {
932       lappend args -vfs devsym
933     }
934     uplevel [concat sqlite3_safeappend $args]
935   }
936   sqlite3_simulate_device -char safe_append
937 } -shutdown {
938   rename sqlite3 {}
939   rename sqlite3_shutdown sqlite3
940 } -files [
941   test_set $::allquicktests shared_err.test -exclude async3.test
944 # The set of tests to run on the alternative-pcache
945 set perm-alt-pcache-testset {
946   async.test
947   attach.test
948   delete.test delete2.test
949   index.test
950   insert.test insert2.test
951   join.test join2.test
952   rollback.test
953   select1.test select2.test
954   trans.test
955   update.test
958 foreach discard_rate {0 10 50 90 100} {
959   test_suite "pcache${discard_rate}" -description "
960     Alternative pcache implementation with ${discard_rate}% random discard
961   " -initialize "
962     catch {db close}
963     sqlite3_shutdown
964     sqlite3_config_alt_pcache 1 $discard_rate 1
965     sqlite3_initialize
966     autoinstall_test_functions
967   " -shutdown {
968     catch {db close}
969     sqlite3_shutdown
970     sqlite3_config_alt_pcache 0 0 0
971     sqlite3_config_lookaside 100 500
972     install_malloc_faultsim 1 
973     sqlite3_initialize
974     autoinstall_test_functions
975   } -files ${perm-alt-pcache-testset}
978 test_suite "journaltest" -description {
979   Check that pages are synced before being written (test_journal.c).
980 } -initialize {
981   catch {db close}
982   register_jt_vfs -default ""
983 } -shutdown {
984   unregister_jt_vfs
985 } -files [test_set $::allquicktests -exclude {
986   wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test 
987   async4.test bigfile.test backcompat.test e_wal* fstat.test mmap2.test
988   pager1.test syscall.test tkt3457.test *malloc* mmap* multiplex* nolock*
989   pager2.test *fault* rowal* snapshot* superlock* symlink.test
990   delete_db.test
993 if {[info commands register_demovfs] != ""} {
994   test_suite "demovfs" -description {
995     Check that the demovfs (code in test_demovfs.c) more or less works.
996   } -initialize {
997     register_demovfs
998   } -shutdown {
999     unregister_demovfs
1000   } -files {
1001     insert.test   insert2.test  insert3.test rollback.test 
1002     select1.test  select2.test  select3.test
1003   }
1006 test_suite "wal" -description {
1007   Run tests with journal_mode=WAL
1008 } -initialize {
1009   set ::G(savepoint6_iterations) 100
1010 } -shutdown {
1011   unset -nocomplain ::G(savepoint6_iterations)
1012 } -files {
1013   savepoint.test     savepoint2.test     savepoint6.test
1014   trans.test         avtrans.test
1016   fts3aa.test  fts3ab.test  fts3ac.test  fts3ad.test
1017   fts3ae.test  fts3af.test  fts3ag.test  fts3ah.test
1018   fts3ai.test  fts3aj.test  fts3ak.test  fts3al.test
1019   fts3am.test  fts3an.test  fts3ao.test  fts3b.test
1020   fts3c.test   fts3d.test   fts3e.test   fts3query.test 
1023 test_suite "rtree" -description {
1024   All R-tree related tests. Provides coverage of source file rtree.c.
1025 } -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
1027 test_suite "session" -description {
1028   All session module related tests. 
1029 } -files [glob -nocomplain $::testdir/../ext/session/*.test]
1031 test_suite "session_eec" -description {
1032   All session module related tests with sqlite3_extended_result_codes() set. 
1033 } -files [
1034   glob -nocomplain $::testdir/../ext/session/*.test
1035 ] -dbconfig {
1036   sqlite3_extended_result_codes $::dbhandle 1
1039 test_suite "session_strm" -description {
1040   All session module related tests using the streaming APIs.
1041 } -files [
1042   glob -nocomplain $::testdir/../ext/session/*.test
1043 ] -dbconfig {
1044   set ::sqlite3session_streams 1
1047 test_suite "rbu" -description {
1048   RBU tests.
1049 } -files [
1050   test_set [glob -nocomplain $::testdir/../ext/rbu/*.test] -exclude rbu.test
1053 test_suite "no_optimization" -description {
1054   Run test scripts with optimizations disabled using the
1055   sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) interface.
1056 } -files {
1057   where.test where2.test where3.test where4.test where5.test
1058   where6.test where7.test where8.test where9.test
1059   whereA.test whereB.test wherelimit.test
1060   select1.test select2.test select3.test select4.test select5.test
1061   select7.test select8.test selectA.test selectC.test
1062 } -dbconfig {
1063   optimization_control $::dbhandle all 0
1066 test_suite "prepare" -description {
1067   Run tests with the db connection using sqlite3_prepare() instead of _v2().
1068 } -dbconfig {
1069   $::dbhandle version -use-legacy-prepare 1
1070   #$::dbhandle cache size 0
1071 } -files [
1072   test_set $allquicktests -exclude *malloc* *ioerr* *fault* \
1073       stmtvtab1.test index9.test
1076 # End of tests
1077 #############################################################################
1079 # run_tests NAME OPTIONS
1081 # where available options are:  
1083 #       -description TITLE
1084 #       -initialize  SCRIPT
1085 #       -shutdown    SCRIPT
1086 #       -presql      SQL
1087 #       -files       LIST-OF-FILES
1088 #       -prefix      NAME
1090 proc run_tests {name args} {
1091   array set options $args
1093   set ::G(perm:name)         $name
1094   set ::G(perm:prefix)       $options(-prefix)
1095   set ::G(perm:presql)       $options(-presql)
1096   set ::G(isquick)           1
1097   set ::G(perm:dbconfig)     $options(-dbconfig)
1099   foreach file [lsort $options(-files)] {
1100     uplevel $options(-initialize)
1101     if {[file tail $file] == $file} { set file [file join $::testdir $file] }
1102     slave_test_file $file
1103     uplevel $options(-shutdown)
1104   }
1106   unset ::G(perm:name)
1107   unset ::G(perm:prefix)
1108   unset ::G(perm:presql)
1109   unset ::G(perm:dbconfig)
1112 proc run_test_suite {name} {
1113   if {[info exists ::testspec($name)]==0} {
1114     error "No such test suite: $name"
1115   }
1116   uplevel run_tests $name $::testspec($name)
1119 proc help {} {
1120   puts "Usage: $::argv0 TESTSUITE ?TESTFILE?"
1121   puts ""
1122   puts "Available test-suites are:"
1123   foreach k $::testsuitelist {
1124     if {[info exists ::testspec($k)]==0} {
1125       puts "         ----------------------------------------"
1126       puts ""
1127     } else {
1128       array set o $::testspec($k)
1129       puts "Test suite: \"$k\""
1130       set d [string trim $o(-description)]
1131       set d [regsub {\n *} $d "\n  "]
1132       puts "  $d"
1133       puts ""
1134     }
1135   }
1136   exit -1
1139 if {[file tail $argv0] == "permutations.test"} {
1140   proc main {argv} {
1141     if {[llength $argv]==0} {
1142       help
1143     } else {
1144       set suite [file tail [lindex $argv 0]]
1145       if {[info exists ::testspec($suite)]==0} help
1146       set extra ""
1147       if {[llength $argv]>1} { set extra [list -files [lrange $argv 1 end]] }
1148       eval run_tests $suite $::testspec($suite) $extra
1149     }
1150   }
1151   main $argv
1152   finish_test