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