summaryrefslogtreecommitdiff
path: root/bdb/test/test014.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'bdb/test/test014.tcl')
-rw-r--r--bdb/test/test014.tcl77
1 files changed, 63 insertions, 14 deletions
diff --git a/bdb/test/test014.tcl b/bdb/test/test014.tcl
index 3ad5335dd0a..00d69d3352e 100644
--- a/bdb/test/test014.tcl
+++ b/bdb/test/test014.tcl
@@ -1,17 +1,20 @@
# See the file LICENSE for redistribution information.
#
-# Copyright (c) 1996, 1997, 1998, 1999, 2000
+# Copyright (c) 1996-2002
# Sleepycat Software. All rights reserved.
#
-# $Id: test014.tcl,v 11.19 2000/08/25 14:21:54 sue Exp $
+# $Id: test014.tcl,v 11.24 2002/05/22 15:42:46 sue Exp $
#
-# DB Test 14 {access method}
-#
-# Partial put test, small data, replacing with same size. The data set
-# consists of the first nentries of the dictionary. We will insert them
-# (and retrieve them) as we do in test 1 (equal key/data pairs). Then
-# we'll try to perform partial puts of some characters at the beginning,
-# some at the end, and some at the middle.
+# TEST test014
+# TEST Exercise partial puts on short data
+# TEST Run 5 combinations of numbers of characters to replace,
+# TEST and number of times to increase the size by.
+# TEST
+# TEST Partial put test, small data, replacing with same size. The data set
+# TEST consists of the first nentries of the dictionary. We will insert them
+# TEST (and retrieve them) as we do in test 1 (equal key/data pairs). Then
+# TEST we'll try to perform partial puts of some characters at the beginning,
+# TEST some at the end, and some at the middle.
proc test014 { method {nentries 10000} args } {
set fixed 0
set args [convert_args $method $args]
@@ -71,6 +74,7 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
}
# 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.
@@ -82,6 +86,18 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
set testfile test014.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]
}
set t1 $testdir/t1
set t2 $testdir/t2
@@ -89,7 +105,7 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
cleanup $testdir $env
set db [eval {berkdb_open \
- -create -truncate -mode 0644} $args {$omethod $testfile}]
+ -create -mode 0644} $args {$omethod $testfile}]
error_check_good dbopen [is_valid_db $db] TRUE
set gflags ""
@@ -117,7 +133,15 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
global dvals
# initial put
- set ret [$db put $key $str]
+ 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 {$key $str}]
+ if { $txnenv == 1 } {
+ error_check_good txn [$t commit] 0
+ }
error_check_good dbput $ret 0
set offset [string length $str]
@@ -133,11 +157,28 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
a[set offset]x[set chars]a[set increase] \
$str $data]
set offset [expr $offset + $chars]
- set ret [$db put -partial [list $offset 0] $key $data]
+ 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 -partial [list $offset 0]} \
+ $txn {$key $data}]
error_check_good dbput:post $ret 0
+ if { $txnenv == 1 } {
+ error_check_good txn [$t commit] 0
+ }
} else {
+ if { $txnenv == 1 } {
+ set t [$env txn]
+ error_check_good txn [is_valid_txn $t $env] TRUE
+ set txn "-txn $t"
+ }
partial_put $method $db $txn \
$gflags $key $str $chars $increase
+ if { $txnenv == 1 } {
+ error_check_good txn [$t commit] 0
+ }
}
incr count
}
@@ -145,7 +186,15 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
# Now make sure that everything looks OK
puts "\tTest014.b: check entire file contents"
+ if { $txnenv == 1 } {
+ set t [$env txn]
+ error_check_good txn [is_valid_txn $t $env] TRUE
+ set txn "-txn $t"
+ }
dump_file $db $txn $t1 test014.check
+ if { $txnenv == 1 } {
+ error_check_good txn [$t commit] 0
+ }
error_check_good db_close [$db close] 0
# Now compare the keys to see if they match the dictionary (or ints)
@@ -168,7 +217,7 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
puts "\tTest014.c: close, open, and dump file"
# Now, reopen the file and run the last test again.
- open_and_dump_file $testfile $env $txn \
+ open_and_dump_file $testfile $env \
$t1 test014.check dump_file_direction "-first" "-next"
if { [string compare $omethod "-recno"] != 0 } {
@@ -182,7 +231,7 @@ proc test014_body { method flagp chars increase {nentries 10000} args } {
# Now, reopen the file and run the last test again in the
# reverse direction.
puts "\tTest014.d: close, open, and dump file in reverse direction"
- open_and_dump_file $testfile $env $txn $t1 \
+ open_and_dump_file $testfile $env $t1 \
test014.check dump_file_direction "-last" "-prev"
if { [string compare $omethod "-recno"] != 0 } {