xref: /sqlite-3.40.0/test/permutations.test (revision d5578433)
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 $testdir/../ext/rtree/*.test] {
90  lappend alltests $f
91}
92
93if {$::tcl_platform(platform)!="unix"} {
94  set alltests [test_set $alltests -exclude crash.test crash2.test]
95}
96set alltests [test_set $alltests -exclude {
97  all.test        async.test         quick.test  veryquick.test
98  memleak.test    permutations.test  soak.test   fts3.test
99  mallocAll.test  rtree.test
100}]
101
102set allquicktests [test_set $alltests -exclude {
103  async2.test async3.test backup_ioerr.test corrupt.test
104  corruptC.test crash.test crash2.test crash3.test crash4.test crash5.test
105  crash6.test crash7.test delete3.test e_fts3.test fts3rnd.test
106  fkey_malloc.test fuzz.test fuzz3.test fuzz_malloc.test in2.test loadext.test
107  misc7.test mutex2.test notify2.test onefile.test pagerfault2.test
108  savepoint4.test savepoint6.test select9.test
109  speed1.test speed1p.test speed2.test speed3.test speed4.test
110  speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
111  thread003.test thread004.test thread005.test trans2.test vacuum3.test
112  incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
113  vtab_err.test walslow.test walcrash.test walcrash3.test
114  walthread.test rtree3.test indexfault.test securedel2.test
115}]
116if {[info exists ::env(QUICKTEST_INCLUDE)]} {
117  set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
118}
119
120#############################################################################
121# Start of tests
122#
123
124#-------------------------------------------------------------------------
125# Define the generic test suites:
126#
127#   veryquick
128#   quick
129#   full
130#
131lappend ::testsuitelist xxx
132
133test_suite "veryquick" -prefix "" -description {
134  "Very" quick test suite. Runs in less than 5 minutes on a workstation.
135  This test suite is the same as the "quick" tests, except that some files
136  that test malloc and IO errors are omitted.
137} -files [
138  test_set $allquicktests -exclude *malloc* *ioerr* *fault*
139]
140
141test_suite "valgrind" -prefix "" -description {
142  Run the "veryquick" test suite with a couple of multi-process tests (that
143  fail under valgrind) omitted.
144} -files [
145  test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test
146] -initialize {
147  set ::G(valgrind) 1
148} -shutdown {
149  unset -nocomplain ::G(valgrind)
150}
151
152test_suite "quick" -prefix "" -description {
153  Quick test suite. Runs in around 10 minutes on a workstation.
154} -files [
155  test_set $allquicktests
156]
157
158test_suite "full" -prefix "" -description {
159  Full test suite. Takes a long time.
160} -files [
161  test_set $alltests
162] -initialize {
163  unset -nocomplain ::G(isquick)
164}
165
166test_suite "threads" -prefix "" -description {
167  All multi-threaded tests.
168} -files {
169  notify2.test   thread001.test thread002.test thread003.test
170  thread004.test thread005.test walthread.test
171}
172
173test_suite "fts3" -prefix "" -description {
174  All FTS3 tests except fts3rnd.test.
175} -files {
176  fts3aa.test fts3ab.test fts3ac.test fts3ad.test fts3ae.test
177  fts3af.test fts3ag.test fts3ah.test fts3ai.test fts3aj.test
178  fts3ak.test fts3al.test fts3am.test fts3an.test fts3ao.test
179  fts3atoken.test fts3b.test fts3c.test fts3cov.test fts3d.test
180  fts3defer.test fts3defer2.test fts3e.test fts3expr.test fts3expr2.test
181  fts3near.test fts3query.test fts3shared.test fts3snippet.test
182  fts3sort.test
183  fts3fault.test fts3malloc.test fts3matchinfo.test
184  fts3aux1.test fts3comp1.test fts3auto.test
185  fts4aa.test fts4content.test
186  fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test
187  fts3corrupt2.test fts3first.test fts4langid.test fts4merge.test
188  fts4check.test fts4unicode.test
189}
190
191test_suite "nofaultsim" -prefix "" -description {
192  "Very" quick test suite. Runs in less than 5 minutes on a workstation.
193  This test suite is the same as the "quick" tests, except that some files
194  that test malloc and IO errors are omitted.
195} -files [
196  test_set $allquicktests -exclude *malloc* *ioerr* *fault*
197] -initialize {
198  catch {db close}
199  sqlite3_shutdown
200  install_malloc_faultsim 0
201  sqlite3_initialize
202  autoinstall_test_functions
203} -shutdown {
204  unset -nocomplain ::G(valgrind)
205}
206
207lappend ::testsuitelist xxx
208#-------------------------------------------------------------------------
209# Define the coverage related test suites:
210#
211#   coverage-wal
212#
213test_suite "coverage-wal" -description {
214  Coverage tests for file wal.c.
215} -files {
216  wal.test       wal2.test     wal3.test       walmode.test
217  walbak.test    walhook.test  walcrash2.test  walcksum.test
218  walfault.test  walbig.test   walnoshm.test
219  wal5.test
220}
221
222test_suite "coverage-pager" -description {
223  Coverage tests for file pager.c.
224} -files {
225  pager1.test    pager2.test  pagerfault.test  pagerfault2.test
226  walfault.test  walbak.test  journal2.test    tkt-9d68c883.test
227}
228
229
230lappend ::testsuitelist xxx
231#-------------------------------------------------------------------------
232# Define the permutation test suites:
233#
234
235# Run some tests using pre-allocated page and scratch blocks.
236#
237test_suite "memsubsys1" -description {
238  Tests using pre-allocated page and scratch blocks
239} -files [
240  test_set $::allquicktests -exclude ioerr5.test malloc5.test
241] -initialize {
242  catch {db close}
243  sqlite3_shutdown
244  sqlite3_config_pagecache 4096 24
245  sqlite3_config_scratch 25000 1
246  sqlite3_initialize
247  autoinstall_test_functions
248} -shutdown {
249  catch {db close}
250  sqlite3_shutdown
251  sqlite3_config_pagecache 0 0
252  sqlite3_config_scratch 0 0
253  sqlite3_initialize
254  autoinstall_test_functions
255}
256
257# Run some tests using pre-allocated page and scratch blocks. This time
258# the allocations are too small to use in most cases.
259#
260# Both ioerr5.test and malloc5.test are excluded because they test the
261# sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
262# This functionality is disabled if a pre-allocated page block is provided.
263#
264test_suite "memsubsys2" -description {
265  Tests using small pre-allocated page and scratch blocks
266} -files [
267  test_set $::allquicktests -exclude ioerr5.test malloc5.test
268] -initialize {
269  catch {db close}
270  sqlite3_shutdown
271  sqlite3_config_pagecache 512 5
272  sqlite3_config_scratch 1000 1
273  sqlite3_initialize
274  autoinstall_test_functions
275} -shutdown {
276  catch {db close}
277  sqlite3_shutdown
278  sqlite3_config_pagecache 0 0
279  sqlite3_config_scratch 0 0
280  sqlite3_initialize
281  autoinstall_test_functions
282}
283
284# Run all tests with the lookaside allocator disabled.
285#
286test_suite "nolookaside" -description {
287  OOM tests with lookaside disabled
288} -initialize {
289  catch {db close}
290  sqlite3_shutdown
291  sqlite3_config_lookaside 0 0
292  sqlite3_initialize
293  autoinstall_test_functions
294} -shutdown {
295  catch {db close}
296  sqlite3_shutdown
297  sqlite3_config_lookaside 100 500
298  sqlite3_initialize
299  autoinstall_test_functions
300} -files $::allquicktests
301
302# Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
303#
304test_suite "singlethread" -description {
305  Tests run in SQLITE_CONFIG_SINGLETHREAD mode
306} -initialize {
307  catch {db close}
308  sqlite3_shutdown
309  catch {sqlite3_config singlethread}
310  sqlite3_initialize
311  autoinstall_test_functions
312} -files {
313  delete.test   delete2.test  insert.test  rollback.test  select1.test
314  select2.test  trans.test    update.test  vacuum.test    types.test
315  types2.test   types3.test
316} -shutdown {
317  catch {db close}
318  sqlite3_shutdown
319  catch {sqlite3_config serialized}
320  sqlite3_initialize
321  autoinstall_test_functions
322}
323
324test_suite "nomutex" -description {
325  Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
326} -initialize {
327  rename sqlite3 sqlite3_nomutex
328  proc sqlite3 {args} {
329    if {[string range [lindex $args 0] 0 0] ne "-"} {
330      lappend args -fullmutex 0 -nomutex 1
331    }
332    uplevel [concat sqlite3_nomutex $args]
333  }
334} -files {
335  delete.test   delete2.test  insert.test  rollback.test  select1.test
336  select2.test  trans.test    update.test  vacuum.test    types.test
337  types2.test   types3.test
338} -shutdown {
339  rename sqlite3 {}
340  rename sqlite3_nomutex sqlite3
341}
342
343# Run some tests in SQLITE_CONFIG_MULTITHREAD mode.
344#
345test_suite "multithread" -description {
346  Tests run in SQLITE_CONFIG_MULTITHREAD mode
347} -initialize {
348  catch {db close}
349  sqlite3_shutdown
350  catch {sqlite3_config multithread}
351  sqlite3_initialize
352  autoinstall_test_functions
353} -files {
354  delete.test   delete2.test  insert.test  rollback.test  select1.test
355  select2.test  trans.test    update.test  vacuum.test    types.test
356  types2.test   types3.test
357} -shutdown {
358  catch {db close}
359  sqlite3_shutdown
360  catch {sqlite3_config serialized}
361  sqlite3_initialize
362  autoinstall_test_functions
363}
364
365# Run some tests in SQLITE_OPEN_FULLMUTEX mode.
366#
367test_suite "fullmutex" -description {
368  Tests run in SQLITE_OPEN_FULLMUTEX mode
369} -initialize {
370  rename sqlite3 sqlite3_fullmutex
371  proc sqlite3 {args} {
372    if {[string range [lindex $args 0] 0 0] ne "-"} {
373      lappend args -nomutex 0 -fullmutex 1
374    }
375    uplevel [concat sqlite3_fullmutex $args]
376  }
377} -files {
378  delete.test   delete2.test  insert.test  rollback.test  select1.test
379  select2.test  trans.test    update.test  vacuum.test    types.test
380  types2.test   types3.test
381} -shutdown {
382  rename sqlite3 {}
383  rename sqlite3_fullmutex sqlite3
384}
385
386# Run some tests using the "onefile" demo.
387#
388test_suite "onefile" -description {
389  Run some tests using the "test_onefile.c" demo
390} -initialize {
391  rename sqlite3 sqlite3_onefile
392  proc sqlite3 {args} {
393    if {[string range [lindex $args 0] 0 0] ne "-"} {
394      lappend args -vfs fs
395    }
396    uplevel [concat sqlite3_onefile $args]
397  }
398} -files {
399  conflict.test  insert.test   insert2.test  insert3.test
400  rollback.test  select1.test  select2.test  select3.test
401} -shutdown {
402  rename sqlite3 {}
403  rename sqlite3_onefile sqlite3
404}
405
406# Run some tests using UTF-16 databases.
407#
408test_suite "utf16" -description {
409  Run tests using UTF-16 databases
410} -presql {
411  pragma encoding = 'UTF-16'
412} -files {
413    alter.test alter3.test
414    auth.test bind.test blob.test capi2.test capi3.test collate1.test
415    collate2.test collate3.test collate4.test collate5.test collate6.test
416    conflict.test date.test delete.test expr.test fkey1.test func.test
417    hook.test index.test insert2.test insert.test interrupt.test in.test
418    intpkey.test ioerr.test join2.test join.test lastinsert.test
419    laststmtchanges.test limit.test lock2.test lock.test main.test
420    memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test
421    null.test progress.test quote.test rowid.test select1.test select2.test
422    select3.test select4.test select5.test select6.test sort.test
423    subselect.test tableapi.test table.test temptable.test
424    trace.test trigger1.test trigger2.test trigger3.test
425    trigger4.test types2.test types.test unique.test update.test
426    vacuum.test view.test where.test
427}
428
429# Run some tests in exclusive locking mode.
430#
431test_suite "exclusive" -description {
432  Run tests in exclusive locking mode.
433} -presql {
434  pragma locking_mode = 'exclusive'
435} -files {
436  rollback.test select1.test select2.test
437  malloc.test ioerr.test
438}
439
440# Run some tests in exclusive locking mode with truncated journals.
441#
442test_suite "exclusive-truncate" -description {
443  Run tests in exclusive locking mode and truncate journal mode.
444} -presql {
445  pragma locking_mode = 'exclusive';
446  pragma journal_mode = TRUNCATE;
447} -files {
448  delete.test delete2.test insert.test rollback.test select1.test
449  select2.test update.test malloc.test ioerr.test
450}
451
452# Run some tests in persistent journal mode.
453#
454test_suite "persistent_journal" -description {
455  Run tests in persistent-journal mode.
456} -presql {
457  pragma journal_mode = persist
458} -files {
459  delete.test delete2.test insert.test rollback.test select1.test
460  select2.test trans.test update.test vacuum.test
461}
462
463# Run some tests in truncating journal mode.
464#
465test_suite "truncate_journal" -description {
466  Run tests in persistent-journal mode.
467} -presql {
468  pragma journal_mode = truncate
469} -files {
470  delete.test delete2.test insert.test rollback.test select1.test
471  select2.test trans.test update.test vacuum.test
472  malloc.test ioerr.test
473}
474
475# Run some error tests in persistent journal mode.
476#
477test_suite "persistent_journal_error" -description {
478  Run malloc.test and ioerr.test in persistent-journal mode.
479} -presql {
480  pragma journal_mode = persist
481} -files {
482  malloc.test ioerr.test
483}
484
485# Run some tests in no journal mode.
486#
487test_suite "no_journal" -description {
488  Run tests in no-journal mode.
489} -presql {
490  pragma journal_mode = persist
491} -files {
492  delete.test delete2.test insert.test rollback.test select1.test
493  select2.test trans.test update.test vacuum.test
494}
495
496# Run some error tests in no journal mode.
497#
498test_suite "no_journal_error" -description {
499  Run malloc.test and ioerr.test in no-journal mode.
500} -presql {
501  pragma journal_mode = persist
502} -files {
503  malloc.test ioerr.test
504}
505
506# Run some crash-tests in autovacuum mode.
507#
508test_suite "autovacuum_crash" -description {
509  Run crash.test in autovacuum mode.
510} -presql {
511  pragma auto_vacuum = 1
512} -files crash.test
513
514# Run some ioerr-tests in autovacuum mode.
515#
516test_suite "autovacuum_ioerr" -description {
517  Run ioerr.test in autovacuum mode.
518} -presql {
519  pragma auto_vacuum = 1
520} -files ioerr.test
521
522# Run tests with an in-memory journal.
523#
524test_suite "inmemory_journal" -description {
525  Run tests with an in-memory journal file.
526} -presql {
527  pragma journal_mode = 'memory'
528} -files [test_set $::allquicktests -exclude {
529  # Exclude all tests that simulate IO errors.
530  autovacuum_ioerr2.test incrvacuum_ioerr.test ioerr.test
531  ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test
532  vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test
533  e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test
534  fts3snippet.test
535
536  # Exclude test scripts that use tcl IO to access journal files or count
537  # the number of fsync() calls.
538  pager.test exclusive.test jrnlmode.test sync.test misc1.test
539  journal1.test conflict.test crash8.test tkt3457.test io.test
540  journal3.test 8_3_names.test
541
542  pager1.test async4.test corrupt.test filefmt.test pager2.test
543  corrupt5.test corruptA.test pageropt.test
544
545  # Exclude stmt.test, which expects sub-journals to use temporary files.
546  stmt.test
547
548  zerodamage.test
549
550  # WAL mode is different.
551  wal* tkt-2d1a5c67d.test backcompat.test
552}]
553
554ifcapable mem3 {
555  test_suite "memsys3" -description {
556    Run tests using the allocator in mem3.c.
557  } -files [test_set $::allquicktests -exclude {
558    autovacuum.test           delete3.test              manydb.test
559    bigrow.test               incrblob2.test            memdb.test
560    bitvec.test               index2.test               memsubsys1.test
561    capi3c.test               ioerr.test                memsubsys2.test
562    capi3.test                join3.test                pagesize.test
563    collate5.test             limit.test                backup_ioerr.test
564    backup_malloc.test
565  }] -initialize {
566    catch {db close}
567    sqlite3_reset_auto_extension
568    sqlite3_shutdown
569    sqlite3_config_heap 25000000 0
570    sqlite3_config_lookaside 0 0
571    ifcapable mem5 {
572      # If both memsys3 and memsys5 are enabled in the build, the call to
573      # [sqlite3_config_heap] will initialize the system to use memsys5.
574      # The following overrides this preference and installs the memsys3
575      # allocator.
576      sqlite3_install_memsys3
577    }
578    install_malloc_faultsim 1
579    sqlite3_initialize
580    autoinstall_test_functions
581  } -shutdown {
582    catch {db close}
583    sqlite3_shutdown
584    sqlite3_config_heap 0 0
585    sqlite3_config_lookaside 100 500
586    install_malloc_faultsim 1
587    sqlite3_initialize
588    autoinstall_test_functions
589  }
590}
591
592ifcapable mem5 {
593  test_suite "memsys5" -description {
594    Run tests using the allocator in mem5.c.
595  } -files [test_set $::allquicktests -exclude {
596    autovacuum.test           delete3.test              manydb.test
597    bigrow.test               incrblob2.test            memdb.test
598    bitvec.test               index2.test               memsubsys1.test
599    capi3c.test               ioerr.test                memsubsys2.test
600    capi3.test                join3.test                pagesize.test
601    collate5.test             limit.test                zeroblob.test
602  }] -initialize {
603    catch {db close}
604    sqlite3_shutdown
605    sqlite3_config_heap 25000000 64
606    sqlite3_config_lookaside 0 0
607    install_malloc_faultsim 1
608    sqlite3_initialize
609    autoinstall_test_functions
610  } -shutdown {
611    catch {db close}
612    sqlite3_shutdown
613    sqlite3_config_heap 0 0
614    sqlite3_config_lookaside 100 500
615    install_malloc_faultsim 1
616    sqlite3_initialize
617    autoinstall_test_functions
618  }
619
620  test_suite "memsys5-2" -description {
621    Run tests using the allocator in mem5.c in a different configuration.
622  } -files {
623    select1.test
624  } -initialize {
625    catch {db close}
626    sqlite3_shutdown
627    sqlite3_config_memstatus 0
628    sqlite3_config_heap 40000000 16
629    sqlite3_config_lookaside 0 0
630    install_malloc_faultsim 1
631    sqlite3_initialize
632    autoinstall_test_functions
633  } -shutdown {
634    catch {db close}
635    sqlite3_shutdown
636    sqlite3_config_heap 0 0
637    sqlite3_config_lookaside 100 500
638    install_malloc_faultsim 1
639    sqlite3_initialize
640    autoinstall_test_functions
641  }
642}
643
644ifcapable threadsafe {
645  test_suite "no_mutex_try" -description {
646     The sqlite3_mutex_try() interface always fails
647  } -files [
648    test_set $::allquicktests -exclude mutex1.test mutex2.test
649  ] -initialize {
650    catch {db close}
651    sqlite3_shutdown
652    install_mutex_counters 1
653    set ::disable_mutex_try 1
654    sqlite3_initialize
655    autoinstall_test_functions
656  } -shutdown {
657    catch {db close}
658    sqlite3_shutdown
659    install_mutex_counters 0
660    sqlite3_initialize
661    autoinstall_test_functions
662  }
663}
664
665# run_tests "crash_safe_append" -description {
666#   Run crash.test with persistent journals on a SAFE_APPEND file-system.
667# } -initialize {
668#   rename crashsql sa_crashsql
669#   proc crashsql {args} {
670#     set options [lrange $args 0 [expr {[llength $args]-2}]]
671#     lappend options -char safe_append
672#     set sql [lindex $args end]
673#     lappend options "
674#       PRAGMA journal_mode=persistent;
675#       $sql
676#     "
677#     set fd [open test.db-journal w]
678#     puts $fd [string repeat 1234567890 100000]
679#     close $fd
680#     eval sa_crashsql $options
681#   }
682# } -shutdown {
683#   rename crashsql {}
684#   rename sa_crashsql crashsql
685# } -files crash.test
686
687test_suite "safe_append" -description {
688  Run some tests on a SAFE_APPEND file-system.
689} -initialize {
690  rename sqlite3 sqlite3_safeappend
691  proc sqlite3 {args} {
692    if {[string range [lindex $args 0] 0 0] ne "-"} {
693      lappend args -vfs devsym
694    }
695    uplevel [concat sqlite3_safeappend $args]
696  }
697  sqlite3_simulate_device -char safe_append
698} -shutdown {
699  rename sqlite3 {}
700  rename sqlite3_shutdown sqlite3
701} -files [
702  test_set $::allquicktests shared_err.test -exclude async3.test
703]
704
705# The set of tests to run on the alternative-pcache
706set perm-alt-pcache-testset {
707  async.test
708  attach.test
709  delete.test delete2.test
710  index.test
711  insert.test insert2.test
712  join.test join2.test
713  rollback.test
714  select1.test select2.test
715  trans.test
716  update.test
717}
718
719foreach discard_rate {0 10 50 90 100} {
720  test_suite "pcache${discard_rate}" -description "
721    Alternative pcache implementation with ${discard_rate}% random discard
722  " -initialize "
723    catch {db close}
724    sqlite3_shutdown
725    sqlite3_config_alt_pcache 1 $discard_rate 1
726    sqlite3_initialize
727    autoinstall_test_functions
728  " -shutdown {
729    catch {db close}
730    sqlite3_shutdown
731    sqlite3_config_alt_pcache 0 0 0
732    sqlite3_config_lookaside 100 500
733    install_malloc_faultsim 1
734    sqlite3_initialize
735    autoinstall_test_functions
736  } -files ${perm-alt-pcache-testset}
737}
738
739test_suite "journaltest" -description {
740  Check that pages are synced before being written (test_journal.c).
741} -initialize {
742  catch {db close}
743  register_jt_vfs -default ""
744} -shutdown {
745  unregister_jt_vfs
746} -files [test_set $::allquicktests -exclude {
747  wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test
748  async4.test bigfile.test backcompat.test
749}]
750
751if {[info commands register_demovfs] != ""} {
752  test_suite "demovfs" -description {
753    Check that the demovfs (code in test_demovfs.c) more or less works.
754  } -initialize {
755    register_demovfs
756  } -shutdown {
757    unregister_demovfs
758  } -files {
759    insert.test   insert2.test  insert3.test rollback.test
760    select1.test  select2.test  select3.test
761  }
762}
763
764test_suite "wal" -description {
765  Run tests with journal_mode=WAL
766} -initialize {
767  set ::G(savepoint6_iterations) 100
768} -shutdown {
769  unset -nocomplain ::G(savepoint6_iterations)
770} -files {
771  savepoint.test     savepoint2.test     savepoint6.test
772  trans.test         avtrans.test
773
774  fts3aa.test  fts3ab.test  fts3ac.test  fts3ad.test
775  fts3ae.test  fts3af.test  fts3ag.test  fts3ah.test
776  fts3ai.test  fts3aj.test  fts3ak.test  fts3al.test
777  fts3am.test  fts3an.test  fts3ao.test  fts3b.test
778  fts3c.test   fts3d.test   fts3e.test   fts3query.test
779}
780
781test_suite "rtree" -description {
782  All R-tree related tests. Provides coverage of source file rtree.c.
783} -files [glob -nocomplain $::testdir/../ext/rtree/*.test]
784
785test_suite "no_optimization" -description {
786  Run test scripts with optimizations disabled using the
787  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) interface.
788} -files {
789  where.test where2.test where3.test where4.test where5.test
790  where6.test where7.test where8.test where9.test
791  whereA.test whereB.test wherelimit.test
792  select1.test select2.test select3.test select4.test select5.test
793  select7.test select8.test selectA.test selectC.test
794} -dbconfig {
795  optimization_control $::dbhandle all 0
796}
797
798test_suite "prepare" -description {
799  Run tests with the db connection using sqlite3_prepare() instead of _v2().
800} -dbconfig {
801  db_use_legacy_prepare $::dbhandle 1
802  #$::dbhandle cache size 0
803} -files [
804  test_set $allquicktests -exclude *malloc* *ioerr* *fault*
805]
806
807# End of tests
808#############################################################################
809
810# run_tests NAME OPTIONS
811#
812# where available options are:
813#
814#       -description TITLE
815#       -initialize  SCRIPT
816#       -shutdown    SCRIPT
817#       -presql      SQL
818#       -files       LIST-OF-FILES
819#       -prefix      NAME
820#
821proc run_tests {name args} {
822  array set options $args
823
824  set ::G(perm:name)         $name
825  set ::G(perm:prefix)       $options(-prefix)
826  set ::G(perm:presql)       $options(-presql)
827  set ::G(isquick)           1
828  set ::G(perm:dbconfig)     $options(-dbconfig)
829
830  uplevel $options(-initialize)
831
832  foreach file [lsort $options(-files)] {
833    if {[file tail $file] == $file} { set file [file join $::testdir $file] }
834    slave_test_file $file
835  }
836
837  uplevel $options(-shutdown)
838
839  unset ::G(perm:name)
840  unset ::G(perm:prefix)
841  unset ::G(perm:presql)
842  unset ::G(perm:dbconfig)
843}
844
845proc run_test_suite {name} {
846  if {[info exists ::testspec($name)]==0} {
847    error "No such test suite: $name"
848  }
849  uplevel run_tests $name $::testspec($name)
850}
851
852proc help {} {
853  puts "Usage: $::argv0 TESTSUITE ?TESTFILE?"
854  puts ""
855  puts "Available test-suites are:"
856  foreach k $::testsuitelist {
857    if {[info exists ::testspec($k)]==0} {
858      puts "         ----------------------------------------"
859      puts ""
860    } else {
861      array set o $::testspec($k)
862      puts "Test suite: \"$k\""
863      set d [string trim $o(-description)]
864      set d [regsub {\n *} $d "\n  "]
865      puts "  $d"
866      puts ""
867    }
868  }
869  exit -1
870}
871
872if {[info script] == $argv0} {
873  proc main {argv} {
874    if {[llength $argv]==0} {
875      help
876    } else {
877      set suite [lindex $argv 0]
878      if {[info exists ::testspec($suite)]==0} help
879      set extra ""
880      if {[llength $argv]>1} { set extra [list -files [lrange $argv 1 end]] }
881      eval run_tests $suite $::testspec($suite) $extra
882    }
883  }
884  main $argv
885  finish_test
886}
887