Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: third_party/sqlite/src/test/malloc_common.tcl

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2007 May 05 1 # 2007 May 05
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 -injectuninstall cantopen_injectuninstall \ 86 -injectuninstall cantopen_injectuninstall \
87 ] 87 ]
88 set FAULTSIM(cantopen-persistent) [list \ 88 set FAULTSIM(cantopen-persistent) [list \
89 -injectinstall cantopen_injectinstall \ 89 -injectinstall cantopen_injectinstall \
90 -injectstart {cantopen_injectstart 1} \ 90 -injectstart {cantopen_injectstart 1} \
91 -injectstop cantopen_injectstop \ 91 -injectstop cantopen_injectstop \
92 -injecterrlist {{1 {unable to open database file}}} \ 92 -injecterrlist {{1 {unable to open database file}}} \
93 -injectuninstall cantopen_injectuninstall \ 93 -injectuninstall cantopen_injectuninstall \
94 ] 94 ]
95 95
96 set FAULTSIM(interrupt) [list \
97 -injectinstall interrupt_injectinstall \
98 -injectstart interrupt_injectstart \
99 -injectstop interrupt_injectstop \
100 -injecterrlist {{1 interrupted} {1 interrupt}} \
101 -injectuninstall interrupt_injectuninstall \
102 ]
103
96 104
97 105
98 #-------------------------------------------------------------------------- 106 #--------------------------------------------------------------------------
99 # Usage do_faultsim_test NAME ?OPTIONS...? 107 # Usage do_faultsim_test NAME ?OPTIONS...?
100 # 108 #
101 # -faults List of fault types to simulate. 109 # -faults List of fault types to simulate.
102 # 110 #
103 # -prep Script to execute before -body. 111 # -prep Script to execute before -body.
104 # 112 #
105 # -body Script to execute (with fault injection). 113 # -body Script to execute (with fault injection).
106 # 114 #
107 # -test Script to execute after -body. 115 # -test Script to execute after -body.
108 # 116 #
109 # -install Script to execute after faultsim -injectinstall 117 # -install Script to execute after faultsim -injectinstall
110 # 118 #
111 # -uninstall Script to execute after faultsim -uninjectinstall 119 # -uninstall Script to execute after faultsim -uninjectinstall
112 # 120 #
113 proc do_faultsim_test {name args} { 121 proc do_faultsim_test {name args} {
114 global FAULTSIM 122 global FAULTSIM
115 123
116 set DEFAULT(-faults) [array names FAULTSIM] 124 foreach n [array names FAULTSIM] {
125 if {$n != "interrupt"} {lappend DEFAULT(-faults) $n}
126 }
117 set DEFAULT(-prep) "" 127 set DEFAULT(-prep) ""
118 set DEFAULT(-body) "" 128 set DEFAULT(-body) ""
119 set DEFAULT(-test) "" 129 set DEFAULT(-test) ""
120 set DEFAULT(-install) "" 130 set DEFAULT(-install) ""
121 set DEFAULT(-uninstall) "" 131 set DEFAULT(-uninstall) ""
122 132
123 fix_testname name 133 fix_testname name
124 134
125 array set O [array get DEFAULT] 135 array set O [array get DEFAULT]
126 array set O $args 136 array set O $args
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 catch {db2 close} 258 catch {db2 close}
249 shmfault delete 259 shmfault delete
250 } 260 }
251 proc cantopen_injectstart {persist iFail} { 261 proc cantopen_injectstart {persist iFail} {
252 shmfault cantopen $iFail $persist 262 shmfault cantopen $iFail $persist
253 } 263 }
254 proc cantopen_injectstop {} { 264 proc cantopen_injectstop {} {
255 shmfault cantopen 265 shmfault cantopen
256 } 266 }
257 267
268 # The following procs are used as [do_one_faultsim_test] callbacks
269 # when injecting SQLITE_INTERRUPT error faults into test cases.
270 #
271 proc interrupt_injectinstall {} {
272 }
273 proc interrupt_injectuninstall {} {
274 }
275 proc interrupt_injectstart {iFail} {
276 set ::sqlite_interrupt_count $iFail
277 }
278 proc interrupt_injectstop {} {
279 set res [expr $::sqlite_interrupt_count<=0]
280 set ::sqlite_interrupt_count 0
281 set res
282 }
283
258 # This command is not called directly. It is used by the 284 # This command is not called directly. It is used by the
259 # [faultsim_test_result] command created by [do_faultsim_test] and used 285 # [faultsim_test_result] command created by [do_faultsim_test] and used
260 # by -test scripts. 286 # by -test scripts.
261 # 287 #
262 proc faultsim_test_result_int {args} { 288 proc faultsim_test_result_int {args} {
263 upvar testrc testrc testresult testresult testnfail testnfail 289 upvar testrc testrc testresult testresult testnfail testnfail
264 set t [list $testrc $testresult] 290 set t [list $testrc $testresult]
265 set r $args 291 set r $args
266 if { ($testnfail==0 && $t != [lindex $r 0]) || [lsearch $r $t]<0 } { 292 if { ($testnfail==0 && $t != [lindex $r 0]) || [lsearch $r $t]<0 } {
267 error "nfail=$testnfail rc=$testrc result=$testresult" 293 error "nfail=$testnfail rc=$testrc result=$testresult list=$r"
268 } 294 }
269 } 295 }
270 296
271 #-------------------------------------------------------------------------- 297 #--------------------------------------------------------------------------
272 # Usage do_one_faultsim_test NAME ?OPTIONS...? 298 # Usage do_one_faultsim_test NAME ?OPTIONS...?
273 # 299 #
274 # The first argument, <test number>, is used as a prefix of the test names 300 # The first argument, <test number>, is used as a prefix of the test names
275 # taken by tests executed by this command. Options are as follows. All 301 # taken by tests executed by this command. Options are as follows. All
276 # options take a single argument. 302 # options take a single argument.
277 # 303 #
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 # Nth call to sqliteMalloc() is made to fail, where N is increased 402 # Nth call to sqliteMalloc() is made to fail, where N is increased
377 # each time the loop runs starting from 1. When all commands execute 403 # each time the loop runs starting from 1. When all commands execute
378 # successfully, the loop ends. 404 # successfully, the loop ends.
379 # 405 #
380 proc do_malloc_test {tn args} { 406 proc do_malloc_test {tn args} {
381 array unset ::mallocopts 407 array unset ::mallocopts
382 array set ::mallocopts $args 408 array set ::mallocopts $args
383 409
384 if {[string is integer $tn]} { 410 if {[string is integer $tn]} {
385 set tn malloc-$tn 411 set tn malloc-$tn
412 catch { set tn $::testprefix-$tn }
386 } 413 }
387 if {[info exists ::mallocopts(-start)]} { 414 if {[info exists ::mallocopts(-start)]} {
388 set start $::mallocopts(-start) 415 set start $::mallocopts(-start)
389 } else { 416 } else {
390 set start 0 417 set start 0
391 } 418 }
392 if {[info exists ::mallocopts(-end)]} { 419 if {[info exists ::mallocopts(-end)]} {
393 set end $::mallocopts(-end) 420 set end $::mallocopts(-end)
394 } else { 421 } else {
395 set end 50000 422 set end 50000
396 } 423 }
397 save_prng_state 424 save_prng_state
398 425
399 foreach ::iRepeat {0 10000000} { 426 foreach ::iRepeat {0 10000000} {
400 set ::go 1 427 set ::go 1
401 for {set ::n $start} {$::go && $::n <= $end} {incr ::n} { 428 for {set ::n $start} {$::go && $::n <= $end} {incr ::n} {
402 429
403 # If $::iRepeat is 0, then the malloc() failure is transient - it 430 # If $::iRepeat is 0, then the malloc() failure is transient - it
404 # fails and then subsequent calls succeed. If $::iRepeat is 1, 431 # fails and then subsequent calls succeed. If $::iRepeat is 1,
405 # then the failure is persistent - once malloc() fails it keeps 432 # then the failure is persistent - once malloc() fails it keeps
406 # failing. 433 # failing.
407 # 434 #
408 set zRepeat "transient" 435 set zRepeat "transient"
409 if {$::iRepeat} {set zRepeat "persistent"} 436 if {$::iRepeat} {set zRepeat "persistent"}
410 restore_prng_state 437 restore_prng_state
411 foreach file [glob -nocomplain test.db-mj*] {file delete -force $file} 438 foreach file [glob -nocomplain test.db-mj*] {forcedelete $file}
412 439
413 do_test ${tn}.${zRepeat}.${::n} { 440 do_test ${tn}.${zRepeat}.${::n} {
414 441
415 # Remove all traces of database files test.db and test2.db 442 # Remove all traces of database files test.db and test2.db
416 # from the file-system. Then open (empty database) "test.db" 443 # from the file-system. Then open (empty database) "test.db"
417 # with the handle [db]. 444 # with the handle [db].
418 # 445 #
419 catch {db close} 446 catch {db close}
420 catch {db2 close} 447 catch {db2 close}
421 forcedelete test.db 448 forcedelete test.db
422 forcedelete test.db-journal 449 forcedelete test.db-journal
423 forcedelete test.db-wal 450 forcedelete test.db-wal
424 forcedelete test2.db 451 forcedelete test2.db
425 forcedelete test2.db-journal 452 forcedelete test2.db-journal
426 forcedelete test2.db-wal 453 forcedelete test2.db-wal
427 if {[info exists ::mallocopts(-testdb)]} { 454 if {[info exists ::mallocopts(-testdb)]} {
428 file copy $::mallocopts(-testdb) test.db 455 copy_file $::mallocopts(-testdb) test.db
429 } 456 }
430 catch { sqlite3 db test.db } 457 catch { sqlite3 db test.db }
431 if {[info commands db] ne ""} { 458 if {[info commands db] ne ""} {
432 sqlite3_extended_result_codes db 1 459 sqlite3_extended_result_codes db 1
433 } 460 }
434 sqlite3_db_config_lookaside db 0 0 0 461 sqlite3_db_config_lookaside db 0 0 0
435 462
436 # Execute any -tclprep and -sqlprep scripts. 463 # Execute any -tclprep and -sqlprep scripts.
437 # 464 #
438 if {[info exists ::mallocopts(-tclprep)]} { 465 if {[info exists ::mallocopts(-tclprep)]} {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 if {[lsearch $answers $res]>=0} { 678 if {[lsearch $answers $res]>=0} {
652 set res $str 679 set res $str
653 } 680 }
654 do_test $name.$zName.$iFail [list set {} $res] $str 681 do_test $name.$zName.$iFail [list set {} $res] $str
655 set cksum2 [db one $cksumsql] 682 set cksum2 [db one $cksumsql]
656 if {$cksum1 != $cksum2} return 683 if {$cksum1 != $cksum2} return
657 } 684 }
658 } 685 }
659 } 686 }
660 } 687 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698