diff options
Diffstat (limited to 'bdb/test/test004.tcl')
-rw-r--r-- | bdb/test/test004.tcl | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/bdb/test/test004.tcl b/bdb/test/test004.tcl index 0b076d6cfb7..7bea6f88eca 100644 --- a/bdb/test/test004.tcl +++ b/bdb/test/test004.tcl @@ -1,14 +1,18 @@ # See the file LICENSE for redistribution information. # -# Copyright (c) 1996, 1997, 1998, 1999, 2000 +# Copyright (c) 1996-2002 # Sleepycat Software. All rights reserved. # -# $Id: test004.tcl,v 11.15 2000/08/25 14:21:54 sue Exp $ +# $Id: test004.tcl,v 11.21 2002/05/22 18:32:35 sue Exp $ # -# DB Test 4 {access method} -# Check that cursor operations work. Create a database. -# Read through the database sequentially using cursors and -# delete each element. +# TEST test004 +# TEST Small keys/medium data +# TEST Put/get per key +# TEST Sequential (cursor) get/delete +# TEST +# TEST Check that cursor operations work. Create a database. +# TEST Read through the database sequentially using cursors and +# TEST delete each element. proc test004 { method {nentries 10000} {reopen 4} {build_only 0} args} { source ./include.tcl @@ -18,33 +22,47 @@ proc test004 { method {nentries 10000} {reopen 4} {build_only 0} args} { set tnum test00$reopen - puts -nonewline "$tnum:\ - $method ($args) $nentries delete small key; medium data pairs" - if {$reopen == 5} { - puts "(with close)" - } else { - puts "" - } - # Create the database and open the dictionary + set txnenv 0 set eindex [lsearch -exact $args "-env"] # # If we are using an env, then testfile should just be the db name. # Otherwise it is the test directory and the name. if { $eindex == -1 } { - set testfile $testdir/test004.db + set testfile $testdir/$tnum.db set env NULL } else { - set testfile test004.db + set testfile $tnum.db incr eindex set env [lindex $args $eindex] + set txnenv [is_txnenv $env] + if { $txnenv == 1 } { + append args " -auto_commit " + # + # If we are using txns and running with the + # default, set the default down a bit. + # + if { $nentries == 10000 } { + set nentries 100 + } + } + set testdir [get_home $env] + } + + puts -nonewline "$tnum:\ + $method ($args) $nentries delete small key; medium data pairs" + if {$reopen == 5} { + puts "(with close)" + } else { + puts "" } + # Create the database and open the dictionary set t1 $testdir/t1 set t2 $testdir/t2 set t3 $testdir/t3 cleanup $testdir $env - set db [eval {berkdb_open -create -truncate -mode 0644} $args {$omethod $testfile}] + set db [eval {berkdb_open -create -mode 0644} $args {$omethod $testfile}] error_check_good dbopen [is_valid_db $db] TRUE set did [open $dict] @@ -71,8 +89,17 @@ proc test004 { method {nentries 10000} {reopen 4} {build_only 0} args} { set datastr [ make_data_str $str ] - set ret [eval {$db put} $txn $pflags {$key [chop_data $method $datastr]}] + if { $txnenv == 1 } { + set t [$env txn] + error_check_good txn [is_valid_txn $t $env] TRUE + set txn "-txn $t" + } + set ret [eval {$db put} $txn $pflags \ + {$key [chop_data $method $datastr]}] error_check_good put $ret 0 + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } set ret [eval {$db get} $gflags {$key}] error_check_good "$tnum:put" $ret \ @@ -93,6 +120,11 @@ proc test004 { method {nentries 10000} {reopen 4} {build_only 0} args} { # Now we will get each key from the DB and compare the results # to the original, then delete it. set outf [open $t1 w] + if { $txnenv == 1 } { + set t [$env txn] + error_check_good txn [is_valid_txn $t $env] TRUE + set txn "-txn $t" + } set c [eval {$db cursor} $txn] set count 0 @@ -117,6 +149,9 @@ proc test004 { method {nentries 10000} {reopen 4} {build_only 0} args} { } close $outf error_check_good curs_close [$c close] 0 + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } # Now compare the keys to see if they match the dictionary if { [is_record_based $method] == 1 } { |