summaryrefslogtreecommitdiff
path: root/bdb/test/test080.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'bdb/test/test080.tcl')
-rw-r--r--bdb/test/test080.tcl123
1 files changed, 104 insertions, 19 deletions
diff --git a/bdb/test/test080.tcl b/bdb/test/test080.tcl
index 02a6a7242cd..9f649496f68 100644
--- a/bdb/test/test080.tcl
+++ b/bdb/test/test080.tcl
@@ -1,12 +1,12 @@
# See the file LICENSE for redistribution information.
#
-# Copyright (c) 2000
+# Copyright (c) 2000-2002
# Sleepycat Software. All rights reserved.
#
-# $Id: test080.tcl,v 11.7 2000/10/19 23:15:22 ubell Exp $
+# $Id: test080.tcl,v 11.16 2002/08/08 15:38:12 bostic Exp $
#
-# DB Test 80 {access method}
-# Test of dbremove
+# TEST test080
+# TEST Test of DB->remove()
proc test080 { method {tnum 80} args } {
source ./include.tcl
@@ -15,27 +15,112 @@ proc test080 { method {tnum 80} args } {
puts "Test0$tnum: Test of DB->remove()"
+ # Determine full path
+ set curdir [pwd]
+ cd $testdir
+ set fulldir [pwd]
+ cd $curdir
+ # Test both relative and absolute path
+ set paths [list $fulldir $testdir]
+
+ # If we are using an env, then skip this test.
+ # It needs its own.
set eindex [lsearch -exact $args "-env"]
- if { $eindex != -1 } {
- puts "\tTest0$tnum: Skipping in the presence of an environment"
+ set encargs ""
+ set args [split_encargs $args encargs]
+ if { $encargs != ""} {
+ puts "Skipping test080 for security"
return
}
- cleanup $testdir NULL
-
- set testfile $testdir/test0$tnum.db
- set db [eval {berkdb_open -create -truncate -mode 0644} $omethod \
- $args {$testfile}]
- error_check_good db_open [is_valid_db $db] TRUE
- for {set i 1} { $i < 1000 } {incr i} {
- $db put $i $i
+ if { $eindex != -1 } {
+ incr eindex
+ set e [lindex $args $eindex]
+ puts "Skipping test080 for env $e"
+ return
}
- error_check_good db_close [$db close] 0
- error_check_good file_exists_before [file exists $testfile] 1
+ foreach path $paths {
+
+ set dbfile test0$tnum.db
+ set testfile $path/$dbfile
+
+ # Loop through test using the following remove options
+ # 1. no environment, not in transaction
+ # 2. with environment, not in transaction
+ # 3. rename with auto-commit
+ # 4. rename in committed transaction
+ # 5. rename in aborted transaction
+
+ foreach op "noenv env auto commit abort" {
- error_check_good db_remove [berkdb dbremove $testfile] 0
- error_check_good file_exists_after [file exists $testfile] 0
+ # Make sure we're starting with a clean slate.
+ env_cleanup $testdir
+ if { $op == "noenv" } {
+ set dbfile $testfile
+ set e NULL
+ set envargs ""
+ } else {
+ if { $op == "env" } {
+ set largs ""
+ } else {
+ set largs " -txn"
+ }
+ set e [eval {berkdb_env -create -home $path} $largs]
+ set envargs "-env $e"
+ error_check_good env_open [is_valid_env $e] TRUE
+ }
- puts "\tTest0$tnum succeeded."
+ puts "\tTest0$tnum: dbremove with $op in $path"
+ puts "\tTest0$tnum.a.1: Create file"
+ set db [eval {berkdb_open -create -mode 0644} $omethod \
+ $envargs $args {$dbfile}]
+ error_check_good db_open [is_valid_db $db] TRUE
+
+ # The nature of the key and data are unimportant;
+ # use numeric key to record-based methods don't need
+ # special treatment.
+ 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
+
+ # Use berkdb dbremove for non-transactional tests
+ # and $env dbremove for transactional tests
+ puts "\tTest0$tnum.a.2: Remove file"
+ if { $op == "noenv" || $op == "env" } {
+ error_check_good remove_$op \
+ [eval {berkdb dbremove} $envargs $dbfile] 0
+ } elseif { $op == "auto" } {
+ error_check_good remove_$op \
+ [eval {$e dbremove} -auto_commit $dbfile] 0
+ } else {
+ # $op is "abort" or "commit"
+ 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 "\tTest0$tnum.a.3: Check that file is gone"
+ # File should now be gone, except in the case of an abort.
+ 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 test0$tnum-old.db
+ set testfile $path/$dbfile
+ }
+ }
}