interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / permutations.test

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