proc test106 { method {nitems 100} {niter 200} {tnum "106"} args } {
source ./include.tcl
global dict
global rand_init
error_check_good set_random_seed [berkdb srand $rand_init] 0
set args [convert_args $method $args]
set omethod [convert_method $method]
if { [is_btree $method] != 1 } {
puts "\tTest$tnum: Skipping for method $method."
return
}
set pgindex [lsearch -exact $args "-pagesize"]
if { $pgindex != -1 } {
puts "Test$tnum: Skipping for specific pagesizes"
return
}
set eindex [lsearch -exact $args "-env"]
if { $eindex == -1 } {
set env [berkdb_env -create -home $testdir -txn]
} else {
incr eindex
set env [lindex $args $eindex]
set txnenv [is_txnenv $env]
if { $txnenv != 1 } {
puts "Skipping test$tnum for non-txn environment."
return
}
set testdir [get_home $env]
}
cleanup $testdir $env
foreach order { ordered random } {
set nproducers 5
puts "\tTest$tnum.a: Start deadlock detector ($order)."
set dpid [exec $util_path/db_deadlock -a o -v -t 5\
-h $testdir >& $testdir/dd.out &]
puts "\tTest$tnum.b: Start consumer process ($order)."
sentinel_init
set pidlist {}
set cpid [exec $tclsh_path $test_path/wrap.tcl t106script.tcl \
$testdir/t106script.log.cons.$order.1 $testdir WAIT \
0 $nproducers $testdir/CONSUMERLOG 1 $tnum $order $niter \
$args &]
lappend pidlist $cpid
puts "\tTest$tnum.c: Initialize producers ($order)."
for { set p 1 } { $p <= $nproducers } { incr p } {
set ppid [exec $tclsh_path $test_path/wrap.tcl \
t106script.tcl \
$testdir/t106script.log.init.$order.$p \
$testdir INITIAL $nitems $nproducers \
$testdir/INITLOG.$p $p $tnum \
$order $niter $args &]
lappend pidlist $ppid
}
watch_procs $pidlist 10
sentinel_init
set pidlist {}
puts "\tTest$tnum.d: Run producers in RMW mode ($order)."
for { set p 1 } { $p <= $nproducers } { incr p } {
set ppid [exec $tclsh_path $test_path/wrap.tcl \
t106script.tcl \
$testdir/t106script.log.prod.$order.$p \
$testdir PRODUCE $nitems $nproducers \
$testdir/PRODUCERLOG.$p $p $tnum \
$order $niter $args &]
lappend pidlist $ppid
}
watch_procs $pidlist 10
tclkill $dpid
}
}