proc dead004 { {tnum "004"} } {
source ./include.tcl
global lock_curid
global lock_maxid
foreach a { o y } {
puts "Dead$tnum: Deadlock detector test -a $a"
env_cleanup $testdir
puts "\tDead$tnum.a: creating environment"
set env [berkdb_env -create -mode 0644 -lock -home $testdir]
error_check_good lock_env:open [is_valid_env $env] TRUE
set dpid [exec $util_path/db_deadlock -v -t 5 -a $a \
-h $testdir >& $testdir/dd.out &]
set procs 6
foreach n $procs {
sentinel_init
set pidlist ""
set ret [$env lock_id_set $lock_curid $lock_maxid]
error_check_good lock_id_set $ret 0
puts "\tDead$tnum: $n procs"
for { set i 0 } { $i < $n } { incr i } {
set locker [$env lock_id]
puts "$tclsh_path $test_path/wrap.tcl \
$testdir/dead$tnum.log.$i \
ddoyscript.tcl $testdir $locker $n $a $i"
set p [exec $tclsh_path \
$test_path/wrap.tcl \
ddoyscript.tcl $testdir/dead$tnum.log.$i \
$testdir $locker $n $a $i &]
lappend pidlist $p
}
watch_procs $pidlist 5
}
set dead 0
set clean 0
set other 0
for { set i 0 } { $i < $n } { incr i } {
set did [open $testdir/dead$tnum.log.$i]
while { [gets $did val] != -1 } {
switch $val {
DEADLOCK { incr dead }
1 { incr clean }
default { incr other }
}
}
close $did
}
tclkill $dpid
puts "\tDead$tnum: dead check..."
dead_check oldyoung $n 0 $dead $clean $other
set did [open $testdir/dead$tnum.log.0]
error_check_bad file:young [gets $did val] -1
error_check_good read:young $val 1
close $did
set did [open $testdir/dead$tnum.log.[expr $procs - 1]]
error_check_bad file:old [gets $did val] -1
error_check_good read:old $val 1
close $did
tclsleep 2
fileremove -f $testdir/dd.out
for { set i 0 } { $i < $n } { incr i } {
fileremove -f $testdir/dead$tnum.log.$i
}
error_check_good lock_env:close [$env close] 0
}
}