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

« back to all changes in this revision

Viewing changes to libdb/test/test006.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  test006
9
 
# TEST  Small keys/medium data
10
 
# TEST          Put/get per key
11
 
# TEST          Keyed delete and verify
12
 
# TEST
13
 
# TEST  Keyed delete test.
14
 
# TEST  Create database.
15
 
# TEST  Go through database, deleting all entries by key.
16
 
proc test006 { method {nentries 10000} {reopen 0} {tnum 6} args} {
17
 
        source ./include.tcl
18
 
 
19
 
        set do_renumber [is_rrecno $method]
20
 
        set args [convert_args $method $args]
21
 
        set omethod [convert_method $method]
22
 
 
23
 
        if { $tnum < 10 } {
24
 
                set tname Test00$tnum
25
 
                set dbname test00$tnum
26
 
        } else {
27
 
                set tname Test0$tnum
28
 
                set dbname test0$tnum
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/$dbname.db
38
 
                set env NULL
39
 
        } else {
40
 
                set testfile $dbname.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
 
                }
54
 
                set testdir [get_home $env]
55
 
        }
56
 
        puts -nonewline "$tname: $method ($args) "
57
 
        puts -nonewline "$nentries equal small key; medium data pairs"
58
 
        if {$reopen == 1} {
59
 
                puts " (with close)"
60
 
        } else {
61
 
                puts ""
62
 
        }
63
 
 
64
 
        set pflags ""
65
 
        set gflags ""
66
 
        set txn ""
67
 
        set count 0
68
 
        if { [is_record_based $method] == 1 } {
69
 
                append gflags " -recno"
70
 
        }
71
 
 
72
 
        # Here is the loop where we put and get each key/data pair
73
 
 
74
 
        cleanup $testdir $env
75
 
        set db [eval {berkdb_open \
76
 
            -create -mode 0644} $args {$omethod $testfile}]
77
 
        error_check_good dbopen [is_valid_db $db] TRUE
78
 
 
79
 
        set did [open $dict]
80
 
        while { [gets $did str] != -1 && $count < $nentries } {
81
 
                if { [is_record_based $method] == 1 } {
82
 
                        set key [expr $count + 1 ]
83
 
                } else {
84
 
                        set key $str
85
 
                }
86
 
 
87
 
                set datastr [make_data_str $str]
88
 
 
89
 
                if { $txnenv == 1 } {
90
 
                        set t [$env txn]
91
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
92
 
                        set txn "-txn $t"
93
 
                }
94
 
                set ret [eval {$db put} \
95
 
                    $txn $pflags {$key [chop_data $method $datastr]}]
96
 
                error_check_good put $ret 0
97
 
                if { $txnenv == 1 } {
98
 
                        error_check_good txn [$t commit] 0
99
 
                }
100
 
 
101
 
                set ret [eval {$db get} $gflags {$key}]
102
 
                error_check_good "$tname: put $datastr got $ret" \
103
 
                    $ret [list [list $key [pad_data $method $datastr]]]
104
 
                incr count
105
 
        }
106
 
        close $did
107
 
 
108
 
        if { $reopen == 1 } {
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 each key from the DB and compare the results
116
 
        # to the original, then delete it.
117
 
        set count 0
118
 
        set did [open $dict]
119
 
        set key 0
120
 
        while { [gets $did str] != -1 && $count < $nentries } {
121
 
                if { $do_renumber == 1 } {
122
 
                        set key 1
123
 
                } elseif { [is_record_based $method] == 1 } {
124
 
                        incr key
125
 
                } else {
126
 
                        set key $str
127
 
                }
128
 
 
129
 
                set datastr [make_data_str $str]
130
 
 
131
 
                set ret [eval {$db get} $gflags {$key}]
132
 
                error_check_good "$tname: get $datastr got $ret" \
133
 
                    $ret [list [list $key [pad_data $method $datastr]]]
134
 
 
135
 
                if { $txnenv == 1 } {
136
 
                        set t [$env txn]
137
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
138
 
                        set txn "-txn $t"
139
 
                }
140
 
                set ret [eval {$db del} $txn {$key}]
141
 
                error_check_good db_del:$key $ret 0
142
 
                if { $txnenv == 1 } {
143
 
                        error_check_good txn [$t commit] 0
144
 
                }
145
 
                incr count
146
 
        }
147
 
        close $did
148
 
 
149
 
        error_check_good db_close [$db close] 0
150
 
}