~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/test/env008.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

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-2001
 
4
#       Sleepycat Software.  All rights reserved.
 
5
#
 
6
# $Id: env008.tcl,v 11.3 2001/01/25 18:23:04 bostic Exp $
 
7
#
 
8
# Test of env and subdirs.
 
9
proc env008 { } {
 
10
        global errorInfo
 
11
        global errorCode
 
12
 
 
13
        source ./include.tcl
 
14
 
 
15
        env_cleanup $testdir
 
16
 
 
17
        set subdir  1/1
 
18
        set subdir1 1/2
 
19
        file mkdir $testdir/$subdir $testdir/$subdir1
 
20
        set testfile $subdir/env.db
 
21
 
 
22
        puts "Env008: Test of environments and subdirectories."
 
23
 
 
24
        # Try opening without Create flag should error
 
25
        puts "\tEnv008.a: Create env and db."
 
26
        set env [berkdb env -create -mode 0644 -home $testdir -txn]
 
27
        error_check_good env [is_valid_env $env] TRUE
 
28
 
 
29
        puts "\tEnv008.b: Remove db in subdir."
 
30
        env008_db $env $testfile
 
31
        error_check_good dbremove:$testfile \
 
32
            [berkdb dbremove -env $env $testfile] 0
 
33
 
 
34
        #
 
35
        # Rather than remaking the db every time for the renames
 
36
        # just move around the new file name to another new file
 
37
        # name.
 
38
        #
 
39
        puts "\tEnv008.c: Rename db in subdir."
 
40
        env008_db $env $testfile
 
41
        set newfile $subdir/new.db
 
42
        error_check_good dbrename:$testfile/.. \
 
43
            [berkdb dbrename -env $env $testfile $newfile] 0
 
44
        set testfile $newfile
 
45
 
 
46
        puts "\tEnv008.d: Rename db to parent dir."
 
47
        set newfile $subdir/../new.db
 
48
        error_check_good dbrename:$testfile/.. \
 
49
            [berkdb dbrename -env $env $testfile $newfile] 0
 
50
        set testfile $newfile
 
51
 
 
52
        puts "\tEnv008.e: Rename db to child dir."
 
53
        set newfile $subdir/env.db
 
54
        error_check_good dbrename:$testfile/.. \
 
55
            [berkdb dbrename -env $env $testfile $newfile] 0
 
56
        set testfile $newfile
 
57
 
 
58
        puts "\tEnv008.f: Rename db to another dir."
 
59
        set newfile $subdir1/env.db
 
60
        error_check_good dbrename:$testfile/.. \
 
61
            [berkdb dbrename -env $env $testfile $newfile] 0
 
62
 
 
63
        error_check_good envclose [$env close] 0
 
64
        puts "\tEnv008 complete."
 
65
}
 
66
 
 
67
proc env008_db { env testfile } {
 
68
        set db [berkdb_open -env $env -create -btree $testfile]
 
69
        error_check_good dbopen [is_valid_db $db] TRUE
 
70
        set ret [$db put key data]
 
71
        error_check_good dbput $ret 0
 
72
        error_check_good dbclose [$db close] 0
 
73
}