1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2001
4
# Sleepycat Software. All rights reserved.
6
# $Id: test025.tcl,v 11.13 2001/05/17 20:37:08 bostic Exp $
8
# DB Test 25 {method nentries}
9
# Test the DB_APPEND flag.
10
proc test025 { method {nentries 10000} {start 0 } {tnum "25" } args} {
14
set args [convert_args $method $args]
15
set omethod [convert_method $method]
16
puts "Test0$tnum: $method ($args)"
18
if { [string compare $omethod "-btree"] == 0 } {
19
puts "Test0$tnum skipping for method BTREE"
22
if { [string compare $omethod "-hash"] == 0 } {
23
puts "Test0$tnum skipping for method HASH"
27
# Create the database and open the dictionary
28
set eindex [lsearch -exact $args "-env"]
30
# If we are using an env, then testfile should just be the db name.
31
# Otherwise it is the test directory and the name.
32
if { $eindex == -1 } {
33
set testfile $testdir/test0$tnum.db
36
set testfile test0$tnum.db
38
set env [lindex $args $eindex]
43
set db [eval {berkdb_open \
44
-create -truncate -mode 0644} $args {$omethod $testfile}]
45
error_check_good dbopen [is_valid_db $db] TRUE
48
puts "\tTest0$tnum.a: put/get loop"
52
set checkfunc test025_check
54
# Here is the loop where we put and get each key/data pair
56
set nentries [expr $start + $nentries]
59
set k [expr $count + 1]
60
set kvals($k) [pad_data $method $str]
61
set ret [eval {$db put} $txn $k {[chop_data $method $str]}]
62
error_check_good db_put $ret 0
66
while { [gets $did str] != -1 && $count < $nentries } {
67
set k [expr $count + 1]
68
set kvals($k) [pad_data $method $str]
69
set ret [eval {$db put} $txn $pflags {[chop_data $method $str]}]
70
error_check_good db_put $ret $k
72
set ret [eval {$db get} $txn $gflags {$k}]
74
get $ret [list [list $k [pad_data $method $str]]]
76
if { [expr $count + 1] == 0 } {
82
# Now we will get each key from the DB and compare the results
84
puts "\tTest0$tnum.b: dump file"
85
dump_file $db $txn $t1 $checkfunc
86
error_check_good db_close [$db close] 0
88
puts "\tTest0$tnum.c: close, open, and dump file"
89
# Now, reopen the file and run the last test again.
90
open_and_dump_file $testfile $env $txn $t1 $checkfunc \
91
dump_file_direction -first -next
93
# Now, reopen the file and run the last test again in the
95
puts "\tTest0$tnum.d: close, open, and dump file in reverse direction"
96
open_and_dump_file $testfile $env $txn $t1 $checkfunc \
97
dump_file_direction -last -prev
100
proc test025_check { key data } {
103
error_check_good key"$key"_exists [info exists kvals($key)] 1
104
error_check_good " key/data mismatch for |$key|" $data $kvals($key)