test060.tcl
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

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