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