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

« back to all changes in this revision

Viewing changes to libdb/test/log002.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.10.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 128.
  • Revision ID: james.westby@ubuntu.com-20100517170206-xu1wmjuy40nt2sk0
Tags: upstream-2.30.1
ImportĀ upstreamĀ versionĀ 2.30.1

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  log002
10
 
# TEST  Tests multiple logs
11
 
# TEST          Log truncation
12
 
# TEST          LSN comparison and file functionality.
13
 
proc log002 { } {
14
 
        source ./include.tcl
15
 
 
16
 
        puts "Log002: Multiple log test w/trunc, file, compare functionality"
17
 
 
18
 
        env_cleanup $testdir
19
 
 
20
 
        set max [expr 1024 * 128]
21
 
        set env [berkdb_env -create -home $testdir -mode 0644 \
22
 
            -log -log_max $max]
23
 
        error_check_good envopen [is_valid_env $env] TRUE
24
 
 
25
 
        # We'll record every hundred'th record for later use
26
 
        set info_list {}
27
 
 
28
 
        puts "\tLog002.a: Writing log records"
29
 
        set i 0
30
 
        for {set s 0} { $s <  [expr 3 * $max] } { incr s $len } {
31
 
                set rec [random_data 120 0 0]
32
 
                set len [string length $rec]
33
 
                set lsn [$env log_put $rec]
34
 
 
35
 
                if { [expr $i % 100 ] == 0 } {
36
 
                        lappend info_list [list $lsn $rec]
37
 
                }
38
 
                incr i
39
 
        }
40
 
 
41
 
        puts "\tLog002.b: Checking log_compare"
42
 
        set last {0 0}
43
 
        foreach p $info_list {
44
 
                set l [lindex $p 0]
45
 
                if { [llength $last] != 0 } {
46
 
                        error_check_good \
47
 
                            log_compare [$env log_compare $l $last] 1
48
 
                        error_check_good \
49
 
                            log_compare [$env log_compare $last $l] -1
50
 
                        error_check_good \
51
 
                            log_compare [$env log_compare $l $l] 0
52
 
                }
53
 
                set last $l
54
 
        }
55
 
 
56
 
        puts "\tLog002.c: Checking log_file"
57
 
        set flist [glob $testdir/log*]
58
 
        foreach p $info_list {
59
 
 
60
 
                set lsn [lindex $p 0]
61
 
                set f [$env log_file $lsn]
62
 
 
63
 
                # Change all backslash separators on Windows to forward slash
64
 
                # separators, which is what the rest of the test suite expects.
65
 
                regsub -all {\\} $f {/} f
66
 
 
67
 
                error_check_bad log_file:$f [lsearch $flist $f] -1
68
 
        }
69
 
 
70
 
        puts "\tLog002.d: Verifying records"
71
 
 
72
 
        set logc [$env log_cursor]
73
 
        error_check_good log_cursor [is_valid_logc $logc $env] TRUE
74
 
 
75
 
        for {set i [expr [llength $info_list] - 1] } { $i >= 0 } { incr i -1} {
76
 
                set p [lindex $info_list $i]
77
 
                set grec [$logc get -set [lindex $p 0]]
78
 
                error_check_good log_get:$env [lindex $grec 1] [lindex $p 1]
79
 
        }
80
 
 
81
 
        # Close and unlink the file
82
 
        error_check_good log_cursor:close:$logc [$logc close] 0
83
 
        error_check_good env:close [$env close] 0
84
 
        error_check_good envremove [berkdb envremove -home $testdir] 0
85
 
}