First public contribution.
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # $Id: permutations.test,v 1.32 2008/09/29 14:27:41 danielk1977 Exp $
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
17 # Argument processing.
19 #puts "PERM-DEBUG: argv=$argv"
20 namespace eval ::perm {
21 variable testmode [lindex $::argv 0]
22 variable testfile [lindex $::argv 1]
24 set argv [lrange $argv 2 end]
25 #puts "PERM-DEBUG: testmode=$::perm::testmode tstfile=$::perm::testfile"
27 set ::permutations_presql ""
28 set ::permutations_test_prefix ""
30 if {$::perm::testmode eq "veryquick"} {
31 set ::perm::testmode [list persistent_journal no_journal]
34 if {$::perm::testmode eq "quick"} {
35 set ::perm::testmode [list persistent_journal no_journal autovacuum_ioerr]
38 if {$::perm::testmode eq "all" || $::perm::testmode eq ""} {
39 set ::perm::testmode {
40 memsubsys1 memsubsys2 singlethread multithread onefile utf16 exclusive
41 persistent_journal persistent_journal_error no_journal no_journal_error
42 autovacuum_ioerr no_mutex_try
45 if {$::perm::testmode eq "targets"} {
47 puts -nonewline "veryquick "
48 puts "Same as persistent_journal and no_journal"
49 puts -nonewline "quick "
50 puts "Same as persistent_journal, no_journal and autovacuum_ioerr"
51 puts -nonewline "all "
52 puts "Everything except autovacuum_crash"
54 #puts "PERM-DEBUG: testmode=$::perm::testmode"
57 all.test in2.test onefile.test
58 async2.test incrvacuum_ioerr.test permutations.test
59 async.test jrnlmode2.test quick.test
60 autovacuum_crash.test jrnlmode3.test shared_err.test
61 autovacuum_ioerr.test jrnlmode4.test soak.test
62 btree8.test loadext.test speed1p.test
63 corrupt.test malloc2.test speed1.test
64 crash2.test malloc3.test speed2.test
65 crash3.test malloc4.test speed3.test
66 crash4.test mallocAll.test speed4p.test
67 crash6.test malloc.test speed4.test
68 crash7.test memleak.test sqllimits1.test
69 crash.test memsubsys1.test thread001.test
70 exclusive3.test memsubsys2.test thread002.test
71 fts3.test misc7.test utf16.test
72 fuzz_malloc.test misuse.test veryquick.test
73 fuzz.test mutex2.test vtab_err.test
74 lookaside.test fuzz3.test
77 foreach filename [glob $testdir/*.test] {
78 set filename [file tail $filename]
79 if {[lsearch $EXCLUDE $filename] < 0} { lappend ALLTESTS $filename }
81 set ALLTESTS [lsort $ALLTESTS]
83 rename finish_test really_finish_test2
84 proc finish_test {} {}
86 rename do_test really_do_test
88 proc do_test {name args} {
89 eval really_do_test [list "perm-$::permutations_test_prefix.$name"] $args
92 # Overload the [sqlite3] command
93 rename sqlite3 really_sqlite3
95 set r [eval really_sqlite3 $args]
96 if { [llength $args] == 2 && $::permutations_presql ne "" } {
97 [lindex $args 0] eval $::permutations_presql
104 # where available options are:
106 # -initialize SCRIPT (default "")
107 # -shutdown SCRIPT (default "")
108 # -include LIST-OF-FILES (default $::ALLTESTS)
109 # -exclude LIST-OF-FILES (default "")
110 # -presql SQL (default "")
111 # -description TITLE (default "")
113 proc run_tests {name args} {
114 set ::permutations_test_prefix $name
115 set options(-shutdown) ""
116 set options(-initialize) ""
117 set options(-exclude) ""
118 set options(-include) $::ALLTESTS
119 set options(-presql) ""
120 set options(-description) "no description supplied (fixme)"
121 array set options $args
122 #puts "PERM-DEBUG: name=$name testfile=$::perm::testfile"
123 #puts "PERM-DEBUG: [array get options]"
125 if {$::perm::testmode eq "targets"} {
126 puts [format "% -20s %s" $name [string trim $options(-description)]]
129 if {$::perm::testmode ne "" && [lsearch $::perm::testmode $name]<0} {
130 puts "skipping permutation test $name..."
134 uplevel $options(-initialize)
135 set ::permutations_presql $options(-presql)
137 foreach file [lsort $options(-include)] {
138 if {[lsearch $options(-exclude) $file] < 0 &&
139 ( $::perm::testfile eq "" ||
140 $::perm::testfile eq $file ||
141 "$::perm::testfile.test" eq $file )
143 set ::perm::shared_cache_setting [shared_cache_setting]
144 uplevel source $::testdir/$file
145 if {$::perm::shared_cache_setting ne [shared_cache_setting]} {
146 error "File $::testdir/$file changed the shared cache setting from $::perm::shared_cache_setting to [shared_cache_setting]"
149 # puts "skipping file $file"
153 uplevel $options(-shutdown)
156 proc shared_cache_setting {} {
159 set ret [sqlite3_enable_shared_cache]
164 #############################################################################
167 # Run some tests using pre-allocated page and scratch blocks.
169 run_tests "memsubsys1" -description {
170 Tests using pre-allocated page and scratch blocks
177 sqlite3_config_pagecache 4096 24
178 sqlite3_config_scratch 25000 1
183 sqlite3_config_pagecache 0 0
184 sqlite3_config_scratch 0 0
188 # Run some tests using pre-allocated page and scratch blocks. This time
189 # the allocations are too small to use in most cases.
191 # Both ioerr5.test and malloc5.test are excluded because they test the
192 # sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
193 # This functionality is disabled if a pre-allocated page block is provided.
195 run_tests "memsubsys2" -description {
196 Tests using small pre-allocated page and scratch blocks
203 sqlite3_config_pagecache 512 5
204 sqlite3_config_scratch 1000 1
209 sqlite3_config_pagecache 0 0
210 sqlite3_config_scratch 0 0
214 # Run all tests with the lookaside allocator disabled.
216 run_tests "memsubsys3" -description {
217 OOM tests with lookaside disabled
237 sqlite3_config_lookaside 0 0
242 sqlite3_config_lookaside 100 500
246 # Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
248 run_tests "singlethread" -description {
249 Tests run in SQLITE_CONFIG_SINGLETHREAD mode
251 do_test mutex2-singlethread.0 {
254 sqlite3_config singlethread
257 delete.test delete2.test insert.test rollback.test select1.test
258 select2.test trans.test update.test vacuum.test types.test
259 types2.test types3.test
264 sqlite3_config serialized
268 run_tests "nomutex" -description {
269 Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
271 rename sqlite3 sqlite3_nomutex
272 proc sqlite3 {args} {
273 if {[string range [lindex $args 0] 0 0] ne "-"} {
274 lappend args -fullmutex 0 -nomutex 1
276 uplevel [concat sqlite3_nomutex $args]
279 delete.test delete2.test insert.test rollback.test select1.test
280 select2.test trans.test update.test vacuum.test types.test
281 types2.test types3.test
284 rename sqlite3_nomutex sqlite3
287 # Run some tests in SQLITE_CONFIG_MULTITHREAD mode.
289 run_tests "multithread" -description {
290 Tests run in SQLITE_CONFIG_MULTITHREAD mode
292 do_test mutex2-multithread.0 {
295 sqlite3_config multithread
298 delete.test delete2.test insert.test rollback.test select1.test
299 select2.test trans.test update.test vacuum.test types.test
300 types2.test types3.test
305 sqlite3_config serialized
309 # Run some tests in SQLITE_OPEN_FULLMUTEX mode.
311 run_tests "fullmutex" -description {
312 Tests run in SQLITE_OPEN_FULLMUTEX mode
314 rename sqlite3 sqlite3_fullmutex
315 proc sqlite3 {args} {
316 if {[string range [lindex $args 0] 0 0] ne "-"} {
317 lappend args -nomutex 0 -fullmutex 1
319 uplevel [concat sqlite3_fullmutex $args]
322 delete.test delete2.test insert.test rollback.test select1.test
323 select2.test trans.test update.test vacuum.test types.test
324 types2.test types3.test
327 rename sqlite3_fullmutex sqlite3
330 # Run some tests using the "onefile" demo.
332 run_tests "onefile" -description {
333 Run some tests using the "test_onefile.c" demo
335 rename sqlite3 sqlite3_onefile
336 proc sqlite3 {args} {
337 if {[string range [lindex $args 0] 0 0] ne "-"} {
340 uplevel [concat sqlite3_onefile $args]
343 conflict.test insert.test insert2.test insert3.test
344 rollback.test select1.test select2.test select3.test
347 rename sqlite3_onefile sqlite3
350 # Run some tests using UTF-16 databases.
352 run_tests "utf16" -description {
353 Run tests using UTF-16 databases
355 pragma encoding = 'UTF-16'
357 alter.test alter3.test
358 auth.test bind.test blob.test capi2.test capi3.test collate1.test
359 collate2.test collate3.test collate4.test collate5.test collate6.test
360 conflict.test date.test delete.test expr.test fkey1.test func.test
361 hook.test index.test insert2.test insert.test interrupt.test in.test
362 intpkey.test ioerr.test join2.test join.test lastinsert.test
363 laststmtchanges.test limit.test lock2.test lock.test main.test
364 memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test
365 null.test progress.test quote.test rowid.test select1.test select2.test
366 select3.test select4.test select5.test select6.test sort.test
367 subselect.test tableapi.test table.test temptable.test
368 trace.test trigger1.test trigger2.test trigger3.test
369 trigger4.test types2.test types.test unique.test update.test
370 vacuum.test view.test where.test
373 # Run some tests in exclusive locking mode.
375 run_tests "exclusive" -description {
376 Run tests in exclusive locking mode.
378 pragma locking_mode = 'exclusive'
380 rollback.test select1.test select2.test
381 malloc.test ioerr.test
384 # Run some tests in exclusive locking mode with truncated journals.
386 run_tests "exclusive-truncate" -description {
387 Run tests in exclusive locking mode and truncate journal mode.
389 pragma locking_mode = 'exclusive';
390 pragma journal_mode = TRUNCATE;
392 delete.test delete2.test insert.test rollback.test select1.test
393 select2.test update.test malloc.test ioerr.test
396 # Run some tests in persistent journal mode.
398 run_tests "persistent_journal" -description {
399 Run tests in persistent-journal mode.
401 pragma journal_mode = persist
403 delete.test delete2.test insert.test rollback.test select1.test
404 select2.test trans.test update.test vacuum.test
407 # Run some tests in truncating journal mode.
409 run_tests "truncate_journal" -description {
410 Run tests in persistent-journal mode.
412 pragma journal_mode = truncate
414 delete.test delete2.test insert.test rollback.test select1.test
415 select2.test trans.test update.test vacuum.test
416 malloc.test ioerr.test
419 # Run some error tests in persistent journal mode.
421 run_tests "persistent_journal_error" -description {
422 Run malloc.test and ioerr.test in persistent-journal mode.
424 pragma journal_mode = persist
426 malloc.test ioerr.test
429 # Run some tests in no journal mode.
431 run_tests "no_journal" -description {
432 Run tests in no-journal mode.
434 pragma journal_mode = persist
436 delete.test delete2.test insert.test rollback.test select1.test
437 select2.test trans.test update.test vacuum.test
440 # Run some error tests in no journal mode.
442 run_tests "no_journal_error" -description {
443 Run malloc.test and ioerr.test in no-journal mode.
445 pragma journal_mode = persist
447 malloc.test ioerr.test
450 # Run some crash-tests in autovacuum mode.
452 run_tests "autovacuum_crash" -description {
453 Run crash.test in autovacuum mode.
455 pragma auto_vacuum = 1
456 } -include crash.test
458 # Run some ioerr-tests in autovacuum mode.
460 run_tests "autovacuum_ioerr" -description {
461 Run ioerr.test in autovacuum mode.
463 pragma auto_vacuum = 1
464 } -include ioerr.test
467 run_tests "memsys3" -description {
468 Run tests using the allocator in mem3.c.
470 autovacuum.test delete3.test manydb.test
471 bigrow.test incrblob2.test memdb.test
472 bitvec.test index2.test memsubsys1.test
473 capi3c.test ioerr.test memsubsys2.test
474 capi3.test join3.test pagesize.test
475 collate5.test limit.test
478 sqlite3_reset_auto_extension
480 sqlite3_config_heap 25000000 0
481 sqlite3_config_lookaside 0 0
482 install_malloc_faultsim 1
484 autoinstall_test_functions
487 sqlite3_reset_auto_extension
489 sqlite3_config_heap 0 0
490 sqlite3_config_lookaside 100 500
491 install_malloc_faultsim 1
497 run_tests "memsys5" -description {
498 Run tests using the allocator in mem5.c.
500 autovacuum.test delete3.test manydb.test
501 bigrow.test incrblob2.test memdb.test
502 bitvec.test index2.test memsubsys1.test
503 capi3c.test ioerr.test memsubsys2.test
504 capi3.test join3.test pagesize.test
505 collate5.test limit.test
508 sqlite3_reset_auto_extension
510 sqlite3_config_heap 25000000 64
511 sqlite3_config_lookaside 0 0
512 install_malloc_faultsim 1
514 autoinstall_test_functions
517 sqlite3_reset_auto_extension
519 sqlite3_config_heap 0 0
520 sqlite3_config_lookaside 100 500
521 install_malloc_faultsim 1
525 run_tests "memsys5-2" -description {
526 Run tests using the allocator in mem5.c in a different configuration.
531 sqlite3_reset_auto_extension
533 sqlite3_config_heap 40000000 16
534 sqlite3_config_lookaside 0 0
535 install_malloc_faultsim 1
537 autoinstall_test_functions
540 sqlite3_reset_auto_extension
542 sqlite3_config_heap 0 0
543 sqlite3_config_lookaside 100 500
544 install_malloc_faultsim 1
549 ifcapable threadsafe {
550 run_tests "no_mutex_try" -description {
551 The sqlite3_mutex_try() interface always fails
552 } -exclude [concat $EXCLUDE mutex1.test mutex2.test] \
556 install_mutex_counters 1
557 set ::disable_mutex_try 1
561 install_mutex_counters 0
565 run_tests "memsys6" -description {
566 Run tests using the allocator in mem6.c.
568 capi3.test capi3c.test
571 sqlite3_reset_auto_extension
573 sqlite3_config_chunkalloc 0
574 install_malloc_faultsim 1
576 autoinstall_test_functions
579 sqlite3_reset_auto_extension
581 sqlite3_config_heap 0 0
582 install_malloc_faultsim 1
586 # run_tests "crash_safe_append" -description {
587 # Run crash.test with persistent journals on a SAFE_APPEND file-system.
589 # rename crashsql sa_crashsql
590 # proc crashsql {args} {
591 # set options [lrange $args 0 [expr {[llength $args]-2}]]
592 # lappend options -char safe_append
593 # set sql [lindex $args end]
595 # PRAGMA journal_mode=persistent;
598 # set fd [open test.db-journal w]
599 # puts $fd [string repeat 1234567890 100000]
601 # eval sa_crashsql $options
605 # rename sa_crashsql crashsql
606 # } -include crash.test
608 run_tests "safe_append" -description {
609 Run some tests on a SAFE_APPEND file-system.
611 rename sqlite3 sqlite3_safeappend
612 proc sqlite3 {args} {
613 if {[string range [lindex $args 0] 0 0] ne "-"} {
614 lappend args -vfs devsym
616 uplevel [concat sqlite3_safeappend $args]
618 sqlite3_simulate_device -char safe_append
621 rename sqlite3_shutdown sqlite3
622 } -include [lsort [concat shared_err.test $ALLTESTS]] \
627 #############################################################################
629 if {$::perm::testmode eq "targets"} { puts "" ; exit }
631 # Restore the [sqlite3] command.
634 rename really_sqlite3 sqlite3
636 # Restore the [finish_test] command.
638 rename finish_test ""
639 rename really_finish_test2 finish_test
641 # Restore the [do_test] command.
644 rename really_do_test do_test