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

« back to all changes in this revision

Viewing changes to libdb/test/test010.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  test010
9
 
# TEST  Duplicate test
10
 
# TEST          Small key/data pairs.
11
 
# TEST
12
 
# TEST  Use the first 10,000 entries from the dictionary.
13
 
# TEST  Insert each with self as key and data; add duplicate records for each.
14
 
# TEST  After all are entered, retrieve all; verify output.
15
 
# TEST  Close file, reopen, do retrieve and re-verify.
16
 
# TEST  This does not work for recno
17
 
proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } {
18
 
        source ./include.tcl
19
 
 
20
 
        set omethod $method
21
 
        set args [convert_args $method $args]
22
 
        set omethod [convert_method $method]
23
 
 
24
 
        if { [is_record_based $method] == 1 || \
25
 
            [is_rbtree $method] == 1 } {
26
 
                puts "Test0$tnum skipping for method $method"
27
 
                return
28
 
        }
29
 
 
30
 
        # Create the database and open the dictionary
31
 
        set txnenv 0
32
 
        set eindex [lsearch -exact $args "-env"]
33
 
        #
34
 
        # If we are using an env, then testfile should just be the db name.
35
 
        # Otherwise it is the test directory and the name.
36
 
        if { $eindex == -1 } {
37
 
                set testfile $testdir/test0$tnum.db
38
 
                set env NULL
39
 
        } else {
40
 
                set testfile test0$tnum.db
41
 
                incr eindex
42
 
                set env [lindex $args $eindex]
43
 
                set txnenv [is_txnenv $env]
44
 
                if { $txnenv == 1 } {
45
 
                        append args " -auto_commit "
46
 
                        #
47
 
                        # If we are using txns and running with the
48
 
                        # default, set the default down a bit.
49
 
                        #
50
 
                        if { $nentries == 10000 } {
51
 
                                set nentries 100
52
 
                        }
53
 
                        reduce_dups nentries ndups
54
 
                }
55
 
                set testdir [get_home $env]
56
 
        }
57
 
        puts "Test0$tnum: $method ($args) $nentries \
58
 
            small $ndups dup key/data pairs"
59
 
 
60
 
        set t1 $testdir/t1
61
 
        set t2 $testdir/t2
62
 
        set t3 $testdir/t3
63
 
 
64
 
        cleanup $testdir $env
65
 
 
66
 
        set db [eval {berkdb_open \
67
 
             -create -mode 0644 -dup} $args {$omethod $testfile}]
68
 
        error_check_good dbopen [is_valid_db $db] TRUE
69
 
 
70
 
        set did [open $dict]
71
 
 
72
 
        set pflags ""
73
 
        set gflags ""
74
 
        set txn ""
75
 
        set count 0
76
 
 
77
 
        # Here is the loop where we put and get each key/data pair
78
 
        while { [gets $did str] != -1 && $count < $nentries } {
79
 
                for { set i 1 } { $i <= $ndups } { incr i } {
80
 
                        set datastr $i:$str
81
 
                        if { $txnenv == 1 } {
82
 
                                set t [$env txn]
83
 
                                error_check_good txn [is_valid_txn $t $env] TRUE
84
 
                                set txn "-txn $t"
85
 
                        }
86
 
                        set ret [eval {$db put} \
87
 
                            $txn $pflags {$str [chop_data $method $datastr]}]
88
 
                        error_check_good put $ret 0
89
 
                        if { $txnenv == 1 } {
90
 
                                error_check_good txn [$t commit] 0
91
 
                        }
92
 
                }
93
 
 
94
 
                # Now retrieve all the keys matching this key
95
 
                set x 1
96
 
                if { $txnenv == 1 } {
97
 
                        set t [$env txn]
98
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
99
 
                        set txn "-txn $t"
100
 
                }
101
 
                set dbc [eval {$db cursor} $txn]
102
 
                for {set ret [$dbc get "-set" $str]} \
103
 
                    {[llength $ret] != 0} \
104
 
                    {set ret [$dbc get "-next"] } {
105
 
                        if {[llength $ret] == 0} {
106
 
                                break
107
 
                        }
108
 
                        set k [lindex [lindex $ret 0] 0]
109
 
                        if { [string compare $k $str] != 0 } {
110
 
                                break
111
 
                        }
112
 
                        set datastr [lindex [lindex $ret 0] 1]
113
 
                        set d [data_of $datastr]
114
 
                        error_check_good "Test0$tnum:get" $d $str
115
 
                        set id [ id_of $datastr ]
116
 
                        error_check_good "Test0$tnum:dup#" $id $x
117
 
                        incr x
118
 
                }
119
 
                error_check_good "Test0$tnum:ndups:$str" [expr $x - 1] $ndups
120
 
                error_check_good cursor_close [$dbc close] 0
121
 
                if { $txnenv == 1 } {
122
 
                        error_check_good txn [$t commit] 0
123
 
                }
124
 
 
125
 
                incr count
126
 
        }
127
 
        close $did
128
 
 
129
 
        # Now we will get each key from the DB and compare the results
130
 
        # to the original.
131
 
        puts "\tTest0$tnum.a: Checking file for correct duplicates"
132
 
        set dlist ""
133
 
        for { set i 1 } { $i <= $ndups } {incr i} {
134
 
                lappend dlist $i
135
 
        }
136
 
        if { $txnenv == 1 } {
137
 
                set t [$env txn]
138
 
                error_check_good txn [is_valid_txn $t $env] TRUE
139
 
                set txn "-txn $t"
140
 
        }
141
 
        dup_check $db $txn $t1 $dlist
142
 
        if { $txnenv == 1 } {
143
 
                error_check_good txn [$t commit] 0
144
 
        }
145
 
 
146
 
        # Now compare the keys to see if they match the dictionary entries
147
 
        set q q
148
 
        filehead $nentries $dict $t3
149
 
        filesort $t3 $t2
150
 
        filesort $t1 $t3
151
 
 
152
 
        error_check_good Test0$tnum:diff($t3,$t2) \
153
 
            [filecmp $t3 $t2] 0
154
 
 
155
 
        error_check_good db_close [$db close] 0
156
 
        set db [eval {berkdb_open} $args $testfile]
157
 
        error_check_good dbopen [is_valid_db $db] TRUE
158
 
 
159
 
        puts "\tTest0$tnum.b: Checking file for correct duplicates after close"
160
 
        if { $txnenv == 1 } {
161
 
                set t [$env txn]
162
 
                error_check_good txn [is_valid_txn $t $env] TRUE
163
 
                set txn "-txn $t"
164
 
        }
165
 
        dup_check $db $txn $t1 $dlist
166
 
        if { $txnenv == 1 } {
167
 
                error_check_good txn [$t commit] 0
168
 
        }
169
 
 
170
 
        # Now compare the keys to see if they match the dictionary entries
171
 
        filesort $t1 $t3
172
 
        error_check_good Test0$tnum:diff($t3,$t2) \
173
 
            [filecmp $t3 $t2] 0
174
 
 
175
 
        error_check_good db_close [$db close] 0
176
 
}