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

« back to all changes in this revision

Viewing changes to libdb/test/test078.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) 2000-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  test078
9
 
# TEST  Test of DBC->c_count(). [#303]
10
 
proc test078 { method { nkeys 100 } { pagesize 512 } { tnum 78 } args } {
11
 
        source ./include.tcl
12
 
        global alphabet rand_init
13
 
 
14
 
        set args [convert_args $method $args]
15
 
        set omethod [convert_method $method]
16
 
 
17
 
        puts "Test0$tnum: Test of key counts."
18
 
 
19
 
        berkdb srand $rand_init
20
 
 
21
 
        set txnenv 0
22
 
        set eindex [lsearch -exact $args "-env"]
23
 
        if { $eindex != -1 } {
24
 
                incr eindex
25
 
        }
26
 
 
27
 
        if { $eindex == -1 } {
28
 
                set testfile $testdir/test0$tnum-a.db
29
 
                set env NULL
30
 
        } else {
31
 
                set testfile test0$tnum-a.db
32
 
                set env [lindex $args $eindex]
33
 
                set txnenv [is_txnenv $env]
34
 
                if { $txnenv == 1 } {
35
 
                        append args " -auto_commit "
36
 
                }
37
 
                set testdir [get_home $env]
38
 
        }
39
 
        cleanup $testdir $env
40
 
 
41
 
        puts "\tTest0$tnum.a: No duplicates, trivial answer."
42
 
        set pgindex [lsearch -exact $args "-pagesize"]
43
 
        if { $pgindex != -1 } {
44
 
                puts "Test078: skipping for specific pagesizes"
45
 
                return
46
 
        }
47
 
 
48
 
        set db [eval {berkdb_open -create -mode 0644\
49
 
            -pagesize $pagesize} $omethod $args {$testfile}]
50
 
        error_check_good db_open [is_valid_db $db] TRUE
51
 
        set txn ""
52
 
 
53
 
        for { set i 1 } { $i <= $nkeys } { incr i } {
54
 
                if { $txnenv == 1 } {
55
 
                        set t [$env txn]
56
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
57
 
                        set txn "-txn $t"
58
 
                }
59
 
                set ret [eval {$db put} $txn {$i\
60
 
                    [pad_data $method $alphabet$i]}]
61
 
                error_check_good put.a($i) $ret 0
62
 
                if { $txnenv == 1 } {
63
 
                        error_check_good txn [$t commit] 0
64
 
                }
65
 
                error_check_good count.a [$db count $i] 1
66
 
        }
67
 
        error_check_good db_close.a [$db close] 0
68
 
 
69
 
        if { [is_record_based $method] == 1 || [is_rbtree $method] == 1 } {
70
 
                puts \
71
 
            "\tTest0$tnum.b: Duplicates not supported in $method, skipping."
72
 
                return
73
 
        }
74
 
 
75
 
        foreach tuple {{b sorted "-dup -dupsort"} {c unsorted "-dup"}} {
76
 
                set letter [lindex $tuple 0]
77
 
                set dupopt [lindex $tuple 2]
78
 
 
79
 
                if { $eindex == -1 } {
80
 
                        set testfile $testdir/test0$tnum-b.db
81
 
                        set env NULL
82
 
                } else {
83
 
                        set testfile test0$tnum-b.db
84
 
                        set env [lindex $args $eindex]
85
 
                        set testdir [get_home $env]
86
 
                }
87
 
                cleanup $testdir $env
88
 
 
89
 
                puts "\tTest0$tnum.$letter: Duplicates ([lindex $tuple 1])."
90
 
 
91
 
                puts "\t\tTest0$tnum.$letter.1: Populating database."
92
 
 
93
 
                set db [eval {berkdb_open -create -mode 0644\
94
 
                    -pagesize $pagesize} $dupopt $omethod $args {$testfile}]
95
 
                error_check_good db_open [is_valid_db $db] TRUE
96
 
 
97
 
                for { set i 1 } { $i <= $nkeys } { incr i } {
98
 
                        for { set j 0 } { $j < $i } { incr j } {
99
 
                                if { $txnenv == 1 } {
100
 
                                        set t [$env txn]
101
 
                                        error_check_good txn \
102
 
                                            [is_valid_txn $t $env] TRUE
103
 
                                        set txn "-txn $t"
104
 
                                }
105
 
                                set ret [eval {$db put} $txn {$i\
106
 
                                    [pad_data $method $j$alphabet]}]
107
 
                                error_check_good put.$letter,$i $ret 0
108
 
                                if { $txnenv == 1 } {
109
 
                                        error_check_good txn [$t commit] 0
110
 
                                }
111
 
                        }
112
 
                }
113
 
 
114
 
                puts -nonewline "\t\tTest0$tnum.$letter.2: "
115
 
                puts "Verifying dup counts on first dup."
116
 
                for { set i 1 } { $i < $nkeys } { incr i } {
117
 
                        error_check_good count.$letter,$i \
118
 
                            [$db count $i] $i
119
 
                }
120
 
 
121
 
                puts -nonewline "\t\tTest0$tnum.$letter.3: "
122
 
                puts "Verifying dup counts on random dup."
123
 
                for { set i 1 } { $i < $nkeys } { incr i } {
124
 
                        set key [berkdb random_int 1 $nkeys]
125
 
                        error_check_good count.$letter,$i \
126
 
                            [$db count $i] $i
127
 
                }
128
 
                error_check_good db_close.$letter [$db close] 0
129
 
        }
130
 
}