proc test080 { method {tnum "080"} args } {
source ./include.tcl
set args [convert_args $method $args]
set omethod [convert_method $method]
puts "Test$tnum: Test of DB->remove()"
set curdir [pwd]
cd $testdir
set fulldir [pwd]
cd $curdir
set paths [list $fulldir $testdir]
set encrypt 0
set encargs ""
set args [split_encargs $args encargs]
set eindex [lsearch -exact $args "-env"]
if { $eindex != -1 } {
incr eindex
set e [lindex $args $eindex]
puts "Skipping test080 for env $e"
return
}
foreach path $paths {
set dbfile test$tnum.db
set testfile $path/$dbfile
set eargs $encargs
foreach op "noenv env auto commit abort" {
env_cleanup $testdir
if { $op == "noenv" } {
set dbfile $testfile
set e NULL
set envargs ""
} else {
if { $op == "env" } {
set largs ""
} else {
set largs " -txn"
}
if { $encargs != "" } {
set eargs " -encrypt "
}
set e [eval {berkdb_env -create -home $path} \
$encargs $largs]
set envargs "-env $e"
error_check_good env_open [is_valid_env $e] TRUE
}
puts "\tTest$tnum: dbremove with $op in $path"
puts "\tTest$tnum.a.1: Create file"
set db [eval {berkdb_open -create -mode 0644} \
$omethod $envargs $eargs $args {$dbfile}]
error_check_good db_open [is_valid_db $db] TRUE
set key 1
set data [pad_data $method data]
error_check_good dbput [$db put $key $data] 0
error_check_good dbclose [$db close] 0
error_check_good file_exists_before \
[file exists $testfile] 1
puts "\tTest$tnum.a.2: Remove file"
if { $op == "noenv" || $op == "env" } {
error_check_good remove_$op [eval \
{berkdb dbremove} $eargs $envargs $dbfile] 0
} elseif { $op == "auto" } {
error_check_good remove_$op \
[eval {$e dbremove} -auto_commit $dbfile] 0
} else {
set txn [$e txn]
error_check_good remove_$op \
[eval {$e dbremove} -txn $txn $dbfile] 0
error_check_good txn_$op [$txn $op] 0
}
puts "\tTest$tnum.a.3: Check that file is gone"
if { $op != "abort" } {
error_check_good exists_after \
[file exists $testfile] 0
} else {
error_check_good exists_after \
[file exists $testfile] 1
}
if { $e != "NULL" } {
error_check_good env_close [$e close] 0
}
set dbfile test$tnum-old.db
set testfile $path/$dbfile
}
}
}