mariadb/bdb/test/test076.tcl

81 lines
1.9 KiB
Tcl
Raw Normal View History

2001-03-04 19:42:05 -05:00
# See the file LICENSE for redistribution information.
#
2002-10-30 15:57:05 +04:00
# Copyright (c) 2000-2002
2001-03-04 19:42:05 -05:00
# Sleepycat Software. All rights reserved.
#
2002-10-30 15:57:05 +04:00
# $Id: test076.tcl,v 1.18 2002/07/08 20:16:31 sue Exp $
2001-03-04 19:42:05 -05:00
#
2002-10-30 15:57:05 +04:00
# TEST test076
# TEST Test creation of many small databases in a single environment. [#1528].
2001-03-04 19:42:05 -05:00
proc test076 { method { ndbs 1000 } { tnum 76 } args } {
source ./include.tcl
set args [convert_args $method $args]
2002-10-30 15:57:05 +04:00
set encargs ""
set args [split_encargs $args encargs]
set omethod [convert_method $method]
2001-03-04 19:42:05 -05:00
if { [is_record_based $method] == 1 } {
set key ""
} else {
set key "key"
}
set data "datamoredatamoredata"
# Create an env if we weren't passed one.
2002-10-30 15:57:05 +04:00
set txnenv 0
2001-03-04 19:42:05 -05:00
set eindex [lsearch -exact $args "-env"]
if { $eindex == -1 } {
set deleteenv 1
2002-10-30 15:57:05 +04:00
env_cleanup $testdir
set env [eval {berkdb_env -create -home} $testdir $encargs]
2001-03-04 19:42:05 -05:00
error_check_good env [is_valid_env $env] TRUE
set args "$args -env $env"
} else {
set deleteenv 0
incr eindex
set env [lindex $args $eindex]
2002-10-30 15:57:05 +04:00
set txnenv [is_txnenv $env]
if { $txnenv == 1 } {
append args " -auto_commit "
if { $ndbs == 1000 } {
set ndbs 100
}
}
set testdir [get_home $env]
2001-03-04 19:42:05 -05:00
}
2002-10-30 15:57:05 +04:00
puts -nonewline "Test0$tnum $method ($args): "
puts -nonewline "Create $ndbs"
puts " small databases in one env."
2001-03-04 19:42:05 -05:00
cleanup $testdir $env
2002-10-30 15:57:05 +04:00
set txn ""
2001-03-04 19:42:05 -05:00
for { set i 1 } { $i <= $ndbs } { incr i } {
set testfile test0$tnum.$i.db
2002-10-30 15:57:05 +04:00
set db [eval {berkdb_open -create -mode 0644}\
2001-03-04 19:42:05 -05:00
$args $omethod $testfile]
error_check_good db_open($i) [is_valid_db $db] TRUE
2002-10-30 15:57:05 +04:00
if { $txnenv == 1 } {
set t [$env txn]
error_check_good txn [is_valid_txn $t $env] TRUE
set txn "-txn $t"
}
set ret [eval {$db put} $txn {$key$i \
[chop_data $method $data$i]}]
error_check_good db_put($i) $ret 0
if { $txnenv == 1 } {
error_check_good txn [$t commit] 0
}
2001-03-04 19:42:05 -05:00
error_check_good db_close($i) [$db close] 0
}
if { $deleteenv == 1 } {
error_check_good env_close [$env close] 0
}
puts "\tTest0$tnum passed."
}