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

« back to all changes in this revision

Viewing changes to libdb/test/log003.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  log003
10
 
# TEST  Verify that log_flush is flushing records correctly.
11
 
proc log003 { } {
12
 
        source ./include.tcl
13
 
 
14
 
        puts "Log003: Verify log_flush behavior"
15
 
 
16
 
        set max [expr 1024 * 128]
17
 
        env_cleanup $testdir
18
 
        set short_rec "abcdefghijklmnopqrstuvwxyz"
19
 
        set long_rec [repeat $short_rec 200]
20
 
        set very_long_rec [repeat $long_rec 4]
21
 
 
22
 
        foreach rec "$short_rec $long_rec $very_long_rec" {
23
 
                puts "\tLog003.a: Verify flush on [string length $rec] byte rec"
24
 
 
25
 
                set env [berkdb_env -log -home $testdir \
26
 
                                -create -mode 0644 -log_max $max]
27
 
                error_check_good envopen [is_valid_env $env] TRUE
28
 
 
29
 
                set lsn [$env log_put $rec]
30
 
                error_check_bad log_put [lindex $lsn 0] "ERROR:"
31
 
                set ret [$env log_flush $lsn]
32
 
                error_check_good log_flush $ret 0
33
 
 
34
 
                # Now, we want to crash the region and recheck.  Closing the
35
 
                # log does not flush any records, so we'll use a close to
36
 
                # do the "crash"
37
 
                set ret [$env close]
38
 
                error_check_good log_env:close $ret 0
39
 
 
40
 
                # Now, remove the log region
41
 
                #set ret [berkdb envremove -home $testdir]
42
 
                #error_check_good env:remove $ret 0
43
 
 
44
 
                # Re-open the log and try to read the record.
45
 
                set env [berkdb_env -create -home $testdir \
46
 
                                -log -mode 0644 -log_max $max]
47
 
                error_check_good envopen [is_valid_env $env] TRUE
48
 
 
49
 
                set logc [$env log_cursor]
50
 
                error_check_good log_cursor [is_valid_logc $logc $env] TRUE
51
 
 
52
 
                set gotrec [$logc get -first]
53
 
                error_check_good lp_get [lindex $gotrec 1] $rec
54
 
 
55
 
                # Close and unlink the file
56
 
                error_check_good log_cursor:close:$logc [$logc close] 0
57
 
                error_check_good env:close:$env [$env close] 0
58
 
                error_check_good envremove [berkdb envremove -home $testdir] 0
59
 
                log_cleanup $testdir
60
 
        }
61
 
 
62
 
        foreach rec "$short_rec $long_rec $very_long_rec" {
63
 
                puts "\tLog003.b: \
64
 
                    Verify flush on non-last record [string length $rec]"
65
 
                set env [berkdb_env \
66
 
                    -create -log -home $testdir -mode 0644 -log_max $max]
67
 
                error_check_good envopen [is_valid_env $env] TRUE
68
 
 
69
 
                # Put 10 random records
70
 
                for { set i 0 } { $i < 10 } { incr i} {
71
 
                        set r [random_data 450 0 0]
72
 
                        set lsn [$env log_put $r]
73
 
                        error_check_bad log_put [lindex $lsn 0] "ERROR:"
74
 
                }
75
 
 
76
 
                # Put the record we are interested in
77
 
                set save_lsn [$env log_put $rec]
78
 
                error_check_bad log_put [lindex $save_lsn 0] "ERROR:"
79
 
 
80
 
                # Put 10 more random records
81
 
                for { set i 0 } { $i < 10 } { incr i} {
82
 
                        set r [random_data 450 0 0]
83
 
                        set lsn [$env log_put $r]
84
 
                        error_check_bad log_put [lindex $lsn 0] "ERROR:"
85
 
                }
86
 
 
87
 
                # Now check the flush
88
 
                set ret [$env log_flush $save_lsn]
89
 
                error_check_good log_flush $ret 0
90
 
 
91
 
                # Now, we want to crash the region and recheck.  Closing the
92
 
                # log does not flush any records, so we'll use a close to
93
 
                # do the "crash"
94
 
 
95
 
                #
96
 
                # Now, close and remove the log region
97
 
                error_check_good env:close:$env [$env close] 0
98
 
                set ret [berkdb envremove -home $testdir]
99
 
                error_check_good env:remove $ret 0
100
 
 
101
 
                # Re-open the log and try to read the record.
102
 
                set env [berkdb_env \
103
 
                    -home $testdir -create -log -mode 0644 -log_max $max]
104
 
                error_check_good envopen [is_valid_env $env] TRUE
105
 
 
106
 
                set logc [$env log_cursor]
107
 
                error_check_good log_cursor [is_valid_logc $logc $env] TRUE
108
 
 
109
 
                set gotrec [$logc get -set $save_lsn]
110
 
                error_check_good lp_get [lindex $gotrec 1] $rec
111
 
 
112
 
                # Close and unlink the file
113
 
                error_check_good log_cursor:close:$logc [$logc close] 0
114
 
                error_check_good env:close:$env [$env close] 0
115
 
                error_check_good envremove [berkdb envremove -home $testdir] 0
116
 
                log_cleanup $testdir
117
 
        }
118
 
}