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

« back to all changes in this revision

Viewing changes to libdb/test/recd017.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  recd017
9
 
# TEST  Test recovery and security.  This is basically a watered
10
 
# TEST  down version of recd001 just to verify that encrypted environments
11
 
# TEST  can be recovered.
12
 
proc recd017 { method {select 0} args} {
13
 
        global fixed_len
14
 
        global encrypt
15
 
        global passwd
16
 
        source ./include.tcl
17
 
 
18
 
        set orig_fixed_len $fixed_len
19
 
        set opts [convert_args $method $args]
20
 
        set omethod [convert_method $method]
21
 
 
22
 
        puts "Recd017: $method operation/transaction tests"
23
 
 
24
 
        # Create the database and environment.
25
 
        env_cleanup $testdir
26
 
 
27
 
        # The recovery tests were originally written to
28
 
        # do a command, abort, do it again, commit, and then
29
 
        # repeat the sequence with another command.  Each command
30
 
        # tends to require that the previous command succeeded and
31
 
        # left the database a certain way.  To avoid cluttering up the
32
 
        # op_recover interface as well as the test code, we create two
33
 
        # databases;  one does abort and then commit for each op, the
34
 
        # other does prepare, prepare-abort, and prepare-commit for each
35
 
        # op.  If all goes well, this allows each command to depend
36
 
        # exactly one successful iteration of the previous command.
37
 
        set testfile recd017.db
38
 
        set testfile2 recd017-2.db
39
 
 
40
 
        set flags "-create -encryptaes $passwd -txn -home $testdir"
41
 
 
42
 
        puts "\tRecd017.a.0: creating environment"
43
 
        set env_cmd "berkdb_env $flags"
44
 
        convert_encrypt $env_cmd
45
 
        set dbenv [eval $env_cmd]
46
 
        error_check_good dbenv [is_valid_env $dbenv] TRUE
47
 
 
48
 
        #
49
 
        # We need to create a database to get the pagesize (either
50
 
        # the default or whatever might have been specified).
51
 
        # Then remove it so we can compute fixed_len and create the
52
 
        # real database.
53
 
        set oflags "-create $omethod -mode 0644 \
54
 
            -env $dbenv -encrypt $opts $testfile"
55
 
        set db [eval {berkdb_open} $oflags]
56
 
        error_check_good db_open [is_valid_db $db] TRUE
57
 
        set stat [$db stat]
58
 
        #
59
 
        # Compute the fixed_len based on the pagesize being used.
60
 
        # We want the fixed_len to be 1/4 the pagesize.
61
 
        #
62
 
        set pg [get_pagesize $stat]
63
 
        error_check_bad get_pagesize $pg -1
64
 
        set fixed_len [expr $pg / 4]
65
 
        error_check_good db_close [$db close] 0
66
 
        error_check_good dbremove [berkdb dbremove -env $dbenv $testfile] 0
67
 
 
68
 
        # Convert the args again because fixed_len is now real.
69
 
        # Create the databases and close the environment.
70
 
        # cannot specify db truncate in txn protected env!!!
71
 
        set opts [convert_args $method ""]
72
 
        convert_encrypt $env_cmd
73
 
        set omethod [convert_method $method]
74
 
        set oflags "-create $omethod -mode 0644 \
75
 
            -env $dbenv -encrypt $opts $testfile"
76
 
        set db [eval {berkdb_open} $oflags]
77
 
        error_check_good db_open [is_valid_db $db] TRUE
78
 
        error_check_good db_close [$db close] 0
79
 
 
80
 
        set oflags "-create $omethod -mode 0644 \
81
 
            -env $dbenv -encrypt $opts $testfile2"
82
 
        set db [eval {berkdb_open} $oflags]
83
 
        error_check_good db_open [is_valid_db $db] TRUE
84
 
        error_check_good db_close [$db close] 0
85
 
 
86
 
        error_check_good env_close [$dbenv close] 0
87
 
 
88
 
        puts "\tRecd017.a.1: Verify db_printlog can read logfile"
89
 
        set tmpfile $testdir/printlog.out
90
 
        set stat [catch {exec $util_path/db_printlog -h $testdir -P $passwd \
91
 
            > $tmpfile} ret]
92
 
        error_check_good db_printlog $stat 0
93
 
        fileremove $tmpfile
94
 
 
95
 
        # List of recovery tests: {CMD MSG} pairs.
96
 
        set rlist {
97
 
        { {DB put -txn TXNID $key $data}        "Recd017.b: put"}
98
 
        { {DB del -txn TXNID $key}              "Recd017.c: delete"}
99
 
        }
100
 
 
101
 
        # These are all the data values that we're going to need to read
102
 
        # through the operation table and run the recovery tests.
103
 
 
104
 
        if { [is_record_based $method] == 1 } {
105
 
                set key 1
106
 
        } else {
107
 
                set key recd017_key
108
 
        }
109
 
        set data recd017_data
110
 
        foreach pair $rlist {
111
 
                set cmd [subst [lindex $pair 0]]
112
 
                set msg [lindex $pair 1]
113
 
                if { $select != 0 } {
114
 
                        set tag [lindex $msg 0]
115
 
                        set tail [expr [string length $tag] - 2]
116
 
                        set tag [string range $tag $tail $tail]
117
 
                        if { [lsearch $select $tag] == -1 } {
118
 
                                continue
119
 
                        }
120
 
                }
121
 
 
122
 
                if { [is_queue $method] != 1 } {
123
 
                        if { [string first append $cmd] != -1 } {
124
 
                                continue
125
 
                        }
126
 
                        if { [string first consume $cmd] != -1 } {
127
 
                                continue
128
 
                        }
129
 
                }
130
 
 
131
 
#               if { [is_fixed_length $method] == 1 } {
132
 
#                       if { [string first partial $cmd] != -1 } {
133
 
#                               continue
134
 
#                       }
135
 
#               }
136
 
                op_recover abort $testdir $env_cmd $testfile $cmd $msg
137
 
                op_recover commit $testdir $env_cmd $testfile $cmd $msg
138
 
                #
139
 
                # Note that since prepare-discard ultimately aborts
140
 
                # the txn, it must come before prepare-commit.
141
 
                #
142
 
                op_recover prepare-abort $testdir $env_cmd $testfile2 \
143
 
                    $cmd $msg
144
 
                op_recover prepare-discard $testdir $env_cmd $testfile2 \
145
 
                    $cmd $msg
146
 
                op_recover prepare-commit $testdir $env_cmd $testfile2 \
147
 
                    $cmd $msg
148
 
        }
149
 
        set fixed_len $orig_fixed_len
150
 
        return
151
 
}