~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to bdb/test/test060.tcl

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

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: test060.tcl,v 11.10 2002/05/22 15:42:56 sue Exp $
 
7
#
 
8
# TEST  test060
 
9
# TEST  Test of the DB_EXCL flag to DB->open().
 
10
# TEST  1) Attempt to open and create a nonexistent database; verify success.
 
11
# TEST  2) Attempt to reopen it;  verify failure.
 
12
proc test060 { method args } {
 
13
        global errorCode
 
14
        source ./include.tcl
 
15
 
 
16
        set args [convert_args $method $args]
 
17
        set omethod [convert_method $method]
 
18
 
 
19
        puts "Test060: $method ($args) Test of the DB_EXCL flag to DB->open"
 
20
 
 
21
        # Set the database location and make sure the db doesn't exist yet
 
22
        set txnenv 0
 
23
        set eindex [lsearch -exact $args "-env"]
 
24
        #
 
25
        # If we are using an env, then testfile should just be the db name.
 
26
        # Otherwise it is the test directory and the name.
 
27
        if { $eindex == -1 } {
 
28
                set testfile $testdir/test060.db
 
29
                set env NULL
 
30
        } else {
 
31
                set testfile test060.db
 
32
                incr eindex
 
33
                set env [lindex $args $eindex]
 
34
                set txnenv [is_txnenv $env]
 
35
                if { $txnenv == 1 } {
 
36
                        append args " -auto_commit "
 
37
                }
 
38
                set testdir [get_home $env]
 
39
        }
 
40
        cleanup $testdir $env
 
41
 
 
42
        # Create the database and check success
 
43
        puts "\tTest060.a: open and close non-existent file with DB_EXCL"
 
44
        set db [eval {berkdb_open \
 
45
             -create  -excl -mode 0644} $args {$omethod $testfile}]
 
46
        error_check_good dbopen:excl [is_valid_db $db] TRUE
 
47
 
 
48
        # Close it and check success
 
49
        error_check_good db_close [$db close] 0
 
50
 
 
51
        # Try to open it again, and make sure the open fails
 
52
        puts "\tTest060.b: open it again with DB_EXCL and make sure it fails"
 
53
        set errorCode NONE
 
54
        error_check_good open:excl:catch [catch { \
 
55
            set db [eval {berkdb_open_noerr \
 
56
             -create  -excl -mode 0644} $args {$omethod $testfile}]
 
57
            } ret ] 1
 
58
 
 
59
        error_check_good dbopen:excl [is_substr $errorCode EEXIST] 1
 
60
}