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

« back to all changes in this revision

Viewing changes to libdb/perl/BerkeleyDB/t/destroy.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..15\n";
16
 
 
17
 
my $Dfile = "dbhash.tmp";
18
 
my $home = "./fred" ;
19
 
 
20
 
umask(0);
21
 
 
22
 
{
23
 
    # let object destruction kill everything
24
 
 
25
 
    my $lex = new LexFile $Dfile ;
26
 
    my %hash ;
27
 
    my $value ;
28
 
 
29
 
    ok 1, my $lexD = new LexDir($home) ;
30
 
    ok 2, my $env = new BerkeleyDB::Env -Home => $home,
31
 
                                     -Flags => DB_CREATE|DB_INIT_TXN|
32
 
                                                DB_INIT_MPOOL|DB_INIT_LOCK ;
33
 
    ok 3, my $txn = $env->txn_begin() ;
34
 
    ok 4, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
35
 
                                                -Flags     => DB_CREATE ,
36
 
                                                -Env       => $env,
37
 
                                                -Txn       => $txn  ;
38
 
 
39
 
    ok 5, $txn->txn_commit() == 0 ;
40
 
    ok 6, $txn = $env->txn_begin() ;
41
 
    $db1->Txn($txn);
42
 
    
43
 
    # create some data
44
 
    my %data =  (
45
 
                "red"   => "boat",
46
 
                "green" => "house",
47
 
                "blue"  => "sea",
48
 
                ) ;
49
 
 
50
 
    my $ret = 0 ;
51
 
    while (my ($k, $v) = each %data) {
52
 
        $ret += $db1->db_put($k, $v) ;
53
 
    }
54
 
    ok 7, $ret == 0 ;
55
 
 
56
 
    # should be able to see all the records
57
 
 
58
 
    ok 8, my $cursor = $db1->db_cursor() ;
59
 
    my ($k, $v) = ("", "") ;
60
 
    my $count = 0 ;
61
 
    # sequence forwards
62
 
    while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
63
 
        ++ $count ;
64
 
    }
65
 
    ok 9, $count == 3 ;
66
 
    undef $cursor ;
67
 
 
68
 
    # now abort the transaction
69
 
    ok 10, $txn->txn_abort() == 0 ;
70
 
 
71
 
    # there shouldn't be any records in the database
72
 
    $count = 0 ;
73
 
    # sequence forwards
74
 
    ok 11, $cursor = $db1->db_cursor() ;
75
 
    while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
76
 
        ++ $count ;
77
 
    }
78
 
    ok 12, $count == 0 ;
79
 
 
80
 
    #undef $txn ;
81
 
    #undef $cursor ;
82
 
    #undef $db1 ;
83
 
    #undef $env ;
84
 
    #untie %hash ;
85
 
 
86
 
}
87
 
 
88
 
{
89
 
    my $lex = new LexFile $Dfile ;
90
 
    my %hash ;
91
 
    my $cursor ;
92
 
    my ($k, $v) = ("", "") ;
93
 
    ok 13, my $db1 = tie %hash, 'BerkeleyDB::Hash', 
94
 
                -Filename       => $Dfile,
95
 
                -Flags          => DB_CREATE ;
96
 
    my $count = 0 ;
97
 
    # sequence forwards
98
 
    ok 14, $cursor = $db1->db_cursor() ;
99
 
    while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
100
 
        ++ $count ;
101
 
    }
102
 
    ok 15, $count == 0 ;
103
 
}
104
 
 
105