diff options
Diffstat (limited to 'bdb/test/test078.tcl')
-rw-r--r-- | bdb/test/test078.tcl | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/bdb/test/test078.tcl b/bdb/test/test078.tcl index 9642096faf9..45a1d46466e 100644 --- a/bdb/test/test078.tcl +++ b/bdb/test/test078.tcl @@ -1,11 +1,12 @@ # See the file LICENSE for redistribution information. # -# Copyright (c) 2000 +# Copyright (c) 2000-2002 # Sleepycat Software. All rights reserved. # -# $Id: test078.tcl,v 1.9 2000/12/11 17:24:55 sue Exp $ +# $Id: test078.tcl,v 1.18 2002/06/20 19:01:02 sue Exp $ # -# DB Test 78: Test of DBC->c_count(). [#303] +# TEST test078 +# TEST Test of DBC->c_count(). [#303] proc test078 { method { nkeys 100 } { pagesize 512 } { tnum 78 } args } { source ./include.tcl global alphabet rand_init @@ -17,14 +18,23 @@ proc test078 { method { nkeys 100 } { pagesize 512 } { tnum 78 } args } { berkdb srand $rand_init + set txnenv 0 set eindex [lsearch -exact $args "-env"] + if { $eindex != -1 } { + incr eindex + } + if { $eindex == -1 } { - set testfile $testdir/test0$tnum.db + set testfile $testdir/test0$tnum-a.db set env NULL } else { - set testfile test0$tnum.db - incr eindex + set testfile test0$tnum-a.db set env [lindex $args $eindex] + set txnenv [is_txnenv $env] + if { $txnenv == 1 } { + append args " -auto_commit " + } + set testdir [get_home $env] } cleanup $testdir $env @@ -35,13 +45,23 @@ proc test078 { method { nkeys 100 } { pagesize 512 } { tnum 78 } args } { return } - set db [eval {berkdb_open -create -truncate -mode 0644\ + set db [eval {berkdb_open -create -mode 0644\ -pagesize $pagesize} $omethod $args {$testfile}] error_check_good db_open [is_valid_db $db] TRUE + set txn "" for { set i 1 } { $i <= $nkeys } { incr i } { - error_check_good put.a($i) [$db put $i\ - [pad_data $method $alphabet$i]] 0 + 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 {$i\ + [pad_data $method $alphabet$i]}] + error_check_good put.a($i) $ret 0 + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } error_check_good count.a [$db count $i] 1 } error_check_good db_close.a [$db close] 0 @@ -56,18 +76,38 @@ proc test078 { method { nkeys 100 } { pagesize 512 } { tnum 78 } args } { set letter [lindex $tuple 0] set dupopt [lindex $tuple 2] + if { $eindex == -1 } { + set testfile $testdir/test0$tnum-b.db + set env NULL + } else { + set testfile test0$tnum-b.db + set env [lindex $args $eindex] + set testdir [get_home $env] + } + cleanup $testdir $env + puts "\tTest0$tnum.$letter: Duplicates ([lindex $tuple 1])." puts "\t\tTest0$tnum.$letter.1: Populating database." - set db [eval {berkdb_open -create -truncate -mode 0644\ + set db [eval {berkdb_open -create -mode 0644\ -pagesize $pagesize} $dupopt $omethod $args {$testfile}] error_check_good db_open [is_valid_db $db] TRUE for { set i 1 } { $i <= $nkeys } { incr i } { for { set j 0 } { $j < $i } { incr j } { - error_check_good put.$letter,$i [$db put $i\ - [pad_data $method $j$alphabet]] 0 + 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 {$i\ + [pad_data $method $j$alphabet]}] + error_check_good put.$letter,$i $ret 0 + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } } } |