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

« back to all changes in this revision

Viewing changes to libdb/test/test008.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  test008
9
 
# TEST  Small keys/large data
10
 
# TEST          Put/get per key
11
 
# TEST          Loop through keys by steps (which change)
12
 
# TEST              ... delete each key at step
13
 
# TEST              ... add each key back
14
 
# TEST              ... change step
15
 
# TEST          Confirm that overflow pages are getting reused
16
 
# TEST
17
 
# TEST  Take the source files and dbtest executable and enter their names as
18
 
# TEST  the key with their contents as data.  After all are entered, begin
19
 
# TEST  looping through the entries; deleting some pairs and then readding them.
20
 
proc test008 { method {reopen 8} {debug 0} args} {
21
 
        source ./include.tcl
22
 
 
23
 
        set tnum test00$reopen
24
 
        set args [convert_args $method $args]
25
 
        set omethod [convert_method $method]
26
 
 
27
 
        if { [is_record_based $method] == 1 } {
28
 
                puts "Test00$reopen skipping for method $method"
29
 
                return
30
 
        }
31
 
 
32
 
        puts -nonewline "$tnum: $method filename=key filecontents=data pairs"
33
 
        if {$reopen == 9} {
34
 
                puts "(with close)"
35
 
        } else {
36
 
                puts ""
37
 
        }
38
 
 
39
 
        # Create the database and open the dictionary
40
 
        set txnenv 0
41
 
        set eindex [lsearch -exact $args "-env"]
42
 
        #
43
 
        # If we are using an env, then testfile should just be the db name.
44
 
        # Otherwise it is the test directory and the name.
45
 
        if { $eindex == -1 } {
46
 
                set testfile $testdir/$tnum.db
47
 
                set env NULL
48
 
        } else {
49
 
                set testfile $tnum.db
50
 
                incr eindex
51
 
                set env [lindex $args $eindex]
52
 
                set txnenv [is_txnenv $env]
53
 
                if { $txnenv == 1 } {
54
 
                        append args " -auto_commit "
55
 
                }
56
 
                set testdir [get_home $env]
57
 
        }
58
 
        set t1 $testdir/t1
59
 
        set t2 $testdir/t2
60
 
        set t3 $testdir/t3
61
 
        set t4 $testdir/t4
62
 
 
63
 
        cleanup $testdir $env
64
 
 
65
 
        set db [eval {berkdb_open -create -mode 0644} \
66
 
            $args {$omethod $testfile}]
67
 
        error_check_good dbopen [is_valid_db $db] TRUE
68
 
 
69
 
        set pflags ""
70
 
        set gflags ""
71
 
        set txn ""
72
 
 
73
 
        # Here is the loop where we put and get each key/data pair
74
 
        set file_list [get_file_list]
75
 
 
76
 
        set count 0
77
 
        puts "\tTest00$reopen.a: Initial put/get loop"
78
 
        foreach f $file_list {
79
 
                set names($count) $f
80
 
                set key $f
81
 
 
82
 
                if { $txnenv == 1 } {
83
 
                        set t [$env txn]
84
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
85
 
                        set txn "-txn $t"
86
 
                }
87
 
                put_file $db $txn $pflags $f
88
 
                if { $txnenv == 1 } {
89
 
                        error_check_good txn [$t commit] 0
90
 
                }
91
 
 
92
 
                if { $txnenv == 1 } {
93
 
                        set t [$env txn]
94
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
95
 
                        set txn "-txn $t"
96
 
                }
97
 
                get_file $db $txn $gflags $f $t4
98
 
                if { $txnenv == 1 } {
99
 
                        error_check_good txn [$t commit] 0
100
 
                }
101
 
 
102
 
                error_check_good Test00$reopen:diff($f,$t4) \
103
 
                    [filecmp $f $t4] 0
104
 
 
105
 
                incr count
106
 
        }
107
 
 
108
 
        if {$reopen == 9} {
109
 
                error_check_good db_close [$db close] 0
110
 
 
111
 
                set db [eval {berkdb_open} $args $testfile]
112
 
                error_check_good dbopen [is_valid_db $db] TRUE
113
 
        }
114
 
 
115
 
        # Now we will get step through keys again (by increments) and
116
 
        # delete all the entries, then re-insert them.
117
 
 
118
 
        puts "\tTest00$reopen.b: Delete re-add loop"
119
 
        foreach i "1 2 4 8 16" {
120
 
                for {set ndx 0} {$ndx < $count} { incr ndx $i} {
121
 
                        if { $txnenv == 1 } {
122
 
                                set t [$env txn]
123
 
                                error_check_good txn [is_valid_txn $t $env] TRUE
124
 
                                set txn "-txn $t"
125
 
                        }
126
 
                        set r [eval {$db del} $txn {$names($ndx)}]
127
 
                        error_check_good db_del:$names($ndx) $r 0
128
 
                        if { $txnenv == 1 } {
129
 
                                error_check_good txn [$t commit] 0
130
 
                        }
131
 
                }
132
 
                for {set ndx 0} {$ndx < $count} { incr ndx $i} {
133
 
                        if { $txnenv == 1 } {
134
 
                                set t [$env txn]
135
 
                                error_check_good txn [is_valid_txn $t $env] TRUE
136
 
                                set txn "-txn $t"
137
 
                        }
138
 
                        put_file $db $txn $pflags $names($ndx)
139
 
                        if { $txnenv == 1 } {
140
 
                                error_check_good txn [$t commit] 0
141
 
                        }
142
 
                }
143
 
        }
144
 
 
145
 
        if {$reopen == 9} {
146
 
                error_check_good db_close [$db close] 0
147
 
                set db [eval {berkdb_open} $args $testfile]
148
 
                error_check_good dbopen [is_valid_db $db] TRUE
149
 
        }
150
 
 
151
 
        # Now, reopen the file and make sure the key/data pairs look right.
152
 
        puts "\tTest00$reopen.c: Dump contents forward"
153
 
        if { $txnenv == 1 } {
154
 
                set t [$env txn]
155
 
                error_check_good txn [is_valid_txn $t $env] TRUE
156
 
                set txn "-txn $t"
157
 
        }
158
 
        dump_bin_file $db $txn $t1 test008.check
159
 
        if { $txnenv == 1 } {
160
 
                error_check_good txn [$t commit] 0
161
 
        }
162
 
 
163
 
        set oid [open $t2.tmp w]
164
 
        foreach f $file_list {
165
 
                puts $oid $f
166
 
        }
167
 
        close $oid
168
 
        filesort $t2.tmp $t2
169
 
        fileremove $t2.tmp
170
 
        filesort $t1 $t3
171
 
 
172
 
        error_check_good Test00$reopen:diff($t3,$t2) \
173
 
            [filecmp $t3 $t2] 0
174
 
 
175
 
        # Now, reopen the file and run the last test again in reverse direction.
176
 
        puts "\tTest00$reopen.d: Dump contents backward"
177
 
        if { $txnenv == 1 } {
178
 
                set t [$env txn]
179
 
                error_check_good txn [is_valid_txn $t $env] TRUE
180
 
                set txn "-txn $t"
181
 
        }
182
 
        dump_bin_file_direction $db $txn $t1 test008.check "-last" "-prev"
183
 
        if { $txnenv == 1 } {
184
 
                error_check_good txn [$t commit] 0
185
 
        }
186
 
 
187
 
        filesort $t1 $t3
188
 
 
189
 
        error_check_good Test00$reopen:diff($t3,$t2) \
190
 
            [filecmp $t3 $t2] 0
191
 
        error_check_good close:$db [$db close] 0
192
 
}
193
 
 
194
 
proc test008.check { binfile tmpfile } {
195
 
        global tnum
196
 
        source ./include.tcl
197
 
 
198
 
        error_check_good diff($binfile,$tmpfile) \
199
 
            [filecmp $binfile $tmpfile] 0
200
 
}