mariadb/bdb/test/dead001.tcl

89 lines
2.4 KiB
Tcl
Raw Normal View History

2001-03-05 01:42:05 +01:00
# See the file LICENSE for redistribution information.
#
2002-10-30 12:57:05 +01:00
# Copyright (c) 1996-2002
2001-03-05 01:42:05 +01:00
# Sleepycat Software. All rights reserved.
#
2002-10-30 12:57:05 +01:00
# $Id: dead001.tcl,v 11.33 2002/09/05 17:23:05 sandstro Exp $
2001-03-05 01:42:05 +01:00
#
2002-10-30 12:57:05 +01:00
# TEST dead001
# TEST Use two different configurations to test deadlock detection among a
# TEST variable number of processes. One configuration has the processes
# TEST deadlocked in a ring. The other has the processes all deadlocked on
# TEST a single resource.
proc dead001 { { procs "2 4 10" } {tests "ring clump" } \
{timeout 0} {tnum "001"} } {
2001-03-05 01:42:05 +01:00
source ./include.tcl
2002-10-30 12:57:05 +01:00
global lock_curid
global lock_maxid
2001-03-05 01:42:05 +01:00
2002-10-30 12:57:05 +01:00
puts "Dead$tnum: Deadlock detector tests"
2001-03-05 01:42:05 +01:00
env_cleanup $testdir
# Create the environment.
2002-10-30 12:57:05 +01:00
puts "\tDead$tnum.a: creating environment"
set env [berkdb_env -create \
-mode 0644 -lock -txn_timeout $timeout -home $testdir]
2001-03-05 01:42:05 +01:00
error_check_good lock_env:open [is_valid_env $env] TRUE
foreach t $tests {
foreach n $procs {
2002-10-30 12:57:05 +01:00
if {$timeout == 0 } {
set dpid [exec $util_path/db_deadlock -vw \
-h $testdir >& $testdir/dd.out &]
} else {
set dpid [exec $util_path/db_deadlock -vw \
-ae -h $testdir >& $testdir/dd.out &]
}
2001-03-05 01:42:05 +01:00
2002-10-30 12:57:05 +01:00
sentinel_init
set pidlist ""
set ret [$env lock_id_set $lock_curid $lock_maxid]
error_check_good lock_id_set $ret 0
2001-03-05 01:42:05 +01:00
# Fire off the tests
2002-10-30 12:57:05 +01:00
puts "\tDead$tnum: $n procs of test $t"
2001-03-05 01:42:05 +01:00
for { set i 0 } { $i < $n } { incr i } {
2002-10-30 12:57:05 +01:00
set locker [$env lock_id]
2001-03-05 01:42:05 +01:00
puts "$tclsh_path $test_path/wrap.tcl \
2002-10-30 12:57:05 +01:00
$testdir/dead$tnum.log.$i \
ddscript.tcl $testdir $t $locker $i $n"
2001-03-05 01:42:05 +01:00
set p [exec $tclsh_path \
$test_path/wrap.tcl \
2002-10-30 12:57:05 +01:00
ddscript.tcl $testdir/dead$tnum.log.$i \
$testdir $t $locker $i $n &]
2001-03-05 01:42:05 +01:00
lappend pidlist $p
}
2002-10-30 12:57:05 +01:00
watch_procs $pidlist 5
2001-03-05 01:42:05 +01:00
# Now check output
set dead 0
set clean 0
set other 0
for { set i 0 } { $i < $n } { incr i } {
2002-10-30 12:57:05 +01:00
set did [open $testdir/dead$tnum.log.$i]
2001-03-05 01:42:05 +01:00
while { [gets $did val] != -1 } {
switch $val {
DEADLOCK { incr dead }
1 { incr clean }
default { incr other }
}
}
close $did
}
2002-10-30 12:57:05 +01:00
tclkill $dpid
2001-03-05 01:42:05 +01:00
puts "dead check..."
2002-10-30 12:57:05 +01:00
dead_check $t $n $timeout $dead $clean $other
2001-03-05 01:42:05 +01:00
}
}
# Windows needs files closed before deleting files, so pause a little
2002-10-30 12:57:05 +01:00
tclsleep 3
2001-03-05 01:42:05 +01:00
fileremove -f $testdir/dd.out
# Remove log files
for { set i 0 } { $i < $n } { incr i } {
2002-10-30 12:57:05 +01:00
fileremove -f $testdir/dead$tnum.log.$i
2001-03-05 01:42:05 +01:00
}
2002-10-30 12:57:05 +01:00
error_check_good lock_env:close [$env close] 0
2001-03-05 01:42:05 +01:00
}