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

« back to all changes in this revision

Viewing changes to libdb/test/ndbm.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
 
# Historic NDBM interface test.
9
 
# Use the first 1000 entries from the dictionary.
10
 
# Insert each with self as key and data; retrieve each.
11
 
# After all are entered, retrieve all; compare output to original.
12
 
# Then reopen the file, re-retrieve everything.
13
 
# Finally, delete everything.
14
 
proc ndbm { { nentries 1000 } } {
15
 
        source ./include.tcl
16
 
 
17
 
        puts "NDBM interfaces test: $nentries"
18
 
 
19
 
        # Create the database and open the dictionary
20
 
        set testfile $testdir/ndbmtest
21
 
        set t1 $testdir/t1
22
 
        set t2 $testdir/t2
23
 
        set t3 $testdir/t3
24
 
        cleanup $testdir NULL
25
 
 
26
 
        set db [berkdb ndbm_open -create -truncate -mode 0644 $testfile]
27
 
        error_check_good ndbm_open [is_substr $db ndbm] 1
28
 
        set did [open $dict]
29
 
 
30
 
        error_check_good rdonly_false [$db rdonly] 0
31
 
 
32
 
        set flags 0
33
 
        set txn 0
34
 
        set count 0
35
 
        set skippednullkey 0
36
 
 
37
 
        puts "\tNDBM.a: put/get loop"
38
 
        # Here is the loop where we put and get each key/data pair
39
 
        while { [gets $did str] != -1 && $count < $nentries } {
40
 
                # NDBM can't handle zero-length keys
41
 
                if { [string length $str] == 0 } {
42
 
                        set skippednullkey 1
43
 
                        continue
44
 
                }
45
 
 
46
 
                set ret [$db store $str $str insert]
47
 
                error_check_good ndbm_store $ret 0
48
 
 
49
 
                set d [$db fetch $str]
50
 
                error_check_good ndbm_fetch $d $str
51
 
                incr count
52
 
        }
53
 
        close $did
54
 
 
55
 
        # Now we will get each key from the DB and compare the results
56
 
        # to the original.
57
 
        puts "\tNDBM.b: dump file"
58
 
        set oid [open $t1 w]
59
 
        for { set key [$db firstkey] } { $key != -1 } {
60
 
            set key [$db nextkey] } {
61
 
                puts $oid $key
62
 
                set d [$db fetch $key]
63
 
                error_check_good ndbm_refetch $d $key
64
 
        }
65
 
 
66
 
        # If we had to skip a zero-length key, juggle things to cover up
67
 
        # this fact in the dump.
68
 
        if { $skippednullkey == 1 } {
69
 
                puts $oid ""
70
 
                incr nentries 1
71
 
        }
72
 
        close $oid
73
 
 
74
 
        # Now compare the keys to see if they match the dictionary (or ints)
75
 
        set q q
76
 
        filehead $nentries $dict $t3
77
 
        filesort $t3 $t2
78
 
        filesort $t1 $t3
79
 
 
80
 
        error_check_good NDBM:diff($t3,$t2) \
81
 
            [filecmp $t3 $t2] 0
82
 
 
83
 
        # File descriptors tests won't work under Windows.
84
 
        if { $is_windows_test != 1 } {
85
 
                puts "\tNDBM.c: pagf/dirf test"
86
 
                set fd [$db pagfno]
87
 
                error_check_bad pagf $fd -1
88
 
                set fd [$db dirfno]
89
 
                error_check_bad dirf $fd -1
90
 
        }
91
 
 
92
 
        puts "\tNDBM.d: close, open, and dump file"
93
 
 
94
 
        # Now, reopen the file and run the last test again.
95
 
        error_check_good ndbm_close [$db close] 0
96
 
        set db [berkdb ndbm_open -rdonly $testfile]
97
 
        error_check_good ndbm_open2 [is_substr $db ndbm] 1
98
 
        set oid [open $t1 w]
99
 
 
100
 
        error_check_good rdonly_true [$db rdonly] "rdonly:not owner"
101
 
 
102
 
        for { set key [$db firstkey] } { $key != -1 } {
103
 
            set key [$db nextkey] } {
104
 
                puts $oid $key
105
 
                set d [$db fetch $key]
106
 
                error_check_good ndbm_refetch2 $d $key
107
 
        }
108
 
        if { $skippednullkey == 1 } {
109
 
                puts $oid ""
110
 
        }
111
 
        close $oid
112
 
 
113
 
        # Now compare the keys to see if they match the dictionary (or ints)
114
 
        filesort $t1 $t3
115
 
 
116
 
        error_check_good NDBM:diff($t2,$t3) \
117
 
            [filecmp $t2 $t3] 0
118
 
 
119
 
        # Now, reopen the file and delete each entry
120
 
        puts "\tNDBM.e: sequential scan and delete"
121
 
 
122
 
        error_check_good ndbm_close [$db close] 0
123
 
        set db [berkdb ndbm_open $testfile]
124
 
        error_check_good ndbm_open3 [is_substr $db ndbm] 1
125
 
        set oid [open $t1 w]
126
 
 
127
 
        for { set key [$db firstkey] } { $key != -1 } {
128
 
            set key [$db nextkey] } {
129
 
                puts $oid $key
130
 
                set ret [$db delete $key]
131
 
                error_check_good ndbm_delete $ret 0
132
 
        }
133
 
        if { $skippednullkey == 1 } {
134
 
                puts $oid ""
135
 
        }
136
 
        close $oid
137
 
 
138
 
        # Now compare the keys to see if they match the dictionary (or ints)
139
 
        filesort $t1 $t3
140
 
 
141
 
        error_check_good NDBM:diff($t2,$t3) \
142
 
            [filecmp $t2 $t3] 0
143
 
        error_check_good ndbm_close [$db close] 0
144
 
}