proc fop006 { } {
source ./include.tcl
env_cleanup $testdir
puts "\nFop006: File system ops in multiple transactions"
set exists {a b}
set noexist {foo bar}
set open {}
set cases {}
set ops {open open_create open_excl rename remove truncate}
foreach retval { 0 "file exists" "no such file" } {
foreach end1 {abort commit} {
foreach op1 $ops {
foreach op2 $ops {
append cases " " [create_tests\
$op1 $op2 $exists $noexist\
$open $retval $end1]
}
}
}
}
foreach retval { 0 "file exists" "no such file" } {
foreach op1 { rename remove open open_excl } {
foreach op2 $ops {
append cases " " [create_badtests $op1 $op2 \
$exists $noexist $open $retval $end1]
}
}
}
set testid 0
foreach case $cases {
incr testid
set op1 [lindex [lindex $case 0] 0]
set args1 [lindex [lindex $case 0] 1]
set res1 [lindex [lindex $case 0] 2]
set end1 [lindex [lindex $case 0] 3]
set op2 [lindex [lindex $case 1] 0]
set args2 [lindex [lindex $case 1] 1]
set res2 [lindex [lindex $case 1] 2]
puts "\tFop006.$testid: $op1 ($args1) $res1 $end1;\
$op2 ($args2) $res2."
foreach end2 { abort commit } {
set env [berkdb_env -create -home $testdir -txn]
error_check_good is_valid_env [is_valid_env $env] TRUE
set db [berkdb_open\
-create -btree -env $env -auto_commit a.db]
error_check_good db_open [is_valid_db $db] TRUE
error_check_good db_put [$db put -auto_commit 1 a] 0
error_check_good db_close [$db close] 0
set db [berkdb_open\
-create -btree -env $env -auto_commit b.db]
error_check_good db_open [is_valid_db $db] TRUE
error_check_good db_put [$db put -auto_commit 1 a] 0
error_check_good db_close [$db close] 0
set txn1 [$env txn]
error_check_good \
txn_begin [is_valid_txn $txn1 $env] TRUE
set result1 [do_op $op1 $args1 $txn1 $env]
if {$res1 == 0} {
error_check_good \
op1_should_succeed $result1 $res1
} else {
set error [extract_error $result1]
error_check_good op1_wrong_failure $error $res1
}
set pid [exec $tclsh_path $test_path/wrap.tcl \
fopscript.tcl $testdir/fop006.log \
$op2 $end2 $res2 $args2 &]
error_check_good txn1_$end1 [$txn1 $end1] 0
set handles [berkdb handles]
foreach handle $handles {
if {[string range $handle 0 1] == "db" } {
error_check_good \
db_close [$handle close] 0
}
}
watch_procs $pid 1 60 1
error_check_good env_close [$env close] 0
error_check_good \
envremove [berkdb envremove -home $testdir] 0
env_cleanup $testdir
}
}
}