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

« back to all changes in this revision

Viewing changes to libdb/test/log001.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
 
 
9
 
# TEST  log001
10
 
# TEST  Read/write log records.
11
 
proc log001 { } {
12
 
        global passwd
13
 
        global rand_init
14
 
 
15
 
        berkdb srand $rand_init
16
 
        set iter 1000
17
 
        set max [expr 1024 * 128]
18
 
        log001_body $max $iter 1
19
 
        log001_body $max $iter 0
20
 
        log001_body $max $iter 1 "-encryptaes $passwd"
21
 
        log001_body $max $iter 0 "-encryptaes $passwd"
22
 
        log001_body $max [expr $iter * 15] 1
23
 
        log001_body $max [expr $iter * 15] 0
24
 
        log001_body $max [expr $iter * 15] 1 "-encryptaes $passwd"
25
 
        log001_body $max [expr $iter * 15] 0 "-encryptaes $passwd"
26
 
}
27
 
 
28
 
proc log001_body { max nrecs fixedlength {encargs ""} } {
29
 
        source ./include.tcl
30
 
 
31
 
        puts -nonewline "Log001: Basic put/get log records "
32
 
        if { $fixedlength == 1 } {
33
 
                puts "(fixed-length $encargs)"
34
 
        } else {
35
 
                puts "(variable-length $encargs)"
36
 
        }
37
 
 
38
 
        env_cleanup $testdir
39
 
 
40
 
        set env [eval {berkdb_env -log -create -home $testdir -mode 0644} \
41
 
            $encargs -log_max $max]
42
 
        error_check_good envopen [is_valid_env $env] TRUE
43
 
 
44
 
        # We will write records to the log and make sure we can
45
 
        # read them back correctly.  We'll use a standard pattern
46
 
        # repeated some number of times for each record.
47
 
        set lsn_list {}
48
 
        set rec_list {}
49
 
        puts "\tLog001.a: Writing $nrecs log records"
50
 
        for { set i 0 } { $i < $nrecs } { incr i } {
51
 
                set rec ""
52
 
                for { set j 0 } { $j < [expr $i % 10 + 1] } {incr j} {
53
 
                        set rec $rec$i:logrec:$i
54
 
                }
55
 
                if { $fixedlength != 1 } {
56
 
                        set rec $rec:[random_data 237 0 0]
57
 
                }
58
 
                set lsn [$env log_put $rec]
59
 
                error_check_bad log_put [is_substr $lsn log_cmd] 1
60
 
                lappend lsn_list $lsn
61
 
                lappend rec_list $rec
62
 
        }
63
 
 
64
 
        # Open a log cursor.
65
 
        set logc [$env log_cursor]
66
 
        error_check_good logc [is_valid_logc $logc $env] TRUE
67
 
 
68
 
        puts "\tLog001.b: Retrieving log records sequentially (forward)"
69
 
        set i 0
70
 
        for { set grec [$logc get -first] } { [llength $grec] != 0 } {
71
 
                set grec [$logc get -next]} {
72
 
                error_check_good log_get:seq [lindex $grec 1] \
73
 
                                                 [lindex $rec_list $i]
74
 
                incr i
75
 
        }
76
 
 
77
 
        puts "\tLog001.c: Retrieving log records sequentially (backward)"
78
 
        set i [llength $rec_list]
79
 
        for { set grec [$logc get -last] } { [llength $grec] != 0 } {
80
 
            set grec [$logc get -prev] } {
81
 
                incr i -1
82
 
                error_check_good \
83
 
                    log_get:seq [lindex $grec 1] [lindex $rec_list $i]
84
 
        }
85
 
 
86
 
        puts "\tLog001.d: Retrieving log records sequentially by LSN"
87
 
        set i 0
88
 
        foreach lsn $lsn_list {
89
 
                set grec [$logc get -set $lsn]
90
 
                error_check_good \
91
 
                    log_get:seq [lindex $grec 1] [lindex $rec_list $i]
92
 
                incr i
93
 
        }
94
 
 
95
 
        puts "\tLog001.e: Retrieving log records randomly by LSN"
96
 
        set m [expr [llength $lsn_list] - 1]
97
 
        for { set i 0 } { $i < $nrecs } { incr i } {
98
 
                set recno [berkdb random_int 0 $m ]
99
 
                set lsn [lindex $lsn_list $recno]
100
 
                set grec [$logc get -set $lsn]
101
 
                error_check_good \
102
 
                    log_get:seq [lindex $grec 1] [lindex $rec_list $recno]
103
 
        }
104
 
 
105
 
        puts "\tLog001.f: Retrieving first/current, last/current log record"
106
 
        set grec [$logc get -first]
107
 
        error_check_good log_get:seq [lindex $grec 1] [lindex $rec_list 0]
108
 
        set grec [$logc get -current]
109
 
        error_check_good log_get:seq [lindex $grec 1] [lindex $rec_list 0]
110
 
        set i [expr [llength $rec_list] - 1]
111
 
        set grec [$logc get -last]
112
 
        error_check_good log_get:seq [lindex $grec 1] [lindex $rec_list $i]
113
 
        set grec [$logc get -current]
114
 
        error_check_good log_get:seq [lindex $grec 1] [lindex $rec_list $i]
115
 
 
116
 
        # Close and unlink the file
117
 
        error_check_good log_cursor:close:$logc [$logc close] 0
118
 
        error_check_good env:close [$env close] 0
119
 
        error_check_good envremove [berkdb envremove -home $testdir] 0
120
 
}