1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
6
# $Id: test060.tcl,v 11.10 2002/05/22 15:42:56 sue Exp $
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 } {
16
set args [convert_args $method $args]
17
set omethod [convert_method $method]
19
puts "Test060: $method ($args) Test of the DB_EXCL flag to DB->open"
21
# Set the database location and make sure the db doesn't exist yet
23
set eindex [lsearch -exact $args "-env"]
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
31
set testfile test060.db
33
set env [lindex $args $eindex]
34
set txnenv [is_txnenv $env]
36
append args " -auto_commit "
38
set testdir [get_home $env]
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
48
# Close it and check success
49
error_check_good db_close [$db close] 0
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"
54
error_check_good open:excl:catch [catch { \
55
set db [eval {berkdb_open_noerr \
56
-create -excl -mode 0644} $args {$omethod $testfile}]
59
error_check_good dbopen:excl [is_substr $errorCode EEXIST] 1