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

« back to all changes in this revision

Viewing changes to libdb/test/test088.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) 1999-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  test088
9
 
# TEST  Test of cursor stability across btree splits with very
10
 
# TEST  deep trees (a variant of test048). [#2514]
11
 
proc test088 { method args } {
12
 
        global errorCode alphabet
13
 
        source ./include.tcl
14
 
 
15
 
        set tstn 088
16
 
        set args [convert_args $method $args]
17
 
 
18
 
        if { [is_btree $method] != 1 } {
19
 
                puts "Test$tstn skipping for method $method."
20
 
                return
21
 
        }
22
 
        set pgindex [lsearch -exact $args "-pagesize"]
23
 
        if { $pgindex != -1 } {
24
 
                puts "Test088: skipping for specific pagesizes"
25
 
                return
26
 
        }
27
 
 
28
 
        set method "-btree"
29
 
 
30
 
        puts "\tTest$tstn: Test of cursor stability across btree splits."
31
 
 
32
 
        set key "key$alphabet$alphabet$alphabet"
33
 
        set data "data$alphabet$alphabet$alphabet"
34
 
        set txn ""
35
 
        set flags ""
36
 
 
37
 
        puts "\tTest$tstn.a: Create $method database."
38
 
        set txnenv 0
39
 
        set eindex [lsearch -exact $args "-env"]
40
 
        #
41
 
        # If we are using an env, then testfile should just be the db name.
42
 
        # Otherwise it is the test directory and the name.
43
 
        if { $eindex == -1 } {
44
 
                set testfile $testdir/test$tstn.db
45
 
                set env NULL
46
 
        } else {
47
 
                set testfile test$tstn.db
48
 
                incr eindex
49
 
                set env [lindex $args $eindex]
50
 
                set txnenv [is_txnenv $env]
51
 
                if { $txnenv == 1 } {
52
 
                        append args " -auto_commit "
53
 
                }
54
 
                set testdir [get_home $env]
55
 
        }
56
 
        set t1 $testdir/t1
57
 
        cleanup $testdir $env
58
 
 
59
 
        set ps 512
60
 
        set txn ""
61
 
        set oflags "-create -pagesize $ps -mode 0644 $args $method"
62
 
        set db [eval {berkdb_open} $oflags $testfile]
63
 
        error_check_good dbopen [is_valid_db $db] TRUE
64
 
 
65
 
        set nkeys 5
66
 
        # Fill page w/ key/data pairs.
67
 
        #
68
 
        puts "\tTest$tstn.b: Fill page with $nkeys small key/data pairs."
69
 
        for { set i 0 } { $i < $nkeys } { incr i } {
70
 
                if { $txnenv == 1 } {
71
 
                        set t [$env txn]
72
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
73
 
                        set txn "-txn $t"
74
 
                }
75
 
                set ret [eval {$db put} $txn {${key}00000$i $data$i}]
76
 
                error_check_good dbput $ret 0
77
 
                if { $txnenv == 1 } {
78
 
                        error_check_good txn [$t commit] 0
79
 
                }
80
 
        }
81
 
 
82
 
        # get db ordering, set cursors
83
 
        puts "\tTest$tstn.c: Set cursors on each of $nkeys pairs."
84
 
        # if mkeys is above 1000, need to adjust below for lexical order
85
 
        set mkeys 30000
86
 
        if { $txnenv == 1 } {
87
 
                set t [$env txn]
88
 
                error_check_good txn [is_valid_txn $t $env] TRUE
89
 
                set txn "-txn $t"
90
 
                set mkeys 300
91
 
        }
92
 
        for {set i 0; set ret [$db get ${key}00000$i]} {\
93
 
                        $i < $nkeys && [llength $ret] != 0} {\
94
 
                        incr i; set ret [$db get ${key}00000$i]} {
95
 
                set key_set($i) [lindex [lindex $ret 0] 0]
96
 
                set data_set($i) [lindex [lindex $ret 0] 1]
97
 
                set dbc [eval {$db cursor} $txn]
98
 
                set dbc_set($i) $dbc
99
 
                error_check_good db_cursor:$i [is_substr $dbc_set($i) $db] 1
100
 
                set ret [$dbc_set($i) get -set $key_set($i)]
101
 
                error_check_bad dbc_set($i)_get:set [llength $ret] 0
102
 
        }
103
 
 
104
 
        puts "\tTest$tstn.d: Add $mkeys pairs to force splits."
105
 
        for {set i $nkeys} { $i < $mkeys } { incr i } {
106
 
                if { $i >= 10000 } {
107
 
                        set ret [eval {$db put} $txn {${key}0$i $data$i}]
108
 
                } elseif { $i >= 1000 } {
109
 
                        set ret [eval {$db put} $txn {${key}00$i $data$i}]
110
 
                } elseif { $i >= 100 } {
111
 
                        set ret [eval {$db put} $txn {${key}000$i $data$i}]
112
 
                } elseif { $i >= 10 } {
113
 
                        set ret [eval {$db put} $txn {${key}0000$i $data$i}]
114
 
                } else {
115
 
                        set ret [eval {$db put} $txn {${key}00000$i $data$i}]
116
 
                }
117
 
                error_check_good dbput:more $ret 0
118
 
        }
119
 
 
120
 
        puts "\tTest$tstn.e: Make sure splits happened."
121
 
        # XXX cannot execute stat in presence of txns and cursors.
122
 
        if { $txnenv == 0 } {
123
 
                error_check_bad stat:check-split [is_substr [$db stat] \
124
 
                                                "{{Internal pages} 0}"] 1
125
 
        }
126
 
 
127
 
        puts "\tTest$tstn.f: Check to see that cursors maintained reference."
128
 
        for {set i 0} { $i < $nkeys } {incr i} {
129
 
                set ret [$dbc_set($i) get -current]
130
 
                error_check_bad dbc$i:get:current [llength $ret] 0
131
 
                set ret2 [$dbc_set($i) get -set $key_set($i)]
132
 
                error_check_bad dbc$i:get:set [llength $ret2] 0
133
 
                error_check_good dbc$i:get(match) $ret $ret2
134
 
        }
135
 
 
136
 
        puts "\tTest$tstn.g: Delete added keys to force reverse splits."
137
 
        for {set i $nkeys} { $i < $mkeys } { incr i } {
138
 
                if { $i >= 10000 } {
139
 
                        set ret [eval {$db del} $txn {${key}0$i}]
140
 
                } elseif { $i >= 1000 } {
141
 
                        set ret [eval {$db del} $txn {${key}00$i}]
142
 
                } elseif { $i >= 100 } {
143
 
                        set ret [eval {$db del} $txn {${key}000$i}]
144
 
                } elseif { $i >= 10 } {
145
 
                        set ret [eval {$db del} $txn {${key}0000$i}]
146
 
                } else {
147
 
                        set ret [eval {$db del} $txn {${key}00000$i}]
148
 
                }
149
 
                error_check_good dbput:more $ret 0
150
 
        }
151
 
 
152
 
        puts "\tTest$tstn.h: Verify cursor reference."
153
 
        for {set i 0} { $i < $nkeys } {incr i} {
154
 
                set ret [$dbc_set($i) get -current]
155
 
                error_check_bad dbc$i:get:current [llength $ret] 0
156
 
                set ret2 [$dbc_set($i) get -set $key_set($i)]
157
 
                error_check_bad dbc$i:get:set [llength $ret2] 0
158
 
                error_check_good dbc$i:get(match) $ret $ret2
159
 
        }
160
 
 
161
 
        puts "\tTest$tstn.i: Cleanup."
162
 
        # close cursors
163
 
        for {set i 0} { $i < $nkeys } {incr i} {
164
 
                error_check_good dbc_close:$i [$dbc_set($i) close] 0
165
 
        }
166
 
        if { $txnenv == 1 } {
167
 
                error_check_good txn [$t commit] 0
168
 
        }
169
 
        error_check_good dbclose [$db close] 0
170
 
 
171
 
        puts "\tTest$tstn complete."
172
 
}