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