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

« back to all changes in this revision

Viewing changes to libdb/test/env002.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) 1999-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  env002
9
 
# TEST  Test of DB_LOG_DIR and env name resolution.
10
 
# TEST  With an environment path specified using -home, and then again
11
 
# TEST  with it specified by the environment variable DB_HOME:
12
 
# TEST  1) Make sure that the set_lg_dir option is respected
13
 
# TEST          a) as a relative pathname.
14
 
# TEST          b) as an absolute pathname.
15
 
# TEST  2) Make sure that the DB_LOG_DIR db_config argument is respected,
16
 
# TEST          again as relative and absolute pathnames.
17
 
# TEST  3) Make sure that if -both- db_config and a file are present,
18
 
# TEST          only the file is respected (see doc/env/naming.html).
19
 
proc env002 { } {
20
 
        #   env002 is essentially just a small driver that runs
21
 
        # env002_body--formerly the entire test--twice;  once, it
22
 
        # supplies a "home" argument to use with environment opens,
23
 
        # and the second time it sets DB_HOME instead.
24
 
        #   Note that env002_body itself calls env002_run_test to run
25
 
        # the body of the actual test and check for the presence
26
 
        # of logs.  The nesting, I hope, makes this test's structure simpler.
27
 
 
28
 
        global env
29
 
        source ./include.tcl
30
 
 
31
 
        puts "Env002: set_lg_dir test."
32
 
 
33
 
        puts "\tEnv002: Running with -home argument to berkdb_env."
34
 
        env002_body "-home $testdir"
35
 
 
36
 
        puts "\tEnv002: Running with environment variable DB_HOME set."
37
 
        set env(DB_HOME) $testdir
38
 
        env002_body "-use_environ"
39
 
 
40
 
        unset env(DB_HOME)
41
 
 
42
 
        puts "\tEnv002: Running with both DB_HOME and -home set."
43
 
        # Should respect -only- -home, so we give it a bogus
44
 
        # environment variable setting.
45
 
        set env(DB_HOME) $testdir/bogus_home
46
 
        env002_body "-use_environ -home $testdir"
47
 
        unset env(DB_HOME)
48
 
 
49
 
}
50
 
 
51
 
proc env002_body { home_arg } {
52
 
        source ./include.tcl
53
 
 
54
 
        env_cleanup $testdir
55
 
        set logdir "logs_in_here"
56
 
 
57
 
        file mkdir $testdir/$logdir
58
 
 
59
 
        # Set up full path to $logdir for when we test absolute paths.
60
 
        set curdir [pwd]
61
 
        cd $testdir/$logdir
62
 
        set fulllogdir [pwd]
63
 
        cd $curdir
64
 
 
65
 
        env002_make_config $logdir
66
 
 
67
 
        # Run the meat of the test.
68
 
        env002_run_test a 1 "relative path, config file" $home_arg \
69
 
                $testdir/$logdir
70
 
 
71
 
        env_cleanup $testdir
72
 
 
73
 
        file mkdir $fulllogdir
74
 
        env002_make_config $fulllogdir
75
 
 
76
 
        # Run the test again
77
 
        env002_run_test a 2 "absolute path, config file" $home_arg \
78
 
                $fulllogdir
79
 
 
80
 
        env_cleanup $testdir
81
 
 
82
 
        # Now we try without a config file, but instead with db_config
83
 
        # relative paths
84
 
        file mkdir $testdir/$logdir
85
 
        env002_run_test b 1 "relative path, db_config" "$home_arg \
86
 
                -log_dir $logdir -data_dir ." \
87
 
                $testdir/$logdir
88
 
 
89
 
        env_cleanup $testdir
90
 
 
91
 
        # absolute
92
 
        file mkdir $fulllogdir
93
 
        env002_run_test b 2 "absolute path, db_config" "$home_arg \
94
 
                -log_dir $fulllogdir -data_dir ." \
95
 
                $fulllogdir
96
 
 
97
 
        env_cleanup $testdir
98
 
 
99
 
        # Now, set db_config -and- have a # DB_CONFIG file, and make
100
 
        # sure only the latter is honored.
101
 
 
102
 
        file mkdir $testdir/$logdir
103
 
        env002_make_config $logdir
104
 
 
105
 
        # note that we supply a -nonexistent- log dir to db_config
106
 
        env002_run_test c 1 "relative path, both db_config and file" \
107
 
                "$home_arg -log_dir $testdir/bogus \
108
 
                -data_dir ." $testdir/$logdir
109
 
        env_cleanup $testdir
110
 
 
111
 
        file mkdir $fulllogdir
112
 
        env002_make_config $fulllogdir
113
 
 
114
 
        # note that we supply a -nonexistent- log dir to db_config
115
 
        env002_run_test c 2 "relative path, both db_config and file" \
116
 
                "$home_arg -log_dir $fulllogdir/bogus \
117
 
                -data_dir ." $fulllogdir
118
 
}
119
 
 
120
 
proc env002_run_test { major minor msg env_args log_path} {
121
 
        global testdir
122
 
        set testfile "env002.db"
123
 
 
124
 
        puts "\t\tEnv002.$major.$minor: $msg"
125
 
 
126
 
        # Create an environment, with logging, and scribble some
127
 
        # stuff in a [btree] database in it.
128
 
        # puts [concat {berkdb_env -create -log -private} $env_args]
129
 
        set dbenv [eval {berkdb_env -create -log -private} $env_args]
130
 
        error_check_good env_open [is_valid_env $dbenv] TRUE
131
 
        set db [berkdb_open -env $dbenv -create -btree -mode 0644 $testfile]
132
 
        error_check_good db_open [is_valid_db $db] TRUE
133
 
 
134
 
        set key "some_key"
135
 
        set data "some_data"
136
 
 
137
 
        error_check_good db_put \
138
 
                [$db put $key [chop_data btree $data]] 0
139
 
 
140
 
        error_check_good db_close [$db close] 0
141
 
        error_check_good env_close [$dbenv close] 0
142
 
 
143
 
        # Now make sure the log file is where we want it to be.
144
 
        error_check_good db_exists [file exists $testdir/$testfile] 1
145
 
        error_check_good log_exists \
146
 
                [file exists $log_path/log.0000000001] 1
147
 
}
148
 
 
149
 
proc env002_make_config { logdir } {
150
 
        global testdir
151
 
 
152
 
        set cid [open $testdir/DB_CONFIG w]
153
 
        puts $cid "set_data_dir ."
154
 
        puts $cid "set_lg_dir $logdir"
155
 
        close $cid
156
 
}