1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 1999-2009 Oracle. All rights reserved. 4# 5# $Id$ 6# 7# TEST env007 8# TEST Test DB_CONFIG config file options for berkdb env. 9# TEST 1) Make sure command line option is respected 10# TEST 2) Make sure that config file option is respected 11# TEST 3) Make sure that if -both- DB_CONFIG and the set_<whatever> 12# TEST method is used, only the file is respected. 13# TEST Then test all known config options. 14# TEST Also test config options on berkdb open. This isn't 15# TEST really env testing, but there's no better place to put it. 16proc env007 { } { 17 global errorInfo 18 global errorCode 19 global passwd 20 global has_crypto 21 source ./include.tcl 22 23 puts "Env007: DB_CONFIG and getters test." 24 puts "Env007.a: Test berkdb env options using getters and stat." 25 26 # Set up options we can check via stat or getters. Structure 27 # of the list is: 28 # 0. Arg used in berkdb env command 29 # 1. Arg used in DB_CONFIG file 30 # 2. Value assigned in berkdb env command 31 # 3. Value assigned in DB_CONFIG file 32 # 4. Message output during test 33 # 5. Stat command to run (empty if we can't get the info 34 # from stat). 35 # 6. String to search for in stat output 36 # 7. Which arg to check in stat (needed for cases where 37 # we set more than one args at a time, but stat can 38 # only check one args, like cachesize) 39 # 8. Arg used in getter 40 # 41 set rlist { 42 { " -txn_max " "set_tx_max" "19" "31" 43 "Env007.a1: Txn Max" "txn_stat" 44 "Maximum txns" "0" "get_tx_max" } 45 { " -lock_max_locks " "set_lk_max_locks" "1070" "1290" 46 "Env007.a2: Lock Max" "lock_stat" 47 "Maximum locks" "0" "get_lk_max_locks" } 48 { " -lock_max_lockers " "set_lk_max_lockers" "1500" "2000" 49 "Env007.a3: Max Lockers" "lock_stat" 50 "Maximum lockers" "0" "get_lk_max_lockers" } 51 { " -lock_max_objects " "set_lk_max_objects" "1500" "2000" 52 "Env007.a4: Max Objects" "lock_stat" 53 "Maximum objects" "0" "get_lk_max_objects" } 54 { " -log_buffer " "set_lg_bsize" "65536" "131072" 55 "Env007.a5: Log Bsize" "log_stat" 56 "Log record cache size" "0" "get_lg_bsize" } 57 { " -log_max " "set_lg_max" "8388608" "9437184" 58 "Env007.a6: Log Max" "log_stat" 59 "Current log file size" "0" "get_lg_max" } 60 { " -cachesize " "set_cachesize" "0 536870912 1" "1 0 1" 61 "Env007.a7.0: Cachesize" "mpool_stat" 62 "Cache size (gbytes)" "0" "get_cachesize" } 63 { " -cachesize " "set_cachesize" "0 536870912 1" "1 0 1" 64 "Env007.a7.1: Cachesize" "mpool_stat" 65 "Cache size (bytes)" "1" "get_cachesize" } 66 { " -cachesize " "set_cachesize" "0 536870912 1" "1 0 1" 67 "Env007.a7.2: Cachesize" "mpool_stat" 68 "Number of caches" "2" "get_cachesize" } 69 { " -lock_timeout " "set_lock_timeout" "100" "120" 70 "Env007.a8: Lock Timeout" "lock_stat" 71 "Lock timeout value" "0" "get_timeout lock" } 72 { " -log_regionmax " "set_lg_regionmax" "8388608" "4194304" 73 "Env007.a9: Log Regionmax" "log_stat" 74 "Region size" "0" "get_lg_regionmax" } 75 { " -mpool_max_openfd " "set_mp_max_openfd" "17" "27" 76 "Env007.a10: Mmap max openfd" "mpool_stat" 77 "Maximum open file descriptors" "0" "get_mp_max_openfd" } 78 { " -mpool_max_write " "set_mp_max_write" "37 47" "57 67" 79 "Env007.a11.0: Mmap max write" "mpool_stat" 80 "Maximum sequential buffer writes" "0" "get_mp_max_write" } 81 { " -mpool_max_write " "set_mp_max_write" "37 47" "57 67" 82 "Env007.a11.1: Mmap max write" "mpool_stat" 83 "Sleep after writing maximum buffers" "1" "get_mp_max_write" } 84 { " -mpool_mmap_size " "set_mp_mmapsize" "12582912" "8388608" 85 "Env007.a12: Mmapsize" "mpool_stat" 86 "Maximum memory-mapped file size" "0" "get_mp_mmapsize" } 87 { " -shm_key " "set_shm_key" "15" "35" 88 "Env007.a13: Shm Key" "" 89 "" "" "get_shm_key" } 90 { " -tmp_dir " "set_tmp_dir" "." "./TEMPDIR" 91 "Env007.a14: Temp dir" "" 92 "" "" "get_tmp_dir" } 93 { " -txn_timeout " "set_txn_timeout" "100" "120" 94 "Env007.a15: Txn timeout" "lock_stat" 95 "Transaction timeout value" "0" "get_timeout txn" } 96 { " -log_filemode " "set_lg_filemode" "417" "637" 97 "Env007.a16: Log FileMode" "log_stat" 98 "Log file mode" "0" "get_lg_filemode" } 99 } 100 101 set e "berkdb_env_noerr -create -mode 0644 -home $testdir -txn " 102 set qnxexclude {set_cachesize} 103 104 foreach item $rlist { 105 set envarg [lindex $item 0] 106 set configarg [lindex $item 1] 107 set envval [lindex $item 2] 108 set configval [lindex $item 3] 109 set msg [lindex $item 4] 110 set statcmd [lindex $item 5] 111 set statstr [lindex $item 6] 112 set index [lindex $item 7] 113 set getter [lindex $item 8] 114 115 if { $is_qnx_test && 116 [lsearch $qnxexclude $configarg] != -1 } { 117 puts "\tEnv007.a: Skipping $configarg for QNX" 118 continue 119 } 120 121 env_cleanup $testdir 122 123 # First verify using just env args 124 puts "\t$msg Environment argument only" 125 set env [eval $e $envarg {$envval}] 126 error_check_good envopen:0 [is_valid_env $env] TRUE 127 error_check_good get_envval [eval $env $getter] $envval 128 if { $statcmd != "" } { 129 set statenvval [lindex $envval $index] 130 # log_stat reports the sum of the specified 131 # region size and the log buffer size. 132 if { $statstr == "Region size" } { 133 set lbufsize 32768 134 set statenvval [expr $statenvval + $lbufsize] 135 } 136 env007_check $env $statcmd $statstr $statenvval 137 } 138 error_check_good envclose:0 [$env close] 0 139 140 env_cleanup $testdir 141 env007_make_config $configarg $configval 142 143 # Verify using just config file 144 puts "\t$msg Config file only" 145 set env [eval $e] 146 error_check_good envopen:1 [is_valid_env $env] TRUE 147 error_check_good get_configval1 [eval $env $getter] $configval 148 if { $statcmd != "" } { 149 set statconfigval [lindex $configval $index] 150 if { $statstr == "Region size" } { 151 set statconfigval \ 152 [expr $statconfigval + $lbufsize] 153 } 154 env007_check $env $statcmd $statstr $statconfigval 155 } 156 error_check_good envclose:1 [$env close] 0 157 158 # Now verify using env args and config args 159 puts "\t$msg Environment arg and config file" 160 set env [eval $e $envarg {$envval}] 161 error_check_good envopen:2 [is_valid_env $env] TRUE 162 # Getter should retrieve config val, not envval. 163 error_check_good get_configval2 [eval $env $getter] $configval 164 if { $statcmd != "" } { 165 env007_check $env $statcmd $statstr $statconfigval 166 } 167 error_check_good envclose:2 [$env close] 0 168 } 169 170 # 171 # Test all options that can be set in DB_CONFIG. Write it out 172 # to the file and make sure we can open the env. This execs 173 # the config file code. Also check with a getter that the 174 # expected value is returned. 175 # 176 puts "\tEnv007.b: Test berkdb env config options using getters\ 177 and env open." 178 179 # The cfglist variable contains options that can be set in DB_CONFIG. 180 set cfglist { 181 { "set_data_dir" "." "get_data_dirs" "." } 182 { "set_flags" "db_auto_commit" "get_flags" "-auto_commit" } 183 { "set_flags" "db_cdb_alldb" "get_flags" "-cdb_alldb" } 184 { "set_flags" "db_direct_db" "get_flags" "-direct_db" } 185 { "set_flags" "db_nolocking" "get_flags" "-nolock" } 186 { "set_flags" "db_nommap" "get_flags" "-nommap" } 187 { "set_flags" "db_nopanic" "get_flags" "-nopanic" } 188 { "set_flags" "db_overwrite" "get_flags" "-overwrite" } 189 { "set_flags" "db_region_init" "get_flags" "-region_init" } 190 { "set_flags" "db_txn_nosync" "get_flags" "-nosync" } 191 { "set_flags" "db_txn_write_nosync" "get_flags" "-wrnosync" } 192 { "set_flags" "db_yieldcpu" "get_flags" "-yield" } 193 { "set_lg_bsize" "65536" "get_lg_bsize" "65536" } 194 { "set_lg_dir" "." "get_lg_dir" "." } 195 { "set_lg_max" "8388608" "get_lg_max" "8388608" } 196 { "set_lg_regionmax" "262144" "get_lg_regionmax" "262144" } 197 { "set_lk_detect" "db_lock_default" "get_lk_detect" "default" } 198 { "set_lk_detect" "db_lock_expire" "get_lk_detect" "expire" } 199 { "set_lk_detect" "db_lock_maxlocks" "get_lk_detect" "maxlocks" } 200 { "set_lk_detect" "db_lock_minlocks" "get_lk_detect" "minlocks" } 201 { "set_lk_detect" "db_lock_minwrite" "get_lk_detect" "minwrite" } 202 { "set_lk_detect" "db_lock_oldest" "get_lk_detect" "oldest" } 203 { "set_lk_detect" "db_lock_random" "get_lk_detect" "random" } 204 { "set_lk_detect" "db_lock_youngest" "get_lk_detect" "youngest" } 205 { "set_lk_max_lockers" "1500" "get_lk_max_lockers" "1500" } 206 { "set_lk_max_locks" "1290" "get_lk_max_locks" "1290" } 207 { "set_lk_max_objects" "1500" "get_lk_max_objects" "1500" } 208 { "set_lock_timeout" "100" "get_timeout lock" "100" } 209 { "set_mp_mmapsize" "12582912" "get_mp_mmapsize" "12582912" } 210 { "set_mp_max_write" "10 20" "get_mp_max_write" "10 20" } 211 { "set_mp_max_openfd" "10" "get_mp_max_openfd" "10" } 212 { "set_region_init" "1" "get_flags" "-region_init" } 213 { "set_shm_key" "15" "get_shm_key" "15" } 214 { "set_tas_spins" "15" "get_tas_spins" "15" } 215 { "set_tmp_dir" "." "get_tmp_dir" "." } 216 { "set_tx_max" "31" "get_tx_max" "31" } 217 { "set_txn_timeout" "50" "get_timeout txn" "50" } 218 { "set_verbose" "db_verb_deadlock" "get_verbose deadlock" "on" } 219 { "set_verbose" "db_verb_fileops" "get_verbose fileops" "on" } 220 { "set_verbose" "db_verb_fileops_all" "get_verbose fileops_all" "on" } 221 { "set_verbose" "db_verb_recovery" "get_verbose recovery" "on" } 222 { "set_verbose" "db_verb_register" "get_verbose register" "on" } 223 { "set_verbose" "db_verb_replication" "get_verbose rep" "on" } 224 { "set_verbose" "db_verb_waitsfor" "get_verbose wait" "on" } 225 } 226 227 env_cleanup $testdir 228 set e "berkdb_env_noerr -create -mode 0644 -home $testdir -txn" 229 set directlist {db_direct_db} 230 231 foreach item $cfglist { 232 env_cleanup $testdir 233 set configarg [lindex $item 0] 234 set configval [lindex $item 1] 235 set getter [lindex $item 2] 236 set getval [lindex $item 3] 237 238 env007_make_config $configarg $configval 239 240 # Verify using config file 241 puts "\t\tEnv007.b: $configarg $configval" 242 243 # Unconfigured/unsupported direct I/O is not reported 244 # as a failure. 245 set directmsg \ 246 "direct I/O either not configured or not supported" 247 if {[catch { eval $e } env ]} { 248 if { [lsearch $directlist $configval] != -1 && \ 249 [is_substr $env $directmsg] == 1 } { 250 continue 251 } else { 252 puts "FAIL: $env" 253 continue 254 } 255 } 256 error_check_good envvalid:1 [is_valid_env $env] TRUE 257 error_check_good getter:1 [eval $env $getter] $getval 258 error_check_good envclose:1 [$env close] 0 259 } 260 261 puts "\tEnv007.c: Test berkdb env options using getters and env open." 262 # The envopenlist variable contains options that can be set using 263 # berkdb env. We always set -mpool. 264# { "-system_mem" "-shm_key 1" "-system_mem" "get_open_flags" } 265 set envopenlist { 266 { "-cdb" "" "-cdb" "get_open_flags" } 267 { "-errpfx" "FOO" "FOO" "get_errpfx" } 268 { "-lock" "" "-lock" "get_open_flags" } 269 { "-log" "" "-log" "get_open_flags" } 270 { "" "" "-mpool" "get_open_flags" } 271 { "-txn" "" "-txn" "get_open_flags" } 272 { "-recover" "-txn" "-recover" "get_open_flags" } 273 { "-recover_fatal" "-txn" "-recover_fatal" "get_open_flags" } 274 { "-register" "-txn -recover" "-register" "get_open_flags" } 275 { "-use_environ" "" "-use_environ" "get_open_flags" } 276 { "-use_environ_root" "" "-use_environ_root" "get_open_flags" } 277 { "" "" "-create" "get_open_flags" } 278 { "-private" "" "-private" "get_open_flags" } 279 { "-thread" "" "-thread" "get_open_flags" } 280 { "-txn_timestamp" "100000000" "100000000" "get_tx_timestamp" } 281 } 282 283 if { $has_crypto == 1 } { 284 lappend envopenlist { 285 "-encryptaes" "$passwd" "-encryptaes" "get_encrypt_flags" } 286 } 287 288 set e "berkdb_env_noerr -create -mode 0644 -home $testdir" 289 set qnxexclude {-system_mem} 290 foreach item $envopenlist { 291 env_cleanup $testdir 292 set envarg [lindex $item 0] 293 set envval [lindex $item 1] 294 set retval [lindex $item 2] 295 set getter [lindex $item 3] 296 297 if { $is_qnx_test && 298 [lsearch $qnxexclude $envarg] != -1} { 299 puts "\t\tEnv007: Skipping $envarg for QNX" 300 continue 301 } 302 303 puts "\t\tEnv007.c: $envarg $retval" 304 305 # Set up env 306 set ret [catch {eval $e $envarg $envval} env] 307 308 if { $ret != 0 } { 309 # If the env open failed, it may be because we're on a 310 # platform such as HP-UX 10 that won't support mutexes 311 # in shmget memory. Verify that the return value was 312 # EINVAL or EOPNOTSUPP and bail gracefully. 313 error_check_good \ 314 is_shm_test [is_substr $envarg -system_mem] 1 315 error_check_good returned_error [expr \ 316 [is_substr $errorCode EINVAL] || \ 317 [is_substr $errorCode EOPNOTSUPP]] 1 318 puts "Warning: platform\ 319 does not support mutexes in shmget memory." 320 puts "Skipping shared memory mpool test." 321 } else { 322 error_check_good env_open [is_valid_env $env] TRUE 323 324 # Check that getter retrieves expected retval. 325 set get_retval [eval $env $getter] 326 if { [is_substr $get_retval $retval] != 1 } { 327 puts "FAIL: $retval\ 328 should be a substring of $get_retval" 329 continue 330 } 331 error_check_good envclose [$env close] 0 332 333 # The -encryptany flag can only be tested on an existing 334 # environment that supports encryption, so do it here. 335 if { $has_crypto == 1 } { 336 if { $envarg == "-encryptaes" } { 337 set env [eval berkdb_env -home $testdir\ 338 -encryptany $passwd] 339 error_check_good get_encryptany \ 340 [eval $env get_encrypt_flags] \ 341 "-encryptaes" 342 error_check_good envclose [$env close] 0 343 } 344 } 345 } 346 } 347 348 puts "\tEnv007.d: Test berkdb env options using set_flags and getters." 349 350 # The flaglist variable contains options that can be set using 351 # $env set_flags. 352 set flaglist { 353 { "-direct_db" } 354 { "-nolock" } 355 { "-nommap" } 356 { "-nopanic" } 357 { "-nosync" } 358 { "-overwrite" } 359 { "-panic" } 360 { "-wrnosync" } 361 } 362 set e "berkdb_env_noerr -create -mode 0644 -home $testdir" 363 set directlist {-direct_db} 364 foreach item $flaglist { 365 set flag [lindex $item 0] 366 env_cleanup $testdir 367 368 # Set up env 369 set env [eval $e] 370 error_check_good envopen [is_valid_env $env] TRUE 371 372 # Use set_flags to turn on new env characteristics. 373 # 374 # Unconfigured/unsupported direct I/O is not reported 375 # as a failure. 376 if {[catch { $env set_flags $flag on } res ]} { 377 if { [lsearch $directlist $flag] != -1 && \ 378 [is_substr $res $directmsg] == 1 } { 379 error_check_good env_close [$env close] 0 380 continue 381 } else { 382 puts "FAIL: $res" 383 error_check_good env_close [$env close] 0 384 continue 385 } 386 } else { 387 error_check_good "flag $flag on" $res 0 388 } 389 390 # Check that getter retrieves expected retval. 391 set get_retval [eval $env get_flags] 392 if { [is_substr $get_retval $flag] != 1 } { 393 puts "FAIL: $flag should be a substring of $get_retval" 394 error_check_good env_close [$env close] 0 395 continue 396 } 397 # Use set_flags to turn off env characteristics, make sure 398 # they are gone. 399 error_check_good "flag $flag off" [$env set_flags $flag off] 0 400 set get_retval [eval $env get_flags] 401 if { [is_substr $get_retval $flag] == 1 } { 402 puts "FAIL: $flag should not be in $get_retval" 403 error_check_good env_close [$env close] 0 404 continue 405 } 406 407 error_check_good envclose [$env close] 0 408 } 409 puts "\tEnv007.d1: Test berkdb env options using set_log_config and getters." 410 411 # The flaglist variable contains options that can be set using 412 # $env log_config. 413 set flaglist { 414 { "autoremove" } 415 { "direct" } 416 { "dsync" } 417 { "zero" } 418 } 419 set e "berkdb_env_noerr -create -txn -mode 0644 -home $testdir" 420 set directlist {direct} 421 foreach item $flaglist { 422 set flag [lindex $item 0] 423 env_cleanup $testdir 424 425 # Set up env 426 set env [eval $e] 427 error_check_good envopen [is_valid_env $env] TRUE 428 429 # Use set_flags to turn on new env characteristics. 430 # 431 # Unconfigured/unsupported direct I/O is not reported 432 # as a failure. 433 if {[catch { $env log_config "$flag on" } res ]} { 434 if { [lsearch $directlist $flag] != -1 && \ 435 [is_substr $res $directmsg] == 1 } { 436 error_check_good env_close [$env close] 0 437 continue 438 } else { 439 puts "FAIL: $res" 440 error_check_good env_close [$env close] 0 441 continue 442 } 443 } else { 444 error_check_good "flag $flag on" $res 0 445 } 446 447 # Check that getter retrieves expected retval. 448 set get_retval [eval $env log_get_config $flag] 449 if { $get_retval != 1 } { 450 puts "FAIL: $flag is not on" 451 error_check_good env_close [$env close] 0 452 continue 453 } 454 # Use set_flags to turn off env characteristics, make sure 455 # they are gone. 456 error_check_good "flag $flag off" [$env log_config "$flag off"] 0 457 set get_retval [eval $env log_get_config $flag] 458 if { $get_retval == 1 } { 459 puts "FAIL: $flag should off" 460 error_check_good env_close [$env close] 0 461 continue 462 } 463 464 error_check_good envclose [$env close] 0 465 } 466 467 puts "\tEnv007.e: Test env get_home." 468 env_cleanup $testdir 469 # Set up env 470 set env [eval $e] 471 error_check_good env_open [is_valid_env $env] TRUE 472 # Test for correct value. 473 set get_retval [eval $env get_home] 474 error_check_good get_home $get_retval $testdir 475 error_check_good envclose [$env close] 0 476 477 puts "\tEnv007.f: Test that bad config values are rejected." 478 set cfglist { 479 { "set_cachesize" "1048576" } 480 { "set_flags" "db_xxx" } 481 { "set_flags" "1" } 482 { "set_flags" "db_txn_nosync x" } 483 { "set_lg_bsize" "db_xxx" } 484 { "set_lg_max" "db_xxx" } 485 { "set_lg_regionmax" "db_xxx" } 486 { "set_lk_detect" "db_xxx" } 487 { "set_lk_detect" "1" } 488 { "set_lk_detect" "db_lock_youngest x" } 489 { "set_lk_max_locks" "db_xxx" } 490 { "set_lk_max_lockers" "db_xxx" } 491 { "set_lk_max_objects" "db_xxx" } 492 { "set_mp_max_openfd" "1 2" } 493 { "set_mp_max_write" "1 2 3" } 494 { "set_mp_mmapsize" "db_xxx" } 495 { "set_region_init" "db_xxx" } 496 { "set_shm_key" "db_xxx" } 497 { "set_tas_spins" "db_xxx" } 498 { "set_tx_max" "db_xxx" } 499 { "set_verbose" "db_xxx" } 500 { "set_verbose" "1" } 501 { "set_verbose" "db_verb_recovery x" } 502 } 503 504 set e "berkdb_env_noerr -create -mode 0644 \ 505 -home $testdir -log -lock -txn " 506 foreach item $cfglist { 507 set configarg [lindex $item 0] 508 set configval [lindex $item 1] 509 510 env007_make_config $configarg $configval 511 512 # verify using just config file 513 set stat [catch {eval $e} ret] 514 error_check_good envopen $stat 1 515 error_check_good error [is_substr $errorCode EINVAL] 1 516 } 517 518 puts "\tEnv007.g: Config name error set_xxx" 519 set e "berkdb_env_noerr -create -mode 0644 \ 520 -home $testdir -log -lock -txn " 521 env007_make_config "set_xxx" 1 522 set stat [catch {eval $e} ret] 523 error_check_good envopen $stat 1 524 error_check_good error [is_substr $errorInfo \ 525 "unrecognized name-value pair"] 1 526 527 puts "\tEnv007.h: Test berkdb open flags and getters." 528 # Check options that we configure with berkdb open and 529 # query via getters. Structure of the list is: 530 # 0. Flag used in berkdb open command 531 # 1. Value specified to flag 532 # 2. Specific method, if needed 533 # 3. Arg used in getter 534 set olist { 535 { "-minkey" "4" " -btree " "get_bt_minkey" } 536 { "-cachesize" "0 1048576 1" "" "get_cachesize" } 537 { "" "FILENAME DBNAME" "" "get_dbname" } 538 { "" "" "" "get_env" } 539 { "-errpfx" "ERROR:" "" "get_errpfx" } 540 { "" "-chksum" "" "get_flags" } 541 { "-delim" "58" "-recno" "get_re_delim" } 542 { "" "-dup" "" "get_flags" } 543 { "" "-dup -dupsort" "" "get_flags" } 544 { "" "-recnum" "" "get_flags" } 545 { "" "-revsplitoff" "" "get_flags" } 546 { "" "-renumber" "-recno" "get_flags" } 547 { "" "-snapshot" "-recno" "get_flags" } 548 { "" "-create" "" "get_open_flags" } 549 { "" "-create -read_uncommitted" "" "get_open_flags" } 550 { "" "-create -excl" "" "get_open_flags" } 551 { "" "-create -nommap" "" "get_open_flags" } 552 { "" "-create -thread" "" "get_open_flags" } 553 { "" "-create -truncate" "" "get_open_flags" } 554 { "-ffactor" "40" " -hash " "get_h_ffactor" } 555 { "-lorder" "4321" "" "get_lorder" } 556 { "-nelem" "10000" " -hash " "get_h_nelem" } 557 { "-pagesize" "4096" "" "get_pagesize" } 558 { "-extent" "4" "-queue" "get_q_extentsize" } 559 { "-len" "20" "-recno" "get_re_len" } 560 { "-pad" "0" "-recno" "get_re_pad" } 561 { "-source" "include.tcl" "-recno" "get_re_source" } 562 } 563 564 set o "berkdb_open_noerr -create -mode 0644" 565 foreach item $olist { 566 cleanup $testdir NULL 567 set flag [lindex $item 0] 568 set flagval [lindex $item 1] 569 set method [lindex $item 2] 570 if { $method == "" } { 571 set method " -btree " 572 } 573 set getter [lindex $item 3] 574 575 puts "\t\tEnv007.h: $flag $flagval" 576 577 # Check that open is successful with the flag. 578 # The option -cachesize requires grouping for $flagval. 579 if { $flag == "-cachesize" } { 580 set ret [catch {eval $o $method $flag {$flagval}\ 581 $testdir/a.db} db] 582 } else { 583 set ret [catch {eval $o $method $flag $flagval\ 584 $testdir/a.db} db] 585 } 586 if { $ret != 0 } { 587 # If the open failed, it may be because we're on a 588 # platform such as HP-UX 10 that won't support 589 # locks in process-local memory. 590 # Verify that the return value was EOPNOTSUPP 591 # and bail gracefully. 592 error_check_good \ 593 is_thread_test [is_substr $flagval -thread] 1 594 error_check_good returned_error [expr \ 595 [is_substr $errorCode EINVAL] || \ 596 [is_substr $errorCode EOPNOTSUPP]] 1 597 puts "Warning: platform does not support\ 598 locks inside process-local memory." 599 puts "Skipping test of -thread flag." 600 } else { 601 error_check_good dbopen:0 [is_valid_db $db] TRUE 602 603 # Check that getter retrieves the correct value. 604 # Cachesizes under 500MB are adjusted upward to 605 # about 25% so just make sure we're in the right 606 # ballpark, between 1.2 and 1.3 of the original value. 607 if { $flag == "-cachesize" } { 608 set retval [eval $db $getter] 609 set retbytes [lindex $retval 1] 610 set setbytes [lindex $flagval 1] 611 error_check_good cachesize_low [expr\ 612 $retbytes > [expr $setbytes * 6 / 5]] 1 613 error_check_good cachesize_high [expr\ 614 $retbytes < [expr $setbytes * 13 / 10]] 1 615 } else { 616 error_check_good get_flagval \ 617 [eval $db $getter] $flagval 618 } 619 error_check_good dbclose:0 [$db close] 0 620 } 621 } 622 623 puts "\tEnv007.i: Test berkdb_open -rdonly." 624 # This test is done separately because -rdonly can only be specified 625 # on an already existing database. 626 set flag "-rdonly" 627 set db [eval berkdb_open $flag $testdir/a.db] 628 error_check_good open_rdonly [is_valid_db $db] TRUE 629 630 error_check_good get_rdonly [eval $db get_open_flags] $flag 631 error_check_good dbclose:0 [$db close] 0 632 633 puts "\tEnv007.j: Test berkdb open flags and getters\ 634 requiring environments." 635 # Check options that we configure with berkdb open and 636 # query via getters. Structure of the list is: 637 # 0. Flag used in berkdb open command 638 # 1. Value specified to flag 639 # 2. Specific method, if needed 640 # 3. Arg used in getter 641 # 4. Additional flags needed in setting up env 642 643 set elist { 644 { "" "-auto_commit" "" "get_open_flags" "" } 645 } 646 647 if { $has_crypto == 1 } { 648 lappend elist \ 649 { "" "-encrypt" "" "get_flags" "-encryptaes $passwd" } 650 } 651 652 set e "berkdb_env -create -home $testdir -txn " 653 set o "berkdb_open -create -btree -mode 0644 " 654 foreach item $elist { 655 env_cleanup $testdir 656 set flag [lindex $item 0] 657 set flagval [lindex $item 1] 658 set method [lindex $item 2] 659 if { $method == "" } { 660 set method " -btree " 661 } 662 set getter [lindex $item 3] 663 set envflag [lindex $item 4] 664 665 # Check that open is successful with the flag. 666 set env [eval $e $envflag] 667 set db [eval $o -env $env $flag $flagval a.db] 668 error_check_good dbopen:0 [is_valid_db $db] TRUE 669 670 # Check that getter retrieves the correct value 671 set get_flagval [eval $db $getter] 672 error_check_good get_flagval [is_substr $get_flagval $flagval] 1 673 error_check_good dbclose [$db close] 0 674 error_check_good envclose [$env close] 0 675 } 676} 677 678proc env007_check { env statcmd statstr testval } { 679 set stat [$env $statcmd] 680 set checked 0 681 foreach statpair $stat { 682 if {$checked == 1} { 683 break 684 } 685 set statmsg [lindex $statpair 0] 686 set statval [lindex $statpair 1] 687 if {[is_substr $statmsg $statstr] != 0} { 688 set checked 1 689 error_check_good $statstr:ck $statval $testval 690 } 691 } 692 error_check_good $statstr:test $checked 1 693} 694 695proc env007_make_config { carg cval } { 696 global testdir 697 698 set cid [open $testdir/DB_CONFIG w] 699 puts $cid "$carg $cval" 700 close $cid 701} 702