~ubuntu-branches/ubuntu/natty/evolution-data-server/natty

« back to all changes in this revision

Viewing changes to libdb/test/test066.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  test066
9
 
# TEST  Test of cursor overwrites of DB_CURRENT w/ duplicates.
10
 
# TEST
11
 
# TEST  Make sure a cursor put to DB_CURRENT acts as an overwrite in a
12
 
# TEST  database with duplicates.
13
 
proc test066 { method args } {
14
 
        set omethod [convert_method $method]
15
 
        set args [convert_args $method $args]
16
 
 
17
 
        set tnum 66
18
 
 
19
 
        if { [is_record_based $method] || [is_rbtree $method] } {
20
 
            puts "Test0$tnum: Skipping for method $method."
21
 
            return
22
 
        }
23
 
 
24
 
        puts "Test0$tnum: Test of cursor put to DB_CURRENT with duplicates."
25
 
 
26
 
        source ./include.tcl
27
 
 
28
 
        set txnenv 0
29
 
        set eindex [lsearch -exact $args "-env"]
30
 
        #
31
 
        # If we are using an env, then testfile should just be the db name.
32
 
        # Otherwise it is the test directory and the name.
33
 
        if { $eindex == -1 } {
34
 
                set testfile $testdir/test066.db
35
 
                set env NULL
36
 
        } else {
37
 
                set testfile test066.db
38
 
                incr eindex
39
 
                set env [lindex $args $eindex]
40
 
                set txnenv [is_txnenv $env]
41
 
                if { $txnenv == 1 } {
42
 
                        append args " -auto_commit "
43
 
                }
44
 
                set testdir [get_home $env]
45
 
        }
46
 
        cleanup $testdir $env
47
 
 
48
 
        set txn ""
49
 
        set key "test"
50
 
        set data "olddata"
51
 
 
52
 
        set db [eval {berkdb_open -create -mode 0644 -dup} $omethod $args \
53
 
            $testfile]
54
 
        error_check_good db_open [is_valid_db $db] TRUE
55
 
 
56
 
        if { $txnenv == 1 } {
57
 
                set t [$env txn]
58
 
                error_check_good txn [is_valid_txn $t $env] TRUE
59
 
                set txn "-txn $t"
60
 
        }
61
 
        set ret [eval {$db put} $txn {$key [chop_data $method $data]}]
62
 
        error_check_good db_put $ret 0
63
 
        if { $txnenv == 1 } {
64
 
                error_check_good txn [$t commit] 0
65
 
        }
66
 
 
67
 
        if { $txnenv == 1 } {
68
 
                set t [$env txn]
69
 
                error_check_good txn [is_valid_txn $t $env] TRUE
70
 
                set txn "-txn $t"
71
 
        }
72
 
        set dbc [eval {$db cursor} $txn]
73
 
        error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
74
 
 
75
 
        set ret [$dbc get -first]
76
 
        error_check_good db_get $ret [list [list $key [pad_data $method $data]]]
77
 
 
78
 
        set newdata "newdata"
79
 
        set ret [$dbc put -current [chop_data $method $newdata]]
80
 
        error_check_good dbc_put $ret 0
81
 
 
82
 
        # There should be only one (key,data) pair in the database, and this
83
 
        # is it.
84
 
        set ret [$dbc get -first]
85
 
        error_check_good db_get_first $ret \
86
 
            [list [list $key [pad_data $method $newdata]]]
87
 
 
88
 
        # and this one should come up empty.
89
 
        set ret [$dbc get -next]
90
 
        error_check_good db_get_next $ret ""
91
 
 
92
 
        error_check_good dbc_close [$dbc close] 0
93
 
        if { $txnenv == 1 } {
94
 
                error_check_good txn [$t commit] 0
95
 
        }
96
 
        error_check_good db_close [$db close] 0
97
 
 
98
 
        puts "\tTest0$tnum: Test completed successfully."
99
 
}