~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/test/dbm.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# See the file LICENSE for redistribution information.
2
 
#
3
 
# Copyright (c) 1996-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  dbm
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
13
 
# TEST  everything.
14
 
proc dbm { { nentries 1000 } } {
15
 
        source ./include.tcl
16
 
 
17
 
        puts "DBM interfaces test: $nentries"
18
 
 
19
 
        # Create the database and open the dictionary
20
 
        set testfile $testdir/dbmtest
21
 
        set t1 $testdir/t1
22
 
        set t2 $testdir/t2
23
 
        set t3 $testdir/t3
24
 
        cleanup $testdir NULL
25
 
 
26
 
        error_check_good dbminit [berkdb dbminit $testfile] 0
27
 
        set did [open $dict]
28
 
 
29
 
        set flags ""
30
 
        set txn ""
31
 
        set count 0
32
 
        set skippednullkey 0
33
 
 
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 } {
39
 
                        set skippednullkey 1
40
 
                        continue
41
 
                }
42
 
 
43
 
                set ret [berkdb store $str $str]
44
 
                error_check_good dbm_store $ret 0
45
 
 
46
 
                set d [berkdb fetch $str]
47
 
                error_check_good dbm_fetch $d $str
48
 
                incr count
49
 
        }
50
 
        close $did
51
 
 
52
 
        # Now we will get each key from the DB and compare the results
53
 
        # to the original.
54
 
        puts "\tDBM.b: dump file"
55
 
        set oid [open $t1 w]
56
 
        for { set key [berkdb firstkey] } { $key != -1 } {\
57
 
                 set key [berkdb nextkey $key] } {
58
 
                puts $oid $key
59
 
                set d [berkdb fetch $key]
60
 
                error_check_good dbm_refetch $d $key
61
 
        }
62
 
 
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 } {
66
 
                puts $oid ""
67
 
                incr nentries 1
68
 
        }
69
 
 
70
 
        close $oid
71
 
 
72
 
        # Now compare the keys to see if they match the dictionary (or ints)
73
 
        set q q
74
 
        filehead $nentries $dict $t3
75
 
        filesort $t3 $t2
76
 
        filesort $t1 $t3
77
 
 
78
 
        error_check_good DBM:diff($t3,$t2) \
79
 
            [filecmp $t3 $t2] 0
80
 
 
81
 
        puts "\tDBM.c: close, open, and dump file"
82
 
 
83
 
        # Now, reopen the file and run the last test again.
84
 
        error_check_good dbminit2 [berkdb dbminit $testfile] 0
85
 
        set oid [open $t1 w]
86
 
 
87
 
        for { set key [berkdb firstkey] } { $key != -1 } {\
88
 
                 set key [berkdb nextkey $key] } {
89
 
                puts $oid $key
90
 
                set d [berkdb fetch $key]
91
 
                error_check_good dbm_refetch $d $key
92
 
        }
93
 
        if { $skippednullkey == 1 } {
94
 
                puts $oid ""
95
 
        }
96
 
        close $oid
97
 
 
98
 
        # Now compare the keys to see if they match the dictionary (or ints)
99
 
        filesort $t1 $t3
100
 
 
101
 
        error_check_good DBM:diff($t2,$t3) \
102
 
            [filecmp $t2 $t3] 0
103
 
 
104
 
        # Now, reopen the file and delete each entry
105
 
        puts "\tDBM.d: sequential scan and delete"
106
 
 
107
 
        error_check_good dbminit3 [berkdb dbminit $testfile] 0
108
 
        set oid [open $t1 w]
109
 
 
110
 
        for { set key [berkdb firstkey] } { $key != -1 } {\
111
 
                 set key [berkdb nextkey $key] } {
112
 
                puts $oid $key
113
 
                set ret [berkdb delete $key]
114
 
                error_check_good dbm_delete $ret 0
115
 
        }
116
 
        if { $skippednullkey == 1 } {
117
 
                puts $oid ""
118
 
        }
119
 
        close $oid
120
 
 
121
 
        # Now compare the keys to see if they match the dictionary (or ints)
122
 
        filesort $t1 $t3
123
 
 
124
 
        error_check_good DBM:diff($t2,$t3) \
125
 
            [filecmp $t2 $t3] 0
126
 
 
127
 
        error_check_good "dbm_close" [berkdb dbmclose] 0
128
 
}