xref: /sqlite-3.40.0/test/permutations.test (revision 8c53b4e7)
1# 2008 June 21
2#
3# The author disclaims copyright to this source code.  In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11#
12
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15db close
16
17#-------------------------------------------------------------------------
18# test_suite NAME OPTIONS
19#
20# where available options are:
21#
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 "")
29#
30proc test_suite {name args} {
31
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)    ""
39
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  }
50
51  set     ::testspec($name) [array get options]
52  lappend ::testsuitelist $name
53}
54
55#-------------------------------------------------------------------------
56# test_set ARGS...
57#
58proc 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  }
76
77  return [array names t]
78}
79
80#-------------------------------------------------------------------------
81# Set up the following global list variables containing the names of
82# various test scripts:
83#
84#   $alltests
85#   $allquicktests
86#
87set alltests [list]
88foreach f [glob $testdir/*.test] { lappend alltests [file tail $f] }
89foreach 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
96}
97foreach f [glob -nocomplain $testdir/../ext/session/*.test] {
98  lappend alltests $f
99}
100
101if {$::tcl_platform(platform)!="unix"} {
102  set alltests [test_set $alltests -exclude crash.test crash2.test]
103}
104set 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    rbu.test
109}]
110
111set 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 walprotocol.test mmap4.test fuzzer2.test
126  walcrash2.test e_fkey.test backup.test
127
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
131
132  rtree4.test
133}]
134if {[info exists ::env(QUICKTEST_INCLUDE)]} {
135  set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
136}
137if {[info exists ::env(QUICKTEST_OMIT)]} {
138  foreach x [split $::env(QUICKTEST_OMIT) ,] {
139    regsub -all \\y$x\\y $allquicktests {} allquicktests
140  }
141}
142
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.
146#
147if {[info exists ::env(TEST_FAILURE)]} {
148  set allquicktests main.test
149}
150
151#############################################################################
152# Start of tests
153#
154
155#-------------------------------------------------------------------------
156# Define the generic test suites:
157#
158#   veryquick
159#   quick
160#   full
161#
162lappend ::testsuitelist xxx
163
164test_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*
171]
172
173test_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
182]
183
184test_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
190]
191
192test_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)
203}
204
205test_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)
225}
226
227
228test_suite "quick" -prefix "" -description {
229  Quick test suite. Runs in around 10 minutes on a workstation.
230} -files [
231  test_set $allquicktests
232]
233
234test_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)
240}
241
242test_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
247}
248
249test_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  fts3corrupt4.test
259  fts3cov.test fts3c.test fts3defer2.test fts3defer3.test
260  fts3defer.test fts3drop.test fts3d.test fts3e.test
261  fts3expr2.test fts3expr3.test fts3expr4.test fts3expr5.test
262  fts3expr.test fts3fault2.test fts3fault.test fts3first.test
263  fts3join.test fts3malloc.test fts3matchinfo.test fts3near.test
264  fts3offsets.test fts3prefix2.test fts3prefix.test fts3query.test
265  fts3shared.test fts3snippet.test fts3sort.test fts3tok1.test
266  fts3tok_err.test fts3varint.test fts4aa.test fts4check.test
267  fts4content.test fts4docid.test fts4growth2.test fts4growth.test
268  fts4incr.test fts4langid.test fts4lastrowid.test fts4merge2.test
269  fts4merge4.test fts4merge.test fts4noti.test fts4onepass.test
270  fts4opt.test fts4unicode.test
271  fts3corrupt3.test
272  fts3misc.test
273}
274
275test_suite "fts5" -prefix "" -description {
276  All FTS5 tests.
277} -files [glob -nocomplain $::testdir/../ext/fts5/test/*.test]
278
279test_suite "fts5-light" -prefix "" -description {
280  All FTS5 tests.
281} -files [
282  test_set \
283      [glob -nocomplain $::testdir/../ext/fts5/test/*.test] \
284      -exclude *corrupt* *fault* *big* *fts5aj*
285]
286
287test_suite "window" -prefix "" -description {
288  All window function related tests .
289} -files [
290  test_set [glob -nocomplain $::testdir/window*.test]
291]
292
293test_suite "lsm1" -prefix "" -description {
294  All LSM1 tests.
295} -files [glob -nocomplain $::testdir/../ext/lsm1/test/*.test]
296
297test_suite "nofaultsim" -prefix "" -description {
298  "Very" quick test suite. Runs in less than 5 minutes on a workstation.
299  This test suite is the same as the "quick" tests, except that some files
300  that test malloc and IO errors are omitted.
301} -files [
302  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err*
303] -initialize {
304  catch {db close}
305  sqlite3_shutdown
306  install_malloc_faultsim 0
307  sqlite3_initialize
308  autoinstall_test_functions
309} -shutdown {
310  unset -nocomplain ::G(valgrind)
311}
312
313test_suite "queryplanner" -prefix "" -description {
314  Tests of the query planner and query optimizer
315} -files {
316  alter2.test alter3.test alter4.test alter.test analyze3.test
317  analyze4.test analyze5.test analyze6.test analyze7.test analyze8.test
318  analyze.test attach2.test attach3.test attach4.test
319  attach.test autoinc.test autoindex1.test between.test cast.test
320  check.test closure01.test coalesce.test collate1.test collate2.test
321  collate3.test collate4.test collate5.test collate6.test collate7.test
322  collate8.test collate9.test collateA.test colmeta.test colname.test
323  conflict.test count.test coveridxscan.test createtab.test cse.test
324  date.test dbstatus2.test dbstatus.test default.test delete2.test
325  delete3.test delete.test descidx1.test descidx2.test descidx3.test
326  distinctagg.test distinct.test e_createtable.test e_delete.test
327  e_droptrigger.test e_dropview.test e_expr.test e_insert.test
328  eqp.test e_reindex.test e_resolve.test e_select2.test e_select.test
329  e_update.test exists.test expr.test fkey1.test fkey2.test fkey3.test
330  fkey4.test fkey5.test func2.test func3.test func.test
331  in3.test in4.test in5.test index2.test index3.test
332  index4.test index5.test indexedby.test index.test
333  insert2.test insert3.test insert4.test insert5.test insert.test
334  instr.test in.test intpkey.test join2.test join3.test join4.test
335  join5.test join6.test join.test like2.test like.test limit.test
336  minmax2.test minmax3.test minmax4.test minmax.test misc1.test misc2.test
337  misc3.test misc4.test misc5.test misc6.test misc7.test orderby1.test
338  orderby2.test orderby3.test orderby4.test randexpr1.test regexp1.test
339  reindex.test rowhash.test rowid.test schema2.test schema3.test
340  schema4.test schema5.test schema.test
341  select1.test select2.test select3.test select4.test select5.test
342  select6.test select7.test select8.test select9.test selectA.test
343  selectB.test selectC.test selectD.test selectE.test sidedelete.test
344  sort.test spellfix.test subquery2.test subquery.test subselect.test
345  substr.test tkt-02a8e81d44.test tkt1435.test tkt1443.test tkt1444.test
346  tkt1449.test tkt1473.test tkt1501.test tkt1512.test tkt1514.test
347  tkt1536.test tkt1537.test tkt1567.test tkt1644.test tkt1667.test
348  tkt1873.test tkt2141.test tkt2192.test tkt2213.test tkt2251.test
349  tkt2285.test tkt2332.test tkt2339.test tkt2391.test tkt2409.test
350  tkt2450.test tkt2565.test tkt2640.test tkt2643.test tkt2686.test
351  tkt-26ff0c2d1e.test tkt2767.test tkt2817.test tkt2820.test tkt2822.test
352  tkt2832.test tkt2854.test tkt2920.test tkt2927.test tkt2942.test
353  tkt-2a5629202f.test tkt-2d1a5c67d.test tkt-2ea2425d34.test tkt3080.test
354  tkt3093.test tkt3121.test tkt-31338dca7e.test tkt-313723c356.test
355  tkt3201.test tkt3292.test tkt3298.test tkt3334.test tkt3346.test
356  tkt3357.test tkt3419.test tkt3424.test tkt3442.test tkt3457.test
357  tkt3461.test tkt3493.test tkt3508.test tkt3522.test tkt3527.test
358  tkt3541.test tkt3554.test tkt3581.test tkt35xx.test tkt3630.test
359  tkt3718.test tkt3731.test tkt3757.test tkt3761.test tkt3762.test
360  tkt3773.test tkt3791.test tkt3793.test tkt3810.test tkt3824.test
361  tkt3832.test tkt3838.test tkt3841.test tkt-385a5b56b9.test tkt3871.test
362  tkt3879.test tkt-38cb5df375.test tkt3911.test tkt3918.test tkt3922.test
363  tkt3929.test tkt3935.test tkt3992.test tkt3997.test tkt-3998683a16.test
364  tkt-3a77c9714e.test tkt-3fe897352e.test tkt4018.test tkt-4a03edc4c8.test
365  tkt-4dd95f6943.test tkt-54844eea3f.test tkt-5d863f876e.test
366  tkt-5e10420e8d.test tkt-5ee23731f.test tkt-6bfb98dfc0.test
367  tkt-752e1646fc.test tkt-78e04e52ea.test tkt-7a31705a7e6.test
368  tkt-7bbfb7d442.test tkt-80ba201079.test tkt-80e031a00f.test
369  tkt-8454a207b9.test tkt-91e2e8ba6f.test tkt-94c04eaadb.test
370  tkt-9d68c883.test tkt-a7b7803e.test tkt-b1d3a2e531.test
371  tkt-b351d95f9.test tkt-b72787b1.test tkt-bd484a090c.test
372  tkt-bdc6bbbb38.test tkt-c48d99d690.test tkt-cbd054fa6b.test
373  tkt-d11f09d36e.test tkt-d635236375.test tkt-d82e3f3721.test
374  tkt-f3e5abed55.test tkt-f777251dc7a.test tkt-f7b4edec.test
375  tkt-f973c7ac31.test tkt-fa7bf5ec.test tkt-fc62af4523.test
376  tkt-fc7bd6358f.test trigger1.test trigger2.test trigger3.test
377  trigger4.test trigger5.test trigger6.test trigger7.test trigger8.test
378  trigger9.test triggerA.test triggerB.test triggerC.test triggerD.test
379  types2.test types3.test types.test unique.test unordered.test
380  update.test view.test vtab1.test vtab2.test vtab3.test vtab4.test
381  vtab5.test vtab6.test vtab7.test vtab8.test vtab9.test vtab_alter.test
382  vtabA.test vtabB.test vtabC.test vtabD.test vtabE.test
383  vtabF.test where2.test where3.test where4.test where5.test where6.test
384  where7.test where8m.test where8.test where9.test whereA.test whereB.test
385  whereC.test whereD.test whereE.test whereF.test wherelimit.test
386  where.test
387}
388
389test_suite "vfslog" -prefix "" -description {
390  "Vfslog" quick test suite. Like "veryquick" except does not omits
391  a few tests that do not work with a version 1 VFS. And the quota* tests,
392  which do not work with a VFS that uses the pVfs argument passed to
393  sqlite3_vfs methods.
394} -files [
395  test_set $allquicktests -exclude *malloc* *ioerr* *fault* oserror.test \
396  pager1.test syscall.test sysfault.test tkt3457.test quota* superlock* \
397  wal* mmap*
398]
399
400test_suite "atomic-batch-write" -prefix "" -description {
401  Like veryquick.test, but must be run on a file-system that supports
402  atomic-batch-writes. Tests that depend on the journal file being present
403  are omitted.
404} -files [
405  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
406      *fts5corrupt* *fts5big* *fts5aj*  \
407      crash8.test delete_db.test        \
408      exclusive.test journal3.test      \
409      journal1.test                     \
410      jrnlmode.test jrnlmode2.test      \
411      lock4.test pager1.test            \
412      pager3.test sharedA.test          \
413      symlink.test stmt.test            \
414      sync.test sync2.test              \
415      tempdb.test tkt3457.test          \
416      vacuum5.test wal2.test            \
417      walmode.test zerodamage.test
418] -initialize {
419  if {[atomic_batch_write test.db]==0} {
420    error "File system does NOT support atomic-batch-write"
421  }
422}
423
424lappend ::testsuitelist xxx
425#-------------------------------------------------------------------------
426# Define the coverage related test suites:
427#
428#   coverage-wal
429#
430test_suite "coverage-wal" -description {
431  Coverage tests for file wal.c.
432} -files {
433  wal.test       wal2.test     wal3.test       walmode.test
434  walbak.test    walhook.test  walcrash2.test  walcksum.test
435  walfault.test  walbig.test   walnoshm.test
436  wal5.test
437}
438
439test_suite "coverage-pager" -description {
440  Coverage tests for file pager.c.
441} -files {
442  pager1.test    pager2.test  pagerfault.test  pagerfault2.test
443  walfault.test  walbak.test  journal2.test    tkt-9d68c883.test
444}
445
446test_suite "coverage-analyze" -description {
447  Coverage tests for file analyze.c.
448} -files {
449  analyze3.test analyze4.test analyze5.test analyze6.test
450  analyze7.test analyze8.test analyze9.test analyzeA.test
451  analyze.test analyzeB.test mallocA.test
452}
453
454test_suite "coverage-sorter" -description {
455  Coverage tests for file vdbesort.c.
456} -files {
457  sort.test sortfault.test
458}
459
460
461lappend ::testsuitelist xxx
462#-------------------------------------------------------------------------
463# Define the permutation test suites:
464#
465
466# Run some tests using pre-allocated page blocks.
467#
468# mmap1.test is excluded because a good number of its tests depend on
469# the page-cache being larger than the database. But this permutation
470# causes the effective limit on the page-cache to be just 24 pages.
471#
472test_suite "memsubsys1" -description {
473  Tests using pre-allocated page blocks
474} -files [
475  test_set $::allquicktests -exclude ioerr5.test malloc5.test mmap1.test
476] -initialize {
477  test_set_config_pagecache 4096 24
478  catch {db close}
479  sqlite3_shutdown
480  sqlite3_initialize
481  autoinstall_test_functions
482} -shutdown {
483  test_restore_config_pagecache
484  catch {db close}
485  sqlite3_shutdown
486  sqlite3_initialize
487  autoinstall_test_functions
488}
489
490# Run some tests using pre-allocated page blocks. This time
491# the allocations are too small to use in most cases.
492#
493# Both ioerr5.test and malloc5.test are excluded because they test the
494# sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
495# This functionality is disabled if a pre-allocated page block is provided.
496#
497test_suite "memsubsys2" -description {
498  Tests using small pre-allocated page blocks
499} -files [
500  test_set $::allquicktests -exclude ioerr5.test malloc5.test
501] -initialize {
502  test_set_config_pagecache 512 5
503  catch {db close}
504  sqlite3_shutdown
505  sqlite3_initialize
506  autoinstall_test_functions
507} -shutdown {
508  test_restore_config_pagecache
509  catch {db close}
510  sqlite3_shutdown
511  sqlite3_initialize
512  autoinstall_test_functions
513}
514
515# Run all tests with the lookaside allocator disabled.
516#
517test_suite "nolookaside" -description {
518  OOM tests with lookaside disabled
519} -initialize {
520  catch {db close}
521  sqlite3_shutdown
522  sqlite3_config_lookaside 0 0
523  sqlite3_initialize
524  autoinstall_test_functions
525} -shutdown {
526  catch {db close}
527  sqlite3_shutdown
528  sqlite3_config_lookaside 100 500
529  sqlite3_initialize
530  autoinstall_test_functions
531} -files $::allquicktests
532
533# Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
534#
535test_suite "singlethread" -description {
536  Tests run in SQLITE_CONFIG_SINGLETHREAD mode
537} -initialize {
538  catch {db close}
539  sqlite3_shutdown
540  catch {sqlite3_config singlethread}
541  sqlite3_initialize
542  autoinstall_test_functions
543} -files {
544  delete.test   delete2.test  insert.test  rollback.test  select1.test
545  select2.test  trans.test    update.test  vacuum.test    types.test
546  types2.test   types3.test
547} -shutdown {
548  catch {db close}
549  sqlite3_shutdown
550  catch {sqlite3_config serialized}
551  sqlite3_initialize
552  autoinstall_test_functions
553}
554
555test_suite "nomutex" -description {
556  Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
557} -initialize {
558  set ::G(perm:sqlite3_args) [list -fullmutex 0 -nomutex 1]
559} -files {
560  delete.test   delete2.test  insert.test  rollback.test  select1.test
561  select2.test  trans.test    update.test  vacuum.test    types.test
562  types2.test   types3.test
563}
564
565# Run some tests in SQLITE_CONFIG_MULTITHREAD mode.
566#
567test_suite "multithread" -description {
568  Tests run in SQLITE_CONFIG_MULTITHREAD mode
569} -initialize {
570  catch {db close}
571  sqlite3_shutdown
572  catch {sqlite3_config multithread}
573  sqlite3_initialize
574  autoinstall_test_functions
575} -files {
576  delete.test   delete2.test  insert.test  rollback.test  select1.test
577  select2.test  trans.test    update.test  vacuum.test    types.test
578  types2.test   types3.test   sort4.test
579} -shutdown {
580  catch {db close}
581  sqlite3_shutdown
582  catch {sqlite3_config serialized}
583  sqlite3_initialize
584  autoinstall_test_functions
585}
586
587# Run some tests in SQLITE_OPEN_FULLMUTEX mode.
588#
589test_suite "fullmutex" -description {
590  Tests run in SQLITE_OPEN_FULLMUTEX mode
591} -initialize {
592  set ::G(perm:sqlite3_args) [list -nomutex 0 -fullmutex 1]
593} -files {
594  delete.test   delete2.test  insert.test  rollback.test  select1.test
595  select2.test  trans.test    update.test  vacuum.test    types.test
596  types2.test   types3.test
597}
598
599# Run some tests using the "onefile" demo.
600#
601test_suite "onefile" -description {
602  Run some tests using the "test_onefile.c" demo
603} -initialize {
604  set ::G(perm:sqlite3_args) [list -vfs fs]
605} -files {
606  conflict.test  insert.test   insert2.test  insert3.test
607  rollback.test  select1.test  select2.test  select3.test
608}
609
610# Run some tests using UTF-16 databases.
611#
612test_suite "utf16" -description {
613  Run tests using UTF-16 databases
614} -presql {
615  pragma encoding = 'UTF-16'
616} -files {
617    alter.test alter3.test
618    analyze.test analyze3.test analyze4.test analyze5.test analyze6.test
619    analyze7.test analyze8.test analyze9.test analyzeA.test analyzeB.test
620    auth.test bind.test blob.test capi2.test capi3.test collate1.test
621    collate2.test collate3.test collate4.test collate5.test collate6.test
622    conflict.test date.test delete.test expr.test fkey1.test func.test
623    hook.test index.test insert2.test insert.test interrupt.test in.test
624    intpkey.test ioerr.test join2.test join.test lastinsert.test
625    laststmtchanges.test limit.test lock2.test lock.test main.test
626    memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test
627    null.test progress.test quote.test rowid.test select1.test select2.test
628    select3.test select4.test select5.test select6.test sort.test
629    subselect.test tableapi.test table.test temptable.test
630    trace.test trigger1.test trigger2.test trigger3.test
631    trigger4.test types2.test types.test unique.test update.test
632    vacuum.test view.test where.test
633    bestindex1.test
634}
635
636# Run some tests in exclusive locking mode.
637#
638test_suite "exclusive" -description {
639  Run tests in exclusive locking mode.
640} -presql {
641  pragma locking_mode = 'exclusive'
642} -files {
643  rollback.test select1.test select2.test
644  malloc.test ioerr.test
645}
646
647# Run some tests in exclusive locking mode with truncated journals.
648#
649test_suite "exclusive-truncate" -description {
650  Run tests in exclusive locking mode and truncate journal mode.
651} -presql {
652  pragma locking_mode = 'exclusive';
653  pragma journal_mode = TRUNCATE;
654} -files {
655  delete.test delete2.test insert.test rollback.test select1.test
656  select2.test update.test malloc.test ioerr.test
657}
658
659# Run some tests in persistent journal mode.
660#
661test_suite "persistent_journal" -description {
662  Run tests in persistent-journal mode.
663} -presql {
664  pragma journal_mode = persist
665} -files {
666  delete.test delete2.test insert.test rollback.test select1.test
667  select2.test trans.test update.test vacuum.test
668}
669
670# Run some tests in truncating journal mode.
671#
672test_suite "truncate_journal" -description {
673  Run tests in persistent-journal mode.
674} -presql {
675  pragma journal_mode = truncate
676} -files {
677  delete.test delete2.test insert.test rollback.test select1.test
678  select2.test trans.test update.test vacuum.test
679  malloc.test ioerr.test
680}
681
682# Run some error tests in persistent journal mode.
683#
684test_suite "persistent_journal_error" -description {
685  Run malloc.test and ioerr.test in persistent-journal mode.
686} -presql {
687  pragma journal_mode = persist
688} -files {
689  malloc.test ioerr.test
690}
691
692# Run some tests in no journal mode.
693#
694test_suite "no_journal" -description {
695  Run tests in no-journal mode.
696} -presql {
697  pragma journal_mode = persist
698} -files {
699  delete.test delete2.test insert.test rollback.test select1.test
700  select2.test trans.test update.test vacuum.test
701}
702
703# Run some error tests in no journal mode.
704#
705test_suite "no_journal_error" -description {
706  Run malloc.test and ioerr.test in no-journal mode.
707} -presql {
708  pragma journal_mode = persist
709} -files {
710  malloc.test ioerr.test
711}
712
713# Run some crash-tests in autovacuum mode.
714#
715test_suite "autovacuum_crash" -description {
716  Run crash.test in autovacuum mode.
717} -presql {
718  pragma auto_vacuum = 1
719} -files crash.test
720
721# Run some ioerr-tests in autovacuum mode.
722#
723test_suite "autovacuum_ioerr" -description {
724  Run ioerr.test in autovacuum mode.
725} -presql {
726  pragma auto_vacuum = 1
727} -files ioerr.test
728
729# Run tests with an in-memory journal.
730#
731test_suite "inmemory_journal" -description {
732  Run tests with an in-memory journal file.
733} -presql {
734  pragma journal_mode = 'memory'
735} -files [test_set $::allquicktests -exclude {
736  # Exclude all tests that simulate IO errors.
737  autovacuum_ioerr2.test cffault.test incrvacuum_ioerr.test ioerr.test
738  ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test
739  vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test
740  e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test
741  fts3snippet.test mmapfault.test sessionfault.test sessionfault2.test
742
743  # Exclude test scripts that use tcl IO to access journal files or count
744  # the number of fsync() calls.
745  pager.test exclusive.test jrnlmode.test sync.test misc1.test
746  journal1.test conflict.test crash8.test tkt3457.test io.test
747  journal3.test 8_3_names.test
748
749  pager1.test async4.test corrupt.test filefmt.test pager2.test
750  corrupt5.test corruptA.test pageropt.test
751
752  # Exclude stmt.test, which expects sub-journals to use temporary files.
753  stmt.test symlink.test
754
755  zerodamage.test
756
757  # WAL mode is different.
758  wal* tkt-2d1a5c67d.test backcompat.test e_wal* rowallock.test
759
760  # This test does not work as the "PRAGMA journal_mode = memory"
761  # statement switches the database out of wal mode at inopportune
762  # times.
763  snapshot_fault.test
764
765  # This test assumes a journal file is created on disk.
766  delete_db.test
767
768  # This test depends on a successful recovery from the pager error
769  # state. Which is not possible with an in-memory journal
770  fts5fault1.test
771}]
772
773ifcapable mem3 {
774  test_suite "memsys3" -description {
775    Run tests using the allocator in mem3.c.
776  } -files [test_set $::allquicktests -exclude {
777    autovacuum.test           delete3.test              manydb.test
778    bigrow.test               incrblob2.test            memdb.test
779    bitvec.test               index2.test               memsubsys1.test
780    capi3c.test               ioerr.test                memsubsys2.test
781    capi3.test                join3.test                pagesize.test
782    collate5.test             limit.test                backup_ioerr.test
783    backup_malloc.test
784  }] -initialize {
785    catch {db close}
786    sqlite3_reset_auto_extension
787    sqlite3_shutdown
788    sqlite3_config_heap 25000000 0
789    sqlite3_config_lookaside 0 0
790    ifcapable mem5 {
791      # If both memsys3 and memsys5 are enabled in the build, the call to
792      # [sqlite3_config_heap] will initialize the system to use memsys5.
793      # The following overrides this preference and installs the memsys3
794      # allocator.
795      sqlite3_install_memsys3
796    }
797    install_malloc_faultsim 1
798    sqlite3_initialize
799    autoinstall_test_functions
800  } -shutdown {
801    catch {db close}
802    sqlite3_shutdown
803    sqlite3_config_heap 0 0
804    sqlite3_config_lookaside 100 500
805    install_malloc_faultsim 1
806    sqlite3_initialize
807    autoinstall_test_functions
808  }
809}
810
811ifcapable mem5 {
812  test_suite "memsys5" -description {
813    Run tests using the allocator in mem5.c.
814  } -files [test_set $::allquicktests -exclude {
815    autovacuum.test           delete3.test              manydb.test
816    bigrow.test               incrblob2.test            memdb.test
817    bitvec.test               index2.test               memsubsys1.test
818    capi3c.test               ioerr.test                memsubsys2.test
819    capi3.test                join3.test                pagesize.test
820    collate5.test             limit.test                zeroblob.test
821  }] -initialize {
822    catch {db close}
823    sqlite3_shutdown
824    sqlite3_config_heap 25000000 64
825    sqlite3_config_lookaside 0 0
826    install_malloc_faultsim 1
827    sqlite3_initialize
828    autoinstall_test_functions
829  } -shutdown {
830    catch {db close}
831    sqlite3_shutdown
832    sqlite3_config_heap 0 0
833    sqlite3_config_lookaside 100 500
834    install_malloc_faultsim 1
835    sqlite3_initialize
836    autoinstall_test_functions
837  }
838
839  test_suite "memsys5-2" -description {
840    Run tests using the allocator in mem5.c in a different configuration.
841  } -files {
842    select1.test
843  } -initialize {
844    catch {db close}
845    sqlite3_shutdown
846    sqlite3_config_memstatus 0
847    sqlite3_config_heap 40000000 16
848    sqlite3_config_lookaside 0 0
849    install_malloc_faultsim 1
850    sqlite3_initialize
851    autoinstall_test_functions
852  } -shutdown {
853    catch {db close}
854    sqlite3_shutdown
855    sqlite3_config_heap 0 0
856    sqlite3_config_lookaside 100 500
857    install_malloc_faultsim 1
858    sqlite3_initialize
859    autoinstall_test_functions
860  }
861}
862
863ifcapable threadsafe {
864  test_suite "no_mutex_try" -description {
865     The sqlite3_mutex_try() interface always fails
866  } -files [
867    test_set $::allquicktests -exclude mutex1.test mutex2.test
868  ] -initialize {
869    catch {db close}
870    sqlite3_shutdown
871    install_mutex_counters 1
872    set ::disable_mutex_try 1
873    sqlite3_initialize
874    autoinstall_test_functions
875  } -shutdown {
876    catch {db close}
877    sqlite3_shutdown
878    install_mutex_counters 0
879    sqlite3_initialize
880    autoinstall_test_functions
881  }
882}
883
884# run_tests "crash_safe_append" -description {
885#   Run crash.test with persistent journals on a SAFE_APPEND file-system.
886# } -initialize {
887#   rename crashsql sa_crashsql
888#   proc crashsql {args} {
889#     set options [lrange $args 0 [expr {[llength $args]-2}]]
890#     lappend options -char safe_append
891#     set sql [lindex $args end]
892#     lappend options "
893#       PRAGMA journal_mode=persistent;
894#       $sql
895#     "
896#     set fd [open test.db-journal w]
897#     puts $fd [string repeat 1234567890 100000]
898#     close $fd
899#     eval sa_crashsql $options
900#   }
901# } -shutdown {
902#   rename crashsql {}
903#   rename sa_crashsql crashsql
904# } -files crash.test
905
906test_suite "safe_append" -description {
907  Run some tests on a SAFE_APPEND file-system.
908} -initialize {
909  set ::G(perm:sqlite3_args) [list -vfs devsym]
910  sqlite3_simulate_device -char safe_append
911} -files [
912  test_set $::allquicktests shared_err.test -exclude async3.test
913]
914
915# The set of tests to run on the alternative-pcache
916set perm-alt-pcache-testset {
917  async.test
918  attach.test
919  delete.test delete2.test
920  index.test
921  insert.test insert2.test
922  join.test join2.test
923  rollback.test
924  select1.test select2.test
925  trans.test
926  update.test
927}
928
929foreach discard_rate {0 10 50 90 100} {
930  test_suite "pcache${discard_rate}" -description "
931    Alternative pcache implementation with ${discard_rate}% random discard
932  " -initialize "
933    catch {db close}
934    sqlite3_shutdown
935    sqlite3_config_alt_pcache 1 $discard_rate 1
936    sqlite3_initialize
937    autoinstall_test_functions
938  " -shutdown {
939    catch {db close}
940    sqlite3_shutdown
941    sqlite3_config_alt_pcache 0 0 0
942    sqlite3_config_lookaside 100 500
943    install_malloc_faultsim 1
944    sqlite3_initialize
945    autoinstall_test_functions
946  } -files ${perm-alt-pcache-testset}
947}
948
949test_suite "journaltest" -description {
950  Check that pages are synced before being written (test_journal.c).
951} -initialize {
952  catch {db close}
953  register_jt_vfs -default ""
954} -shutdown {
955  unregister_jt_vfs
956} -files [test_set $::allquicktests -exclude {
957  wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test
958  async4.test bigfile.test backcompat.test e_wal* fstat.test mmap2.test
959  pager1.test syscall.test tkt3457.test *malloc* mmap* multiplex* nolock*
960  pager2.test *fault* rowal* snapshot* superlock* symlink.test
961  delete_db.test
962}]
963
964if {[info commands register_demovfs] != ""} {
965  test_suite "demovfs" -description {
966    Check that the demovfs (code in test_demovfs.c) more or less works.
967  } -initialize {
968    register_demovfs
969  } -shutdown {
970    unregister_demovfs
971  } -files {
972    insert.test   insert2.test  insert3.test rollback.test
973    select1.test  select2.test  select3.test
974  }
975}
976
977test_suite "wal" -description {
978  Run tests with journal_mode=WAL
979} -initialize {
980  set ::G(savepoint6_iterations) 100
981} -shutdown {
982  unset -nocomplain ::G(savepoint6_iterations)
983} -files {
984  savepoint.test     savepoint2.test     savepoint6.test
985  trans.test         avtrans.test
986
987  fts3aa.test  fts3ab.test  fts3ac.test  fts3ad.test
988  fts3ae.test  fts3af.test  fts3ag.test  fts3ah.test
989  fts3ai.test  fts3aj.test  fts3ak.test  fts3al.test
990  fts3am.test  fts3an.test  fts3ao.test  fts3b.test
991  fts3c.test   fts3d.test   fts3e.test   fts3query.test
992}
993
994test_suite "rtree" -description {
995  All R-tree related tests. Provides coverage of source file rtree.c.
996} -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
997
998test_suite "session" -description {
999  All session module related tests.
1000} -files [glob -nocomplain $::testdir/../ext/session/*.test]
1001
1002test_suite "session_eec" -description {
1003  All session module related tests with sqlite3_extended_result_codes() set.
1004} -files [
1005  glob -nocomplain $::testdir/../ext/session/*.test
1006] -dbconfig {
1007  sqlite3_extended_result_codes $::dbhandle 1
1008}
1009
1010test_suite "session_strm" -description {
1011  All session module related tests using the streaming APIs.
1012} -files [
1013  glob -nocomplain $::testdir/../ext/session/*.test
1014] -dbconfig {
1015  set ::sqlite3session_streams 1
1016}
1017
1018test_suite "rbu" -description {
1019  RBU tests.
1020} -files [
1021  test_set [glob -nocomplain $::testdir/../ext/rbu/*.test] -exclude rbu.test
1022]
1023
1024test_suite "no_optimization" -description {
1025  Run test scripts with optimizations disabled using the
1026  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) interface.
1027} -files {
1028  where.test where2.test where3.test where4.test where5.test
1029  where6.test where7.test where8.test where9.test
1030  whereA.test whereB.test wherelimit.test
1031  select1.test select2.test select3.test select4.test select5.test
1032  select7.test select8.test selectA.test selectC.test
1033} -dbconfig {
1034  optimization_control $::dbhandle all 0
1035}
1036
1037test_suite "prepare" -description {
1038  Run tests with the db connection using sqlite3_prepare() instead of _v2().
1039} -dbconfig {
1040  $::dbhandle version -use-legacy-prepare 1
1041  #$::dbhandle cache size 0
1042} -files [
1043  test_set $allquicktests -exclude *malloc* *ioerr* *fault* \
1044      stmtvtab1.test index9.test
1045]
1046
1047test_suite "sorterref" -prefix "" -description {
1048  Run the "veryquick" test suite with SQLITE_CONFIG_SORTERREF_SIZE set
1049  to 0 so that sorter-references are used whenever possible.
1050} -files [
1051  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
1052      *fts5corrupt* *fts5big* *fts5aj*
1053] -initialize {
1054  catch {db close}
1055  sqlite3_shutdown
1056  sqlite3_config_sorterref 0
1057  sqlite3_initialize
1058  autoinstall_test_functions
1059} -shutdown {
1060  catch {db close}
1061  sqlite3_shutdown
1062  sqlite3_config_sorterref -1
1063  sqlite3_initialize
1064  autoinstall_test_functions
1065}
1066
1067# End of tests
1068#############################################################################
1069
1070# run_tests NAME OPTIONS
1071#
1072# where available options are:
1073#
1074#       -description TITLE
1075#       -initialize  SCRIPT
1076#       -shutdown    SCRIPT
1077#       -files       LIST-OF-FILES
1078#       -prefix      NAME
1079#       -dbconfig    SCRIPT
1080#
1081proc run_tests {name args} {
1082  set options(-initialize) ""
1083  set options(-shutdown) ""
1084  set options(-prefix) ""
1085  set options(-dbconfig) ""
1086  set options(-presql) ""
1087
1088  array set options $args
1089
1090  set ::G(perm:name)         $name
1091  set ::G(perm:prefix)       $options(-prefix)
1092  set ::G(isquick)           1
1093  set ::G(perm:dbconfig)     $options(-dbconfig)
1094  set ::G(perm:presql)       $options(-presql)
1095
1096  foreach file [lsort $options(-files)] {
1097    uplevel $options(-initialize)
1098    if {[file tail $file] == $file} { set file [file join $::testdir $file] }
1099    slave_test_file $file
1100    uplevel $options(-shutdown)
1101
1102    unset -nocomplain ::G(perm:sqlite3_args)
1103  }
1104
1105  unset ::G(perm:name)
1106  unset ::G(perm:prefix)
1107  unset ::G(perm:dbconfig)
1108  unset ::G(perm:presql)
1109}
1110
1111proc run_test_suite {name} {
1112  if {[info exists ::testspec($name)]==0} {
1113    error "No such test suite: $name"
1114  }
1115  uplevel run_tests $name $::testspec($name)
1116}
1117
1118proc help {} {
1119  puts "Usage: $::argv0 TESTSUITE ?TESTFILE?"
1120  puts ""
1121  puts "Available test-suites are:"
1122
1123  set iPos 0
1124  foreach k $::testsuitelist {
1125    if {[info exists ::testspec($k)]} {
1126      switch $iPos {
1127        0 {
1128          puts ""
1129          puts -nonewline "  [format %-30s $k]"
1130        }
1131
1132        1 {
1133          puts -nonewline [format %-30s $k]
1134        }
1135
1136        2 {
1137          puts -nonewline $k
1138        }
1139      }
1140
1141      set iPos [expr (($iPos+1) % 3)]
1142    }
1143  }
1144  puts ""
1145  exit -1
1146}
1147
1148if {[file tail $argv0] == "permutations.test"} {
1149  proc main {argv} {
1150    if {[llength $argv]==0} {
1151      help
1152    } else {
1153
1154      # See if the first argument is a named test-suite.
1155      #
1156      set suite [file tail [lindex $argv 0]]
1157      if {[info exists ::testspec($suite)]} {
1158        set S $::testspec($suite)
1159        set i 1
1160      } else {
1161        set S [list]
1162        set i 0
1163      }
1164
1165      set extra ""
1166      if {$i < [llength $argv] && [string range [lindex $argv $i] 0 0]!="-" } {
1167        set files [list]
1168        for {} {$i < [llength $argv]} {incr i} {
1169          set pattern [string map {% *} [lindex $argv $i]]
1170          if {[string range $pattern 0 0]=="-"} break
1171          foreach f $::alltests {
1172            set tail [file tail $f]
1173            if {[lsearch $files $f]<0 && [string match $pattern $tail]} {
1174              lappend files $f
1175            }
1176          }
1177        }
1178        set extra [list -files $files]
1179      }
1180
1181      eval run_tests $suite $S $extra
1182    }
1183  }
1184  main $argv
1185  finish_test
1186}
1187