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

« back to all changes in this revision

Viewing changes to libdb/perl/BerkeleyDB/t/strict.t

  • 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
 
#!./perl -w
2
 
 
3
 
use strict ;
4
 
 
5
 
BEGIN {
6
 
    unless(grep /blib/, @INC) {
7
 
        chdir 't' if -d 't';
8
 
        @INC = '../lib' if -d '../lib';
9
 
    }
10
 
}
11
 
 
12
 
use BerkeleyDB; 
13
 
use t::util ;
14
 
 
15
 
print "1..44\n";
16
 
 
17
 
my $Dfile = "dbhash.tmp";
18
 
my $home = "./fred" ;
19
 
 
20
 
umask(0);
21
 
 
22
 
{
23
 
    # closing a database & an environment in the correct order.
24
 
    my $lex = new LexFile $Dfile ;
25
 
    my %hash ;
26
 
    my $status ;
27
 
 
28
 
    ok 1, my $lexD = new LexDir($home);
29
 
    ok 2, my $env = new BerkeleyDB::Env -Home => $home,
30
 
                                     -Flags => DB_CREATE|DB_INIT_TXN|
31
 
                                                DB_INIT_MPOOL|DB_INIT_LOCK ;
32
 
                                                
33
 
    ok 3, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
34
 
                                                -Flags     => DB_CREATE ,
35
 
                                                -Env       => $env;
36
 
 
37
 
    ok 4, $db1->db_close() == 0 ; 
38
 
 
39
 
    eval { $status = $env->db_appexit() ; } ;
40
 
    ok 5, $status == 0 ;
41
 
    ok 6, $@ eq "" ;
42
 
    #print "[$@]\n" ;
43
 
 
44
 
}
45
 
 
46
 
{
47
 
    # closing an environment with an open database
48
 
    my $lex = new LexFile $Dfile ;
49
 
    my %hash ;
50
 
 
51
 
    ok 7, my $lexD = new LexDir($home);
52
 
    ok 8, my $env = new BerkeleyDB::Env -Home => $home,
53
 
                                     -Flags => DB_CREATE|DB_INIT_TXN|
54
 
                                                DB_INIT_MPOOL|DB_INIT_LOCK ;
55
 
                                                
56
 
    ok 9, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
57
 
                                                -Flags     => DB_CREATE ,
58
 
                                                -Env       => $env;
59
 
 
60
 
    eval { $env->db_appexit() ; } ;
61
 
    ok 10, $@ =~ /BerkeleyDB Aborting: attempted to close an environment with 1 open database/ ;
62
 
    #print "[$@]\n" ;
63
 
 
64
 
    undef $db1 ;
65
 
    untie %hash ;
66
 
    undef $env ;
67
 
}
68
 
 
69
 
{
70
 
    # closing a transaction & a database 
71
 
    my $lex = new LexFile $Dfile ;
72
 
    my %hash ;
73
 
    my $status ;
74
 
 
75
 
    ok 11, my $lexD = new LexDir($home);
76
 
    ok 12, my $env = new BerkeleyDB::Env -Home => $home,
77
 
                                     -Flags => DB_CREATE|DB_INIT_TXN|
78
 
                                                DB_INIT_MPOOL|DB_INIT_LOCK ;
79
 
 
80
 
    ok 13, my $txn = $env->txn_begin() ;
81
 
    ok 14, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
82
 
                                                -Flags     => DB_CREATE ,
83
 
                                                -Env       => $env,
84
 
                                                -Txn       => $txn  ;
85
 
 
86
 
    ok 15, $txn->txn_commit()  == 0 ;
87
 
    eval { $status = $db->db_close() ; } ;
88
 
    ok 16, $status == 0 ;
89
 
    ok 17, $@ eq "" ;
90
 
    #print "[$@]\n" ;
91
 
    eval { $status = $env->db_appexit() ; } ;
92
 
    ok 18, $status == 0 ;
93
 
    ok 19, $@ eq "" ;
94
 
    #print "[$@]\n" ;
95
 
}
96
 
 
97
 
{
98
 
    # closing a database with an open transaction
99
 
    my $lex = new LexFile $Dfile ;
100
 
    my %hash ;
101
 
 
102
 
    ok 20, my $lexD = new LexDir($home);
103
 
    ok 21, my $env = new BerkeleyDB::Env -Home => $home,
104
 
                                     -Flags => DB_CREATE|DB_INIT_TXN|
105
 
                                                DB_INIT_MPOOL|DB_INIT_LOCK ;
106
 
 
107
 
    ok 22, my $txn = $env->txn_begin() ;
108
 
    ok 23, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
109
 
                                                -Flags     => DB_CREATE ,
110
 
                                                -Env       => $env,
111
 
                                                -Txn       => $txn  ;
112
 
 
113
 
    eval { $db->db_close() ; } ;
114
 
    ok 24, $@ =~ /BerkeleyDB Aborting: attempted to close a database while a transaction was still open at/ ;
115
 
    #print "[$@]\n" ;
116
 
}
117
 
 
118
 
{
119
 
    # closing a cursor & a database 
120
 
    my $lex = new LexFile $Dfile ;
121
 
    my %hash ;
122
 
    my $status ;
123
 
    ok 25, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
124
 
                                                -Flags     => DB_CREATE ;
125
 
    ok 26, my $cursor = $db->db_cursor() ;
126
 
    ok 27, $cursor->c_close() == 0 ;
127
 
    eval { $status = $db->db_close() ; } ;
128
 
    ok 28, $status == 0 ;
129
 
    ok 29, $@ eq "" ;
130
 
    #print "[$@]\n" ;
131
 
}
132
 
 
133
 
{
134
 
    # closing a database with an open cursor
135
 
    my $lex = new LexFile $Dfile ;
136
 
    my %hash ;
137
 
    ok 30, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
138
 
                                                -Flags     => DB_CREATE ;
139
 
    ok 31, my $cursor = $db->db_cursor() ;
140
 
    eval { $db->db_close() ; } ;
141
 
    ok 32, $@ =~ /\QBerkeleyDB Aborting: attempted to close a database with 1 open cursor(s) at/;
142
 
    #print "[$@]\n" ;
143
 
}
144
 
 
145
 
{
146
 
    # closing a transaction & a cursor 
147
 
    my $lex = new LexFile $Dfile ;
148
 
    my %hash ;
149
 
    my $status ;
150
 
 
151
 
    ok 33, my $lexD = new LexDir($home);
152
 
    ok 34, my $env = new BerkeleyDB::Env -Home => $home,
153
 
                                     -Flags => DB_CREATE|DB_INIT_TXN|
154
 
                                                DB_INIT_MPOOL|DB_INIT_LOCK ;
155
 
    ok 35, my $txn = $env->txn_begin() ;
156
 
    ok 36, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
157
 
                                                -Flags     => DB_CREATE ,
158
 
                                                -Env       => $env,
159
 
                                                -Txn       => $txn  ;
160
 
    ok 37, my $cursor = $db->db_cursor() ;
161
 
    eval { $status = $cursor->c_close() ; } ;
162
 
    ok 38, $status == 0 ;
163
 
    ok 39, ($status = $txn->txn_commit())  == 0 ;
164
 
    ok 40, $@ eq "" ;
165
 
    eval { $status = $db->db_close() ; } ;
166
 
    ok 41, $status == 0 ;
167
 
    ok 42, $@ eq "" ;
168
 
    #print "[$@]\n" ;
169
 
    eval { $status = $env->db_appexit() ; } ;
170
 
    ok 43, $status == 0 ;
171
 
    ok 44, $@ eq "" ;
172
 
    #print "[$@]\n" ;
173
 
}
174