danielk1977 | 1077e3f | 2008-06-21 18:07:37 +0000 | [diff] [blame] | 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 | # |
danielk1977 | 2dd6d80 | 2008-06-21 19:10:27 +0000 | [diff] [blame^] | 12 | # $Id: permutations.test,v 1.2 2008/06/21 19:10:27 danielk1977 Exp $ |
danielk1977 | 1077e3f | 2008-06-21 18:07:37 +0000 | [diff] [blame] | 13 | |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
| 16 | |
| 17 | # Argument processing. |
| 18 | # |
| 19 | set ::testmode [lindex $argv 0] |
| 20 | set ::testfile [lindex $argv 1] |
| 21 | set argv [lrange $argv 2 end] |
| 22 | |
| 23 | set ::permutations_presql "" |
| 24 | set ::permutations_test_prefix "" |
| 25 | |
| 26 | if {$::testmode eq "veryquick"} { |
| 27 | set ::testmode [list persistent_journal no_journal] |
| 28 | set ISQUICK 1 |
| 29 | } |
| 30 | if {$::testmode eq "quick"} { |
| 31 | set ::testmode [list persistent_journal no_journal autovacuum_ioerr] |
| 32 | set ISQUICK 1 |
| 33 | } |
| 34 | if {$::testmode eq "all"} { |
| 35 | set ::testmode { |
| 36 | memsubsys1 memsubsys2 singlethread multithread onefile utf16 exclusive |
| 37 | persistent_journal persistent_journal_error no_journal no_journal_error |
| 38 | autovacuum_ioerr |
| 39 | } |
| 40 | } |
| 41 | if {$::testmode eq "targets"} { |
| 42 | puts "" |
| 43 | puts -nonewline "veryquick " |
| 44 | puts "Same as persistent_journal and no_journal" |
| 45 | puts -nonewline "quick " |
| 46 | puts "Same as persistent_journal, no_journal and autovacuum_ioerr" |
| 47 | puts -nonewline "all " |
| 48 | puts "Everything except autovacuum_crash" |
| 49 | } |
| 50 | |
| 51 | set EXCLUDE { |
| 52 | all.test async.test async2.test corrupt.test |
| 53 | crash.test crash2.test crash3.test crash4.test |
| 54 | crash6.test crash7.test exclusive3.test fts3.test |
| 55 | fuzz.test fuzz_malloc.test in2.test jrnlmode3.test |
| 56 | loadext.test mallocAll.test malloc.test malloc2.test |
| 57 | malloc3.test malloc4.test memleak.test misc7.test |
| 58 | misuse.test mutex2.test onefile.test quick.test |
| 59 | soak.test speed1.test speed1p.test speed2.test |
| 60 | speed3.test speed4.test speed4p.test sqllimits1.test |
| 61 | thread001.test thread002.test btree8.test utf16.test |
| 62 | shared_err.test vtab_err.test veryquick.test incrvacuum_ioerr.test |
| 63 | autovacuum_crash.test permutations.test |
| 64 | autovacuum_ioerr.test jrnlmode2.test jrnlmode4.test |
| 65 | } |
| 66 | set ALLTESTS [list] |
| 67 | foreach filename [glob $testdir/*.test] { |
| 68 | set filename [file tail $filename] |
| 69 | if {[lsearch $EXCLUDE $filename] < 0} { lappend ALLTESTS $filename } |
| 70 | } |
| 71 | |
| 72 | rename finish_test really_finish_test2 |
| 73 | proc finish_test {} {} |
| 74 | |
| 75 | rename do_test really_do_test |
| 76 | |
| 77 | proc do_test {name args} { |
| 78 | eval really_do_test [list "perm-$::permutations_test_prefix.$name"] $args |
| 79 | } |
| 80 | |
| 81 | # Overload the [sqlite3] command |
| 82 | rename sqlite3 really_sqlite3 |
| 83 | proc sqlite3 {args} { |
| 84 | set r [eval really_sqlite3 $args] |
| 85 | if { [llength $args] == 2 && $::permutations_presql ne "" } { |
| 86 | [lindex $args 0] eval $::permutations_presql |
| 87 | } |
| 88 | set r |
| 89 | } |
| 90 | |
| 91 | # run_tests OPTIONS |
| 92 | # |
| 93 | # where available options are: |
| 94 | # |
| 95 | # -initialize SCRIPT (default "") |
| 96 | # -shutdown SCRIPT (default "") |
| 97 | # -include LIST-OF-FILES (default $::ALLTESTS) |
| 98 | # -exclude LIST-OF-FILES (default "") |
| 99 | # -presql SQL (default "") |
| 100 | # -description TITLE (default "") |
| 101 | # |
| 102 | proc run_tests {name args} { |
| 103 | set ::permutations_test_prefix $name |
| 104 | set options(-shutdown) "" |
| 105 | set options(-initialize) "" |
| 106 | set options(-exclude) "" |
| 107 | set options(-include) $::ALLTESTS |
| 108 | set options(-presql) "" |
| 109 | set options(-description) "no description supplied (fixme)" |
| 110 | array set options $args |
| 111 | |
| 112 | if {$::testmode eq "targets"} { |
| 113 | puts [format "% -20s %s" $name [string trim $options(-description)]] |
| 114 | return |
| 115 | } |
| 116 | if {$::testmode ne "" && [lsearch $::testmode $name]<0} return |
| 117 | |
| 118 | |
| 119 | uplevel $options(-initialize) |
| 120 | set ::permutations_presql $options(-presql) |
| 121 | |
| 122 | foreach file $options(-include) { |
| 123 | if {[lsearch $options(-exclude) $file] < 0 && ( |
| 124 | $::testfile eq "" || $::testfile eq $file || "$::testfile.test" eq $file |
| 125 | ) } { |
| 126 | uplevel source $::testdir/$file |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | uplevel $options(-shutdown) |
| 131 | } |
| 132 | |
| 133 | ############################################################################# |
| 134 | # Start of tests |
| 135 | |
| 136 | # Run some tests using pre-allocated page and scratch blocks. |
| 137 | # |
| 138 | run_tests "memsubsys1" -description { |
| 139 | Tests using pre-allocated page and scratch blocks |
| 140 | } -initialize { |
| 141 | sqlite3_shutdown |
| 142 | sqlite3_config_pagecache 4096 24 |
| 143 | sqlite3_config_scratch 25000 1 |
| 144 | sqlite3_initialize |
| 145 | } -exclude { |
| 146 | memsubsys1.test |
| 147 | } -shutdown { |
| 148 | catch {db close} |
| 149 | sqlite3_shutdown |
| 150 | sqlite3_config_pagecache 0 0 |
| 151 | sqlite3_config_scratch 0 0 |
| 152 | sqlite3_initialize |
| 153 | } |
| 154 | |
| 155 | # Run some tests using pre-allocated page and scratch blocks. This time |
| 156 | # the allocations are too small to use in most cases. |
| 157 | # |
| 158 | run_tests "memsubsys2" -description { |
| 159 | Tests using small pre-allocated page and scratch blocks |
| 160 | } -initialize { |
| 161 | sqlite3_shutdown |
| 162 | sqlite3_config_pagecache 512 5 |
| 163 | sqlite3_config_scratch 1000 1 |
| 164 | sqlite3_initialize |
| 165 | } -exclude { |
| 166 | memsubsys1.test |
| 167 | } -shutdown { |
| 168 | catch {db close} |
| 169 | sqlite3_shutdown |
| 170 | sqlite3_config_pagecache 0 0 |
| 171 | sqlite3_config_scratch 0 0 |
| 172 | sqlite3_initialize |
| 173 | } |
| 174 | |
| 175 | # Run some tests in SQLITE_CONFIG_SINGLETHREAD mode. |
| 176 | # |
| 177 | run_tests "singlethread" -description { |
| 178 | Tests run in SQLITE_CONFIG_SINGLETHREAD mode |
| 179 | } -initialize { |
| 180 | do_test mutex2-singlethread.0 { |
| 181 | catch {db close} |
| 182 | sqlite3_shutdown |
| 183 | sqlite3_config singlethread |
| 184 | } SQLITE_OK |
| 185 | } -include { |
| 186 | delete.test delete2.test insert.test rollback.test select1.test |
| 187 | select2.test trans.test update.test vacuum.test types.test |
| 188 | types2.test types3.test |
| 189 | } -shutdown { |
| 190 | do_test mutex2-X { |
| 191 | catch {db close} |
| 192 | sqlite3_shutdown |
| 193 | sqlite3_config serialized |
| 194 | } SQLITE_OK |
| 195 | } |
| 196 | |
| 197 | # Run some tests in SQLITE_CONFIG_MULTITHREAD mode. |
| 198 | # |
| 199 | run_tests "multithread" -description { |
| 200 | Tests run in SQLITE_CONFIG_MULTITHREAD mode |
| 201 | } -initialize { |
| 202 | do_test mutex2-multithread.0 { |
| 203 | catch {db close} |
| 204 | sqlite3_shutdown |
| 205 | sqlite3_config multithread |
| 206 | } SQLITE_OK |
| 207 | } -include { |
| 208 | delete.test delete2.test insert.test rollback.test select1.test |
| 209 | select2.test trans.test update.test vacuum.test types.test |
| 210 | types2.test types3.test |
| 211 | } -shutdown { |
| 212 | do_test mutex2-X { |
| 213 | catch {db close} |
| 214 | sqlite3_shutdown |
| 215 | sqlite3_config serialized |
| 216 | } SQLITE_OK |
| 217 | } |
| 218 | |
| 219 | # Run some tests using the "onefile" demo. |
| 220 | # |
| 221 | run_tests "onefile" -description { |
| 222 | Run some tests using the "test_onefile.c" demo |
| 223 | } -initialize { |
| 224 | rename sqlite3 sqlite3_onefile |
| 225 | proc sqlite3 {args} { |
| 226 | if {[string range [lindex $args 0] 0 0] ne "-"} { |
| 227 | lappend args -vfs fs |
| 228 | } |
| 229 | uplevel [concat sqlite3_onefile $args] |
| 230 | } |
| 231 | } -include { |
| 232 | conflict.test insert.test insert2.test insert3.test |
| 233 | rollback.test select1.test select2.test select3.test |
| 234 | temptable.test |
| 235 | } -shutdown { |
| 236 | rename sqlite3 {} |
| 237 | rename sqlite3_onefile sqlite3 |
| 238 | } |
| 239 | |
| 240 | # Run some tests using UTF-16 databases. |
| 241 | # |
| 242 | run_tests "utf16" -description { |
| 243 | Run tests using UTF-16 databases |
danielk1977 | 2dd6d80 | 2008-06-21 19:10:27 +0000 | [diff] [blame^] | 244 | } -presql { |
danielk1977 | 1077e3f | 2008-06-21 18:07:37 +0000 | [diff] [blame] | 245 | pragma encoding = 'UTF-16' |
| 246 | } -include { |
| 247 | alter.test alter3.test |
| 248 | auth.test bind.test blob.test capi2.test capi3.test collate1.test |
| 249 | collate2.test collate3.test collate4.test collate5.test collate6.test |
| 250 | conflict.test date.test delete.test expr.test fkey1.test func.test |
| 251 | hook.test index.test insert2.test insert.test interrupt.test in.test |
| 252 | intpkey.test ioerr.test join2.test join.test lastinsert.test |
| 253 | laststmtchanges.test limit.test lock2.test lock.test main.test |
| 254 | memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test |
| 255 | null.test progress.test quote.test rowid.test select1.test select2.test |
| 256 | select3.test select4.test select5.test select6.test sort.test |
| 257 | subselect.test tableapi.test table.test temptable.test |
| 258 | trace.test trigger1.test trigger2.test trigger3.test |
| 259 | trigger4.test types2.test types.test unique.test update.test |
| 260 | vacuum.test view.test where.test |
| 261 | } |
| 262 | |
| 263 | # Run some tests in exclusive locking mode. |
| 264 | # |
| 265 | run_tests "exclusive" -description { |
| 266 | Run tests in exclusive locking mode. |
| 267 | } -presql { |
| 268 | pragma locking_mode = 'exclusive' |
| 269 | } -include { |
| 270 | rollback.test select1.test select2.test |
| 271 | malloc.test ioerr.test |
| 272 | } |
| 273 | |
| 274 | # Run some tests in persistent journal mode. |
| 275 | # |
| 276 | run_tests "persistent_journal" -description { |
| 277 | Run tests in persistent-journal mode. |
| 278 | } -presql { |
| 279 | pragma journal_mode = persist |
| 280 | } -include { |
| 281 | delete.test delete2.test insert.test rollback.test select1.test |
| 282 | select2.test trans.test update.test vacuum.test |
| 283 | } |
| 284 | |
| 285 | # Run some error tests in persistent journal mode. |
| 286 | # |
| 287 | run_tests "persistent_journal_error" -description { |
| 288 | Run malloc.test and ioerr.test in persistent-journal mode. |
| 289 | } -presql { |
| 290 | pragma journal_mode = persist |
| 291 | } -include { |
| 292 | malloc.test ioerr.test |
| 293 | } |
| 294 | |
| 295 | # Run some tests in no journal mode. |
| 296 | # |
| 297 | run_tests "no_journal" -description { |
| 298 | Run tests in no-journal mode. |
| 299 | } -presql { |
| 300 | pragma journal_mode = persist |
| 301 | } -include { |
| 302 | delete.test delete2.test insert.test rollback.test select1.test |
| 303 | select2.test trans.test update.test vacuum.test |
| 304 | } |
| 305 | |
| 306 | # Run some error tests in no journal mode. |
| 307 | # |
| 308 | run_tests "no_journal_error" -description { |
| 309 | Run malloc.test and ioerr.test in no-journal mode. |
| 310 | } -presql { |
| 311 | pragma journal_mode = persist |
| 312 | } -include { |
| 313 | malloc.test ioerr.test |
| 314 | } |
| 315 | |
| 316 | # Run some crash-tests in autovacuum mode. |
| 317 | # |
| 318 | run_tests "autovacuum_crash" -description { |
| 319 | Run crash.test in autovacuum mode. |
| 320 | } -presql { |
| 321 | pragma auto_vacuum = 1 |
| 322 | } -include crash.test |
| 323 | |
| 324 | # Run some ioerr-tests in autovacuum mode. |
| 325 | # |
| 326 | run_tests "autovacuum_ioerr" -description { |
| 327 | Run ioerr.test in autovacuum mode. |
| 328 | } -presql { |
| 329 | pragma auto_vacuum = 1 |
| 330 | } -include ioerr.test |
| 331 | |
| 332 | # End of tests |
| 333 | ############################################################################# |
| 334 | |
| 335 | if {$::testmode eq "targets"} { puts "" ; exit } |
| 336 | |
| 337 | # Restore the [sqlite3] command. |
| 338 | # |
| 339 | rename sqlite3 {} |
| 340 | rename really_sqlite3 sqlite3 |
| 341 | |
| 342 | # Restore the [finish_test] command. |
| 343 | # |
| 344 | rename finish_test "" |
| 345 | rename really_finish_test2 finish_test |
| 346 | |
| 347 | # Restore the [do_test] command. |
| 348 | # |
| 349 | rename do_test "" |
| 350 | rename really_do_test do_test |
| 351 | |
| 352 | finish_test |
| 353 | |