mariadb/bdb/test/dead003.tcl

99 lines
2.5 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: dead003.tcl,v 1.17 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 dead003
# TEST
# TEST Same test as dead002, but explicitly specify DB_LOCK_OLDEST and
# TEST DB_LOCK_YOUNGEST. Verify the correct lock was aborted/granted.
2001-03-05 01:42:05 +01:00
proc dead003 { { procs "2 4 10" } {tests "ring clump" } } {
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
set detects { oldest youngest }
puts "Dead003: Deadlock detector tests: $detects"
# Create the environment.
foreach d $detects {
env_cleanup $testdir
puts "\tDead003.a: creating environment for $d"
2002-10-30 12:57:05 +01:00
set env [berkdb_env \
2001-03-05 01:42:05 +01:00
-create -mode 0644 -home $testdir -lock -lock_detect $d]
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
set pidlist ""
sentinel_init
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
puts "\tDead003: $n procs of test $t"
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/ddscript.tcl $testdir \
2002-10-30 12:57:05 +01:00
$t $locker $i $n >& \
2001-03-05 01:42:05 +01:00
$testdir/dead003.log.$i"
set p [exec $tclsh_path \
$test_path/wrap.tcl \
ddscript.tcl \
$testdir/dead003.log.$i $testdir \
2002-10-30 12:57:05 +01:00
$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 } {
set did [open $testdir/dead003.log.$i]
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
dead_check $t $n 0 $dead $clean $other
2001-03-05 01:42:05 +01:00
#
# If we get here we know we have the
# correct number of dead/clean procs, as
# checked by dead_check above. Now verify
# that the right process was the one.
puts "\tDead003: Verify $d locks were aborted"
set l ""
if { $d == "oldest" } {
set l [expr $n - 1]
}
if { $d == "youngest" } {
set l 0
}
set did [open $testdir/dead003.log.$l]
while { [gets $did val] != -1 } {
error_check_good check_abort \
$val 1
}
close $did
}
}
fileremove -f $testdir/dd.out
# Remove log files
for { set i 0 } { $i < $n } { incr i } {
fileremove -f $testdir/dead003.log.$i
}
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
}
}