summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/test/permutations.test
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/sqlite/test/permutations.test')
-rw-r--r--third_party/sqlite/test/permutations.test390
1 files changed, 302 insertions, 88 deletions
diff --git a/third_party/sqlite/test/permutations.test b/third_party/sqlite/test/permutations.test
index 8aee99f..2dec299 100644
--- a/third_party/sqlite/test/permutations.test
+++ b/third_party/sqlite/test/permutations.test
@@ -9,36 +9,41 @@
#
#***********************************************************************
#
-# $Id: permutations.test,v 1.20 2008/08/01 18:47:02 drh Exp $
+# $Id: permutations.test,v 1.51 2009/07/01 18:09:02 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Argument processing.
#
-set ::testmode [lindex $argv 0]
-set ::testfile [lindex $argv 1]
+#puts "PERM-DEBUG: argv=$argv"
+namespace eval ::perm {
+ variable testmode [lindex $::argv 0]
+ variable testfile [lindex $::argv 1]
+}
set argv [lrange $argv 2 end]
+#puts "PERM-DEBUG: testmode=$::perm::testmode tstfile=$::perm::testfile"
set ::permutations_presql ""
set ::permutations_test_prefix ""
-if {$::testmode eq "veryquick"} {
- set ::testmode [list persistent_journal no_journal]
+if {$::perm::testmode eq "veryquick"} {
+ set ::perm::testmode [list persistent_journal no_journal]
set ISQUICK 1
}
-if {$::testmode eq "quick"} {
- set ::testmode [list persistent_journal no_journal autovacuum_ioerr]
+if {$::perm::testmode eq "quick"} {
+ set ::perm::testmode [list persistent_journal no_journal autovacuum_ioerr]
set ISQUICK 1
}
-if {$::testmode eq "all"} {
- set ::testmode {
+if {$::perm::testmode eq "all" || $::perm::testmode eq ""} {
+ set ::perm::testmode {
memsubsys1 memsubsys2 singlethread multithread onefile utf16 exclusive
persistent_journal persistent_journal_error no_journal no_journal_error
- autovacuum_ioerr no_mutex_try
+ autovacuum_ioerr no_mutex_try fullmutex journaltest inmemory_journal
+ pcache0 pcache10 pcache50 pcache90 pcache100
}
}
-if {$::testmode eq "targets"} {
+if {$::perm::testmode eq "targets"} {
puts ""
puts -nonewline "veryquick "
puts "Same as persistent_journal and no_journal"
@@ -47,6 +52,7 @@ if {$::testmode eq "targets"} {
puts -nonewline "all "
puts "Everything except autovacuum_crash"
}
+#puts "PERM-DEBUG: testmode=$::perm::testmode"
set EXCLUDE {
all.test in2.test onefile.test
@@ -66,13 +72,15 @@ set EXCLUDE {
fts3.test misc7.test utf16.test
fuzz_malloc.test misuse.test veryquick.test
fuzz.test mutex2.test vtab_err.test
- lookaside.test
+ lookaside.test fuzz3.test savepoint4.test
+ savepoint6.test
}
set ALLTESTS [list]
foreach filename [glob $testdir/*.test] {
set filename [file tail $filename]
if {[lsearch $EXCLUDE $filename] < 0} { lappend ALLTESTS $filename }
}
+set ALLTESTS [lsort $ALLTESTS]
rename finish_test really_finish_test2
proc finish_test {} {}
@@ -113,25 +121,47 @@ proc run_tests {name args} {
set options(-presql) ""
set options(-description) "no description supplied (fixme)"
array set options $args
+ #puts "PERM-DEBUG: name=$name testfile=$::perm::testfile"
+ #puts "PERM-DEBUG: [array get options]"
- if {$::testmode eq "targets"} {
+ if {$::perm::testmode eq "targets"} {
puts [format "% -20s %s" $name [string trim $options(-description)]]
return
}
- if {$::testmode ne "" && [lsearch $::testmode $name]<0} return
+ if {$::perm::testmode ne "" && [lsearch $::perm::testmode $name]<0} {
+ puts "skipping permutation test $name..."
+ return
+ }
uplevel $options(-initialize)
set ::permutations_presql $options(-presql)
- foreach file $options(-include) {
- if {[lsearch $options(-exclude) $file] < 0 && (
- $::testfile eq "" || $::testfile eq $file || "$::testfile.test" eq $file
- ) } {
+ foreach file [lsort $options(-include)] {
+ if {[lsearch $options(-exclude) $file] < 0 &&
+ ( $::perm::testfile eq "" ||
+ $::perm::testfile eq $file ||
+ "$::perm::testfile.test" eq $file )
+ } {
+ set ::perm::shared_cache_setting [shared_cache_setting]
uplevel source $::testdir/$file
+ if {$::perm::shared_cache_setting ne [shared_cache_setting]} {
+ error "File $::testdir/$file changed the shared cache setting from $::perm::shared_cache_setting to [shared_cache_setting]"
+ }
+ } else {
+ # puts "skipping file $file"
}
}
uplevel $options(-shutdown)
+ set ::permutations_test_prefix ""
+}
+
+proc shared_cache_setting {} {
+ set ret 0
+ catch {
+ set ret [sqlite3_enable_shared_cache]
+ }
+ return $ret
}
#############################################################################
@@ -141,69 +171,69 @@ proc run_tests {name args} {
#
run_tests "memsubsys1" -description {
Tests using pre-allocated page and scratch blocks
+} -exclude {
+ ioerr5.test
+ malloc5.test
} -initialize {
catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 4096 24
sqlite3_config_scratch 25000 1
sqlite3_initialize
+ autoinstall_test_functions
} -shutdown {
catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 0 0
sqlite3_config_scratch 0 0
sqlite3_initialize
+ autoinstall_test_functions
}
# Run some tests using pre-allocated page and scratch blocks. This time
# the allocations are too small to use in most cases.
#
+# Both ioerr5.test and malloc5.test are excluded because they test the
+# sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.
+# This functionality is disabled if a pre-allocated page block is provided.
+#
run_tests "memsubsys2" -description {
Tests using small pre-allocated page and scratch blocks
+} -exclude {
+ ioerr5.test
+ malloc5.test
} -initialize {
catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 512 5
sqlite3_config_scratch 1000 1
sqlite3_initialize
+ autoinstall_test_functions
} -shutdown {
catch {db close}
sqlite3_shutdown
sqlite3_config_pagecache 0 0
sqlite3_config_scratch 0 0
sqlite3_initialize
+ autoinstall_test_functions
}
# Run all tests with the lookaside allocator disabled.
#
-run_tests "memsubsys3" -description {
+run_tests "nolookaside" -description {
OOM tests with lookaside disabled
-} -include {
- malloc.test
- malloc3.test
- malloc4.test
- malloc5.test
- malloc6.test
- malloc7.test
- malloc8.test
- malloc9.test
- mallocA.test
- mallocB.test
- mallocC.test
- mallocD.test
- mallocE.test
- mallocF.test
- mallocG.test
} -initialize {
catch {db close}
sqlite3_shutdown
sqlite3_config_lookaside 0 0
sqlite3_initialize
+ autoinstall_test_functions
} -shutdown {
catch {db close}
sqlite3_shutdown
sqlite3_config_lookaside 100 500
sqlite3_initialize
+ autoinstall_test_functions
}
# Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.
@@ -211,30 +241,30 @@ run_tests "memsubsys3" -description {
run_tests "singlethread" -description {
Tests run in SQLITE_CONFIG_SINGLETHREAD mode
} -initialize {
- do_test mutex2-singlethread.0 {
- catch {db close}
- sqlite3_shutdown
- sqlite3_config singlethread
- } SQLITE_OK
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config singlethread}
+ sqlite3_initialize
+ autoinstall_test_functions
} -include {
delete.test delete2.test insert.test rollback.test select1.test
select2.test trans.test update.test vacuum.test types.test
types2.test types3.test
} -shutdown {
- do_test mutex2-X {
- catch {db close}
- sqlite3_shutdown
- sqlite3_config serialized
- } SQLITE_OK
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config serialized}
+ sqlite3_initialize
+ autoinstall_test_functions
}
run_tests "nomutex" -description {
- Tests run with the SQLITE_OPEN_SINGLETHREADED flag passed to sqlite3_open().
+ Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().
} -initialize {
rename sqlite3 sqlite3_nomutex
proc sqlite3 {args} {
if {[string range [lindex $args 0] 0 0] ne "-"} {
- lappend args -nomutex 1
+ lappend args -fullmutex 0 -nomutex 1
}
uplevel [concat sqlite3_nomutex $args]
}
@@ -252,21 +282,42 @@ run_tests "nomutex" -description {
run_tests "multithread" -description {
Tests run in SQLITE_CONFIG_MULTITHREAD mode
} -initialize {
- do_test mutex2-multithread.0 {
- catch {db close}
- sqlite3_shutdown
- sqlite3_config multithread
- } SQLITE_OK
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config multithread}
+ sqlite3_initialize
+ autoinstall_test_functions
} -include {
delete.test delete2.test insert.test rollback.test select1.test
select2.test trans.test update.test vacuum.test types.test
types2.test types3.test
} -shutdown {
- do_test mutex2-X {
- catch {db close}
- sqlite3_shutdown
- sqlite3_config serialized
- } SQLITE_OK
+ catch {db close}
+ sqlite3_shutdown
+ catch {sqlite3_config serialized}
+ sqlite3_initialize
+ autoinstall_test_functions
+}
+
+# Run some tests in SQLITE_OPEN_FULLMUTEX mode.
+#
+run_tests "fullmutex" -description {
+ Tests run in SQLITE_OPEN_FULLMUTEX mode
+} -initialize {
+ rename sqlite3 sqlite3_fullmutex
+ proc sqlite3 {args} {
+ if {[string range [lindex $args 0] 0 0] ne "-"} {
+ lappend args -nomutex 0 -fullmutex 1
+ }
+ uplevel [concat sqlite3_fullmutex $args]
+ }
+} -include {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test types.test
+ types2.test types3.test
+} -shutdown {
+ rename sqlite3 {}
+ rename sqlite3_fullmutex sqlite3
}
# Run some tests using the "onefile" demo.
@@ -284,7 +335,6 @@ run_tests "onefile" -description {
} -include {
conflict.test insert.test insert2.test insert3.test
rollback.test select1.test select2.test select3.test
- temptable.test
} -shutdown {
rename sqlite3 {}
rename sqlite3_onefile sqlite3
@@ -324,6 +374,18 @@ run_tests "exclusive" -description {
malloc.test ioerr.test
}
+# Run some tests in exclusive locking mode with truncated journals.
+#
+run_tests "exclusive-truncate" -description {
+ Run tests in exclusive locking mode and truncate journal mode.
+} -presql {
+ pragma locking_mode = 'exclusive';
+ pragma journal_mode = TRUNCATE;
+} -include {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test update.test malloc.test ioerr.test
+}
+
# Run some tests in persistent journal mode.
#
run_tests "persistent_journal" -description {
@@ -335,6 +397,18 @@ run_tests "persistent_journal" -description {
select2.test trans.test update.test vacuum.test
}
+# Run some tests in truncating journal mode.
+#
+run_tests "truncate_journal" -description {
+ Run tests in persistent-journal mode.
+} -presql {
+ pragma journal_mode = truncate
+} -include {
+ delete.test delete2.test insert.test rollback.test select1.test
+ select2.test trans.test update.test vacuum.test
+ malloc.test ioerr.test
+}
+
# Run some error tests in persistent journal mode.
#
run_tests "persistent_journal_error" -description {
@@ -382,6 +456,24 @@ run_tests "autovacuum_ioerr" -description {
pragma auto_vacuum = 1
} -include ioerr.test
+# Run tests with an in-memory journal.
+#
+run_tests "inmemory_journal" -description {
+ Run tests with an in-memory journal file.
+} -presql {
+ pragma journal_mode = 'memory'
+} -exclude {
+ # Exclude all tests that simulate IO errors.
+ autovacuum_ioerr2.test incrvacuum_ioerr.test ioerr.test
+ ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test
+ vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test
+
+ # Exclude test scripts that use tcl IO to access journal files or count
+ # the number of fsync() calls.
+ pager.test exclusive.test jrnlmode.test sync.test misc1.test
+ journal1.test conflict.test crash8.test tkt3457.test io.test
+}
+
ifcapable mem3 {
run_tests "memsys3" -description {
Run tests using the allocator in mem3.c.
@@ -391,24 +483,32 @@ ifcapable mem3 {
bitvec.test index2.test memsubsys1.test
capi3c.test ioerr.test memsubsys2.test
capi3.test join3.test pagesize.test
- collate5.test limit.test
+ collate5.test limit.test backup_ioerr.test
+ backup_malloc.test
} -initialize {
catch {db close}
sqlite3_reset_auto_extension
sqlite3_shutdown
sqlite3_config_heap 25000000 0
sqlite3_config_lookaside 0 0
+ ifcapable mem5 {
+ # If both memsys3 and memsys5 are enabled in the build, the call to
+ # [sqlite3_config_heap] will initialize the system to use memsys5.
+ # The following overrides this preference and installs the memsys3
+ # allocator.
+ sqlite3_install_memsys3
+ }
install_malloc_faultsim 1
sqlite3_initialize
autoinstall_test_functions
} -shutdown {
catch {db close}
- sqlite3_reset_auto_extension
sqlite3_shutdown
sqlite3_config_heap 0 0
sqlite3_config_lookaside 100 500
install_malloc_faultsim 1
sqlite3_initialize
+ autoinstall_test_functions
}
}
@@ -421,10 +521,9 @@ ifcapable mem5 {
bitvec.test index2.test memsubsys1.test
capi3c.test ioerr.test memsubsys2.test
capi3.test join3.test pagesize.test
- collate5.test limit.test
+ collate5.test limit.test zeroblob.test
} -initialize {
catch {db close}
- sqlite3_reset_auto_extension
sqlite3_shutdown
sqlite3_config_heap 25000000 64
sqlite3_config_lookaside 0 0
@@ -433,12 +532,12 @@ ifcapable mem5 {
autoinstall_test_functions
} -shutdown {
catch {db close}
- sqlite3_reset_auto_extension
sqlite3_shutdown
sqlite3_config_heap 0 0
sqlite3_config_lookaside 100 500
install_malloc_faultsim 1
sqlite3_initialize
+ autoinstall_test_functions
}
run_tests "memsys5-2" -description {
@@ -447,7 +546,6 @@ ifcapable mem5 {
select1.test
} -initialize {
catch {db close}
- sqlite3_reset_auto_extension
sqlite3_shutdown
sqlite3_config_heap 40000000 16
sqlite3_config_lookaside 0 0
@@ -456,51 +554,35 @@ ifcapable mem5 {
autoinstall_test_functions
} -shutdown {
catch {db close}
- sqlite3_reset_auto_extension
sqlite3_shutdown
sqlite3_config_heap 0 0
sqlite3_config_lookaside 100 500
install_malloc_faultsim 1
sqlite3_initialize
+ autoinstall_test_functions
}
}
ifcapable threadsafe {
run_tests "no_mutex_try" -description {
The sqlite3_mutex_try() interface always fails
- } -initialize {
+ } -exclude [concat $EXCLUDE mutex1.test mutex2.test] \
+ -initialize {
catch {db close}
sqlite3_shutdown
install_mutex_counters 1
set ::disable_mutex_try 1
+ sqlite3_initialize
+ autoinstall_test_functions
} -shutdown {
catch {db close}
sqlite3_shutdown
install_mutex_counters 0
+ sqlite3_initialize
+ autoinstall_test_functions
}
}
-run_tests "memsys6" -description {
- Run tests using the allocator in mem6.c.
-} -exclude {
- capi3.test capi3c.test
-} -initialize {
- catch {db close}
- sqlite3_reset_auto_extension
- sqlite3_shutdown
- sqlite3_config_chunkalloc 0
- install_malloc_faultsim 1
- sqlite3_initialize
- autoinstall_test_functions
-} -shutdown {
- catch {db close}
- sqlite3_reset_auto_extension
- sqlite3_shutdown
- sqlite3_config_heap 0 0
- install_malloc_faultsim 1
- sqlite3_initialize
-}
-
# run_tests "crash_safe_append" -description {
# Run crash.test with persistent journals on a SAFE_APPEND file-system.
# } -initialize {
@@ -523,11 +605,143 @@ run_tests "memsys6" -description {
# rename sa_crashsql crashsql
# } -include crash.test
+run_tests "safe_append" -description {
+ Run some tests on a SAFE_APPEND file-system.
+} -initialize {
+ rename sqlite3 sqlite3_safeappend
+ proc sqlite3 {args} {
+ if {[string range [lindex $args 0] 0 0] ne "-"} {
+ lappend args -vfs devsym
+ }
+ uplevel [concat sqlite3_safeappend $args]
+ }
+ sqlite3_simulate_device -char safe_append
+} -shutdown {
+ rename sqlite3 {}
+ rename sqlite3_shutdown sqlite3
+} -include [lsort [concat shared_err.test $ALLTESTS]] \
+ -exclude async3.test
+
+# The set of tests to run on the alternative-pcache
+set perm-alt-pcache-testset {
+ async.test
+ attach.test
+ delete.test delete2.test
+ index.test
+ insert.test insert2.test
+ join.test join2.test
+ rollback.test
+ select1.test select2.test
+ trans.test
+ update.test
+}
+
+run_tests "pcache0" -description {
+ Alternative pcache implementation without random discard
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 1 0 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 0 0 0
+ sqlite3_config_lookaside 100 500
+ install_malloc_faultsim 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -include ${perm-alt-pcache-testset}
+
+run_tests "pcache10" -description {
+ Alternative pcache implementation without 10% random discard
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 1 50 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 0 0 0
+ sqlite3_initialize
+ autoinstall_test_functions
+} -include ${perm-alt-pcache-testset}
+
+run_tests "pcache50" -description {
+ Alternative pcache implementation without 50% random discard
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 1 50 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 0 0 0
+ sqlite3_initialize
+ autoinstall_test_functions
+} -include ${perm-alt-pcache-testset}
+
+run_tests "pcache90" -description {
+ Alternative pcache implementation without 90% random discard
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 1 50 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 0 0 0
+ sqlite3_initialize
+ autoinstall_test_functions
+} -include ${perm-alt-pcache-testset}
+
+run_tests "pcache100" -description {
+ Alternative pcache implementation that always discards when unpinning
+} -initialize {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 1 100 1
+ sqlite3_initialize
+ autoinstall_test_functions
+} -shutdown {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_alt_pcache 0 0 0
+ sqlite3_initialize
+ autoinstall_test_functions
+} -include ${perm-alt-pcache-testset}
+
+run_tests "journaltest" -description {
+ Check that pages are synced before being written (test_journal.c).
+} -initialize {
+ set ISQUICK 1
+ catch {db close}
+ register_jt_vfs -default ""
+ #sqlite3_instvfs binarylog -default binarylog ostrace.bin
+} -shutdown {
+ #sqlite3_instvfs destroy binarylog
+ unregister_jt_vfs
+} -include [concat $::ALLTESTS savepoint6.test
+] -exclude {
+ incrvacuum.test
+ ioerr.test
+ corrupt4.test
+ io.test
+ crash8.test
+ async4.test
+}
# End of tests
#############################################################################
-if {$::testmode eq "targets"} { puts "" ; exit }
+if {$::perm::testmode eq "targets"} { puts "" ; exit }
# Restore the [sqlite3] command.
#