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