summaryrefslogtreecommitdiff
path: root/db/test/test055.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'db/test/test055.tcl')
-rw-r--r--db/test/test055.tcl55
1 files changed, 39 insertions, 16 deletions
diff --git a/db/test/test055.tcl b/db/test/test055.tcl
index fc5ce4e98..d2c24e787 100644
--- a/db/test/test055.tcl
+++ b/db/test/test055.tcl
@@ -1,16 +1,17 @@
# See the file LICENSE for redistribution information.
#
-# Copyright (c) 1996, 1997, 1998, 1999, 2000
+# Copyright (c) 1996-2003
# Sleepycat Software. All rights reserved.
#
-# $Id: test055.tcl,v 11.11 2000/08/25 14:21:57 sue Exp $
+# $Id: test055.tcl,v 11.17 2003/01/08 05:53:58 bostic Exp $
#
-# Test055:
-# This test checks basic cursor operations.
-# There are N different scenarios to tests:
-# 1. (no dups) Set cursor, retrieve current.
-# 2. (no dups) Set cursor, retrieve next.
-# 3. (no dups) Set cursor, retrieve prev.
+# TEST test055
+# TEST Basic cursor operations.
+# TEST This test checks basic cursor operations.
+# TEST There are N different scenarios to tests:
+# TEST 1. (no dups) Set cursor, retrieve current.
+# TEST 2. (no dups) Set cursor, retrieve next.
+# TEST 3. (no dups) Set cursor, retrieve prev.
proc test055 { method args } {
global errorInfo
source ./include.tcl
@@ -21,6 +22,7 @@ proc test055 { method args } {
puts "Test055: $method interspersed cursor and normal operations"
# 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.
@@ -32,6 +34,11 @@ proc test055 { method args } {
set testfile test055.db
incr eindex
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
@@ -39,28 +46,41 @@ proc test055 { method args } {
set txn ""
puts "\tTest055.a: No duplicates"
- set db [eval {berkdb_open -create -truncate -mode 0644 $omethod } \
+ set db [eval {berkdb_open -create -mode 0644 $omethod } \
$args {$testfile}]
error_check_good db_open:nodup [is_valid_db $db] TRUE
- set curs [eval {$db cursor} $txn]
- error_check_good curs_open:nodup [is_substr $curs $db] 1
-
# Put three keys in the database
for { set key 1 } { $key <= 3 } {incr key} {
+ if { $txnenv == 1 } {
+ set t [$env txn]
+ error_check_good txn [is_valid_txn $t $env] TRUE
+ set txn "-txn $t"
+ }
set r [eval {$db put} $txn $flags {$key datum$key}]
error_check_good put $r 0
+ if { $txnenv == 1 } {
+ error_check_good txn [$t commit] 0
+ }
}
# Retrieve keys sequentially so we can figure out their order
set i 1
+ if { $txnenv == 1 } {
+ set t [$env txn]
+ error_check_good txn [is_valid_txn $t $env] TRUE
+ set txn "-txn $t"
+ }
+ set curs [eval {$db cursor} $txn]
+ error_check_good curs_open:nodup [is_valid_cursor $curs $db] TRUE
+
for {set d [$curs get -first] } { [llength $d] != 0 } {\
set d [$curs get -next] } {
set key_set($i) [lindex [lindex $d 0] 0]
incr i
}
- # TEST CASE 1
+ # Test case #1.
puts "\tTest055.a1: Set cursor, retrieve current"
# Now set the cursor on the middle on.
@@ -81,7 +101,7 @@ proc test055 { method args } {
error_check_good \
curs_get:DB_CURRENT:data $d [pad_data $method datum$key_set(2)]
- # TEST CASE 2
+ # Test case #2.
puts "\tTest055.a2: Set cursor, retrieve previous"
set r [$curs get -prev]
error_check_bad cursor_get:DB_PREV [llength $r] 0
@@ -91,10 +111,10 @@ proc test055 { method args } {
error_check_good \
curs_get:DB_PREV:data $d [pad_data $method datum$key_set(1)]
- #TEST CASE 3
+ # Test case #3.
puts "\tTest055.a2: Set cursor, retrieve next"
- # Now set the cursor on the middle on.
+ # Now set the cursor on the middle one.
set r [$curs get -set $key_set(2)]
error_check_bad cursor_get:DB_SET [llength $r] 0
set k [lindex [lindex $r 0] 0]
@@ -114,5 +134,8 @@ proc test055 { method args } {
# Close cursor and database.
error_check_good curs_close [$curs close] 0
+ if { $txnenv == 1 } {
+ error_check_good txn [$t commit] 0
+ }
error_check_good db_close [$db close] 0
}