6
unless(grep /blib/, @INC) {
8
@INC = '../lib' if -d '../lib';
13
use File::Path qw(rmtree);
40
print "not " unless $result ;
48
open(CAT,$file) || die "Cannot open $file:$!";
55
my $Dfile = "dbhash.tmp";
61
# closing a database & an environment in the correct order.
62
my $lex = new LexFile $Dfile ;
66
rmtree $home if -e $home ;
67
ok 1, mkdir($home, 0777) ;
68
ok 2, my $env = new BerkeleyDB::Env -Home => $home,
69
-Flags => DB_CREATE|DB_INIT_TXN|
70
DB_INIT_MPOOL|DB_INIT_LOCK ;
72
ok 3, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
76
ok 4, $db1->db_close() == 0 ;
78
eval { $status = $env->db_appexit() ; } ;
83
rmtree $home if -e $home ;
87
# closing an environment with an open database
88
my $lex = new LexFile $Dfile ;
91
rmtree $home if -e $home ;
92
ok 7, mkdir($home, 0777) ;
93
ok 8, my $env = new BerkeleyDB::Env -Home => $home,
94
-Flags => DB_CREATE|DB_INIT_TXN|
95
DB_INIT_MPOOL|DB_INIT_LOCK ;
97
ok 9, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
101
eval { $env->db_appexit() ; } ;
102
ok 10, $@ =~ /BerkeleyDB Aborting: attempted to close an environment with 1 open database/ ;
108
rmtree $home if -e $home ;
112
# closing a transaction & a database
113
my $lex = new LexFile $Dfile ;
117
rmtree $home if -e $home ;
118
ok 11, mkdir($home, 0777) ;
119
ok 12, my $env = new BerkeleyDB::Env -Home => $home,
120
-Flags => DB_CREATE|DB_INIT_TXN|
121
DB_INIT_MPOOL|DB_INIT_LOCK ;
123
ok 13, my $txn = $env->txn_begin() ;
124
ok 14, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
125
-Flags => DB_CREATE ,
129
ok 15, $txn->txn_commit() == 0 ;
130
eval { $status = $db->db_close() ; } ;
131
ok 16, $status == 0 ;
133
eval { $status = $env->db_appexit() ; } ;
134
ok 18, $status == 0 ;
140
# closing a database with an open transaction
141
my $lex = new LexFile $Dfile ;
144
rmtree $home if -e $home ;
145
ok 20, mkdir($home, 0777) ;
146
ok 21, my $env = new BerkeleyDB::Env -Home => $home,
147
-Flags => DB_CREATE|DB_INIT_TXN|
148
DB_INIT_MPOOL|DB_INIT_LOCK ;
150
ok 22, my $txn = $env->txn_begin() ;
151
ok 23, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
152
-Flags => DB_CREATE ,
156
eval { $db->db_close() ; } ;
157
ok 24, $@ =~ /BerkeleyDB Aborting: attempted to close a database while a transaction was still open at/ ;
162
# closing a cursor & a database
163
my $lex = new LexFile $Dfile ;
166
ok 25, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
167
-Flags => DB_CREATE ;
168
ok 26, my $cursor = $db->db_cursor() ;
169
ok 27, $cursor->c_close() == 0 ;
170
eval { $status = $db->db_close() ; } ;
171
ok 28, $status == 0 ;
174
rmtree $home if -e $home ;
178
# closing a database with an open cursor
179
my $lex = new LexFile $Dfile ;
181
ok 30, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
182
-Flags => DB_CREATE ;
183
ok 31, my $cursor = $db->db_cursor() ;
184
eval { $db->db_close() ; } ;
185
ok 32, $@ =~ /\QBerkeleyDB Aborting: attempted to close a database with 1 open cursor(s) at/;
187
rmtree $home if -e $home ;
191
# closing a transaction & a cursor
192
my $lex = new LexFile $Dfile ;
196
rmtree $home if -e $home ;
197
ok 33, mkdir($home, 0777) ;
198
ok 34, my $env = new BerkeleyDB::Env -Home => $home,
199
-Flags => DB_CREATE|DB_INIT_TXN|
200
DB_INIT_MPOOL|DB_INIT_LOCK ;
201
ok 35, my $txn = $env->txn_begin() ;
202
ok 36, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
203
-Flags => DB_CREATE ,
206
ok 37, my $cursor = $db->db_cursor() ;
207
eval { $status = $cursor->c_close() ; } ;
208
ok 38, $status == 0 ;
209
ok 39, ($status = $txn->txn_commit()) == 0 ;
211
eval { $status = $db->db_close() ; } ;
212
ok 41, $status == 0 ;
214
eval { $status = $env->db_appexit() ; } ;
215
ok 43, $status == 0 ;
218
rmtree $home if -e $home ;