1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2001
4
# Sleepycat Software. All rights reserved.
6
# $Id: test012.tcl,v 11.16 2001/05/14 21:55:55 krinsky Exp $
8
# DB Test 12 {access method}
9
# Take the source files and dbtest executable and enter their contents as
10
# the key with their names as data. After all are entered, retrieve all;
11
# compare output to original. Close file, reopen, do retrieve and re-verify.
12
proc test012 { method args} {
16
set args [convert_args $method $args]
17
set omethod [convert_method $method]
19
if { [is_record_based $method] == 1 } {
20
puts "Test012 skipping for method $method"
24
puts "Test012: $method ($args) filename=data filecontents=key pairs"
26
# Create the database and open the dictionary
27
set eindex [lsearch -exact $args "-env"]
29
# If we are using an env, then testfile should just be the db name.
30
# Otherwise it is the test directory and the name.
31
if { $eindex == -1 } {
32
set testfile $testdir/test012.db
35
set testfile test012.db
37
set env [lindex $args $eindex]
46
set db [eval {berkdb_open \
47
-create -truncate -mode 0644} $args {$omethod $testfile}]
48
error_check_good dbopen [is_valid_db $db] TRUE
54
# Here is the loop where we put and get each key/data pair
55
set file_list [get_file_list]
57
puts "\tTest012.a: put/get loop"
59
foreach f $file_list {
60
put_file_as_key $db $txn $pflags $f
62
set kd [get_file_as_key $db $txn $gflags $f]
66
# Now we will get each key from the DB and compare the results
68
puts "\tTest012.b: dump file"
69
dump_binkey_file $db $txn $t1 test012.check
70
error_check_good db_close [$db close] 0
72
# Now compare the data to see if they match the .o and dbtest files
73
set oid [open $t2.tmp w]
74
foreach f $file_list {
82
error_check_good Test012:diff($t3,$t2) \
85
# Now, reopen the file and run the last test again.
86
puts "\tTest012.c: close, open, and dump file"
87
open_and_dump_file $testfile $env $txn $t1 test012.check \
88
dump_binkey_file_direction "-first" "-next"
92
error_check_good Test012:diff($t3,$t2) \
95
# Now, reopen the file and run the last test again in reverse direction.
96
puts "\tTest012.d: close, open, and dump file in reverse direction"
97
open_and_dump_file $testfile $env $txn $t1 test012.check\
98
dump_binkey_file_direction "-last" "-prev"
102
error_check_good Test012:diff($t3,$t2) \
106
# Check function for test012; key should be file name; data should be contents
107
proc test012.check { binfile tmpfile } {
110
error_check_good Test012:diff($binfile,$tmpfile) \
111
[filecmp $binfile $tmpfile] 0