1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Historic DBM interface test. Use the first 1000 entries from the
10
# TEST dictionary. Insert each with self as key and data; retrieve each.
11
# TEST After all are entered, retrieve all; compare output to original.
12
# TEST Then reopen the file, re-retrieve everything. Finally, delete
14
proc dbm { { nentries 1000 } } {
17
puts "DBM interfaces test: $nentries"
19
# Create the database and open the dictionary
20
set testfile $testdir/dbmtest
26
error_check_good dbminit [berkdb dbminit $testfile] 0
34
puts "\tDBM.a: put/get loop"
35
# Here is the loop where we put and get each key/data pair
36
while { [gets $did str] != -1 && $count < $nentries } {
37
# DBM can't handle zero-length keys
38
if { [string length $str] == 0 } {
43
set ret [berkdb store $str $str]
44
error_check_good dbm_store $ret 0
46
set d [berkdb fetch $str]
47
error_check_good dbm_fetch $d $str
52
# Now we will get each key from the DB and compare the results
54
puts "\tDBM.b: dump file"
56
for { set key [berkdb firstkey] } { $key != -1 } {\
57
set key [berkdb nextkey $key] } {
59
set d [berkdb fetch $key]
60
error_check_good dbm_refetch $d $key
63
# If we had to skip a zero-length key, juggle things to cover up
64
# this fact in the dump.
65
if { $skippednullkey == 1 } {
72
# Now compare the keys to see if they match the dictionary (or ints)
74
filehead $nentries $dict $t3
78
error_check_good DBM:diff($t3,$t2) \
81
puts "\tDBM.c: close, open, and dump file"
83
# Now, reopen the file and run the last test again.
84
error_check_good dbminit2 [berkdb dbminit $testfile] 0
87
for { set key [berkdb firstkey] } { $key != -1 } {\
88
set key [berkdb nextkey $key] } {
90
set d [berkdb fetch $key]
91
error_check_good dbm_refetch $d $key
93
if { $skippednullkey == 1 } {
98
# Now compare the keys to see if they match the dictionary (or ints)
101
error_check_good DBM:diff($t2,$t3) \
104
# Now, reopen the file and delete each entry
105
puts "\tDBM.d: sequential scan and delete"
107
error_check_good dbminit3 [berkdb dbminit $testfile] 0
110
for { set key [berkdb firstkey] } { $key != -1 } {\
111
set key [berkdb nextkey $key] } {
113
set ret [berkdb delete $key]
114
error_check_good dbm_delete $ret 0
116
if { $skippednullkey == 1 } {
121
# Now compare the keys to see if they match the dictionary (or ints)
124
error_check_good DBM:diff($t2,$t3) \
127
error_check_good "dbm_close" [berkdb dbmclose] 0