File: cds.t

package info (click to toggle)
libberkeleydb-perl 0.66-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,996 kB
  • sloc: perl: 10,202; ansic: 6,484; makefile: 7
file content (73 lines) | stat: -rw-r--r-- 1,366 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!./perl -w

# Tests for Concurrent Data Store mode

use strict ;
use lib 't' ;

use BerkeleyDB;
use util ;
use Test::More;



BEGIN {
    plan(skip_all => "this needs BerkeleyDB 2.x or better" )
        if $BerkeleyDB::db_version < 2;

    plan tests => 12;
}


my $Dfile = "dbhash.tmp";
unlink $Dfile;

umask(0) ;

{
    # Error case -- env not opened in CDS mode

    my $lex = new LexFile $Dfile ;

    my $home = "./fred" ;
    ok my $lexD = new LexDir($home) ;

    ok my $env = new BerkeleyDB::Env -Flags => DB_CREATE|DB_INIT_MPOOL,
    					 -Home => $home, @StdErrFile ;

    ok my $db = new BerkeleyDB::Btree -Filename => $Dfile,
				    -Env      => $env,
				    -Flags    => DB_CREATE ;

    ok ! $env->cds_enabled() ;
    ok ! $db->cds_enabled() ;

    eval { $db->cds_lock() };
    ok $@ =~ /CDS not enabled for this database/;

    undef $db;
    undef $env ;
}

{
    my $lex = new LexFile $Dfile ;

    my $home = "./fred" ;
    ok my $lexD = new LexDir($home) ;

    ok my $env = new BerkeleyDB::Env -Flags => DB_INIT_CDB|DB_CREATE|DB_INIT_MPOOL,
    					 -Home => $home, @StdErrFile ;

    ok my $db = new BerkeleyDB::Btree -Filename => $Dfile,
				    -Env      => $env,
				    -Flags    => DB_CREATE ;

    ok $env->cds_enabled() ;
    ok $db->cds_enabled() ;

    my $cds = $db->cds_lock() ;
    ok $cds ;

    undef $db;
    undef $env ;
}