📄 test.tcl
字号:
} } res] != 0} { global errorInfo; set fnl [string first "\n" $errorInfo] set theError [string range $errorInfo 0 [expr $fnl - 1]] if {[string first FAIL $errorInfo] == -1} { error "FAIL:[timestamp]\ run_method: $method $i: $theError" } else { error $theError; } }}proc run_rpcmethod { method {start 1} {stop 0} {largs ""} } { global __debug_on global __debug_print global num_test global parms global is_envmethod global rpc_svc source ./include.tcl if { $stop == 0 } { set stop $num_test(test) } puts "run_rpcmethod: $method $start $stop $largs" set save_largs $largs if { [string compare $rpc_server "localhost"] == 0 } { set dpid [exec $util_path/$rpc_svc -h $rpc_testdir &] } else { set dpid [exec rsh $rpc_server $rpc_path/$rpc_svc \ -h $rpc_testdir &] } puts "\tRun_rpcmethod.a: starting server, pid $dpid" tclsleep 10 remote_cleanup $rpc_server $rpc_testdir $testdir set home [file tail $rpc_testdir] set is_envmethod 1 set use_txn 0 if { [string first "txn" $method] != -1 } { set use_txn 1 } if { $use_txn == 1 } { if { $start == 1 } { set ntxns 32 } else { set ntxns $start } set i 1 check_handles remote_cleanup $rpc_server $rpc_testdir $testdir set env [eval {berkdb_env -create -mode 0644 -home $home \ -server $rpc_server -client_timeout 10000} -txn] error_check_good env_open [is_valid_env $env] TRUE set stat [catch {eval txn001_suba $ntxns $env} res] if { $stat == 0 } { set stat [catch {eval txn001_subb $ntxns $env} res] } error_check_good envclose [$env close] 0 set stat [catch {eval txn003} res] } else { set stat [catch { for { set i $start } { $i <= $stop } {incr i} { check_handles set name [format "test%03d" $i] if { [info exists parms($name)] != 1 } { puts stderr "[format Test%03d $i]\ disabled in testparams.tcl;\ skipping." continue } remote_cleanup $rpc_server $rpc_testdir $testdir # # Set server cachesize to 1Mb. Otherwise some # tests won't fit (like test084 -btree). # set env [eval {berkdb_env -create -mode 0644 \ -home $home -server $rpc_server \ -client_timeout 10000 \ -cachesize {0 1048576 1}}] error_check_good env_open \ [is_valid_env $env] TRUE append largs " -env $env " puts "[timestamp]" eval $name $method $parms($name) $largs if { $__debug_print != 0 } { puts "" } if { $__debug_on != 0 } { debug } flush stdout flush stderr set largs $save_largs error_check_good envclose [$env close] 0 } } res] } if { $stat != 0} { global errorInfo; set fnl [string first "\n" $errorInfo] set theError [string range $errorInfo 0 [expr $fnl - 1]] tclkill $dpid if {[string first FAIL $errorInfo] == -1} { error "FAIL:[timestamp]\ run_rpcmethod: $method $i: $theError" } else { error $theError; } } set is_envmethod 0 tclkill $dpid}proc run_rpcnoserver { method {start 1} {stop 0} {largs ""} } { global __debug_on global __debug_print global num_test global parms global is_envmethod source ./include.tcl if { $stop == 0 } { set stop $num_test(test) } puts "run_rpcnoserver: $method $start $stop $largs" set save_largs $largs remote_cleanup $rpc_server $rpc_testdir $testdir set home [file tail $rpc_testdir] set is_envmethod 1 set use_txn 0 if { [string first "txn" $method] != -1 } { set use_txn 1 } if { $use_txn == 1 } { if { $start == 1 } { set ntxns 32 } else { set ntxns $start } set i 1 check_handles remote_cleanup $rpc_server $rpc_testdir $testdir set env [eval {berkdb_env -create -mode 0644 -home $home \ -server $rpc_server -client_timeout 10000} -txn] error_check_good env_open [is_valid_env $env] TRUE set stat [catch {eval txn001_suba $ntxns $env} res] if { $stat == 0 } { set stat [catch {eval txn001_subb $ntxns $env} res] } error_check_good envclose [$env close] 0 } else { set stat [catch { for { set i $start } { $i <= $stop } {incr i} { check_handles set name [format "test%03d" $i] if { [info exists parms($name)] != 1 } { puts stderr "[format Test%03d $i]\ disabled in testparams.tcl;\ skipping." continue } remote_cleanup $rpc_server $rpc_testdir $testdir # # Set server cachesize to 1Mb. Otherwise some # tests won't fit (like test084 -btree). # set env [eval {berkdb_env -create -mode 0644 \ -home $home -server $rpc_server \ -client_timeout 10000 \ -cachesize {0 1048576 1} }] error_check_good env_open \ [is_valid_env $env] TRUE append largs " -env $env " puts "[timestamp]" eval $name $method $parms($name) $largs if { $__debug_print != 0 } { puts "" } if { $__debug_on != 0 } { debug } flush stdout flush stderr set largs $save_largs error_check_good envclose [$env close] 0 } } res] } if { $stat != 0} { global errorInfo; set fnl [string first "\n" $errorInfo] set theError [string range $errorInfo 0 [expr $fnl - 1]] if {[string first FAIL $errorInfo] == -1} { error "FAIL:[timestamp]\ run_rpcnoserver: $method $i: $theError" } else { error $theError; } set is_envmethod 0 }}## Run method tests in secure mode.#proc run_secmethod { method {start 1} {stop 0} {display 0} {run 1} \ { outfile stdout } args } { global passwd append largs " -encryptaes $passwd " eval run_method $method $start $stop $display $run $outfile $largs}## Run method tests in its own, new secure environment.#proc run_secenv { method {start 1} {stop 0} {largs ""} } { global __debug_on global __debug_print global is_envmethod global num_test global parms global passwd source ./include.tcl if { $stop == 0 } { set stop $num_test(test) } puts "run_secenv: $method $start $stop $largs" set save_largs $largs env_cleanup $testdir set is_envmethod 1 set stat [catch { for { set i $start } { $i <= $stop } {incr i} { check_handles set env [eval {berkdb_env -create -mode 0644 \ -home $testdir -encryptaes $passwd \ -cachesize {0 1048576 1}}] error_check_good env_open [is_valid_env $env] TRUE append largs " -env $env " puts "[timestamp]" set name [format "test%03d" $i] if { [info exists parms($name)] != 1 } { puts stderr "[format Test%03d $i] disabled in\ testparams.tcl; skipping." continue } # # Run each test multiple times in the secure env. # Once with a secure env + clear database # Once with a secure env + secure database # eval $name $method $parms($name) $largs append largs " -encrypt " eval $name $method $parms($name) $largs if { $__debug_print != 0 } { puts "" } if { $__debug_on != 0 } { debug } flush stdout flush stderr set largs $save_largs error_check_good envclose [$env close] 0 error_check_good envremove [berkdb envremove \ -home $testdir -encryptaes $passwd] 0 } } res] if { $stat != 0} { global errorInfo; set fnl [string first "\n" $errorInfo] set theError [string range $errorInfo 0 [expr $fnl - 1]] if {[string first FAIL $errorInfo] == -1} { error "FAIL:[timestamp]\ run_secenv: $method $i: $theError" } else { error $theError; } set is_envmethod 0 }}## Run replication method tests in master and client env.#proc run_reptest { method test {droppct 0} {nclients 1} {do_del 0} \ {do_sec 0} {do_oob 0} {largs "" } } { source ./include.tcl global __debug_on global __debug_print global __debug_test global is_envmethod global num_test global parms global passwd global rand_init berkdb srand $rand_init set c [string index $test 0] if { $c == "s" } { set i [string range $test 1 end] set name [format "subdb%03d" $i] } else { set i $test set name [format "test%03d" $i] } puts "run_reptest: $method $name" env_cleanup $testdir set is_envmethod 1 set stat [catch { if { $do_sec } { set envargs "-encryptaes $passwd" append largs " -encrypt " } else { set envargs "" } check_handles # # This will set up the master and client envs # and will return us the args to pass to the # test. set largs [repl_envsetup \ $envargs $largs $test $nclients $droppct $do_oob] puts "[timestamp]" if { [info exists parms($name)] != 1 } { puts stderr "[format Test%03d $i] \ disabled in\ testparams.tcl; skipping." continue } puts -nonewline \ "Repl: $name: dropping $droppct%, $nclients clients " if { $do_del } { puts -nonewline " with delete verification;" } else { puts -nonewline " no delete verification;" } if { $do_sec } { puts -nonewline " with security;" } else { puts -nonewline " no security;" } if { $do_oob } { puts -nonewline " with out-of-order msgs;" } else { puts -nonewline " no out-of-order msgs;" } puts "" eval $name $method $parms($name) $largs if { $__debug_print != 0 } { puts "" } if { $__debug_on != 0 } { debug $__debug_test } flush stdout flush stderr repl_envprocq $i $nclients $do_oob repl_envver0 $i $method $nclients if { $do_del } { repl_verdel $i $method $nclients } repl_envclose $i $envargs } res] if { $stat != 0} { global errorInfo; set fnl [string first "\n" $errorInfo] set theError [string range $errorInfo 0 [expr $fnl - 1]] if {[string first FAIL $errorInfo] == -1} { error "FAIL:[timestamp]\ run_reptest: $method $i: $theError" } else { error $theError; } } set is_envmethod 0}## Run replication method tests in master and client env.#proc run_repmethod { method {numcl 0} {start 1} {stop 0} {display 0} {run 1} {outfile stdout} {largs ""} } { source ./include.tcl global __debug_on global __debug_print global __debug_test global is_envmethod global num_test global parms global passwd global rand_init set stopsdb $num_test(sdb) if { $stop == 0 } { set stop $num_test(test) } else { if { $stopsdb > $stop } { set stopsdb $stop } } berkdb srand $rand_init # # We want to run replication both normally and with crypto. # So run it once and then run again with crypto. # set save_largs $largs env_cleanup $testdir if { $display == 1 } { for { set i $start } { $i <= $stop } { incr i } { puts $outfile "eval run_repmethod $method \ 0 $i $i 0 1 stdout $largs" } } if { $run == 1 } { set is_envmethod 1 # # Use an array for number of clients because we really don't # want to evenly-weight all numbers of clients. Favor smaller # numbers but test more clients occasionally. set drop_list { 0 0 0 0 0 1 1 5 5 10 20 } set drop_len [expr [llength $drop_list] - 1] set client_list { 1 1 2 1 1 1 2 2 3 1 } set cl_len [expr [llength $client_list] - 1] set stat [catch { for { set i $start } { $i <= $stopsdb } {incr i} { if { $numcl == 0 } { set clindex [berkdb random_int 0 $cl_len] set nclients [lindex $client_list $clindex] } else { set nclients $numcl } set drindex [berkdb random_int 0 $drop_len] set droppct [lindex $drop_list $drindex] set do_sec [berkdb random_int 0 1] set do_oob [berkdb random_int 0 1] set do_del [berkdb random_int 0 1] if { $do_sec } { set envargs "-encryptaes $passwd" append largs " -encrypt " } else { set envargs "" } check_handles # # This will set up the master and client envs # and will return us the args to pass to the # test. set largs [repl_envsetup $envargs $largs \ $i $nclients $droppct $do_oob] puts "[timestamp]" set name [format "subdb%03d" $i] if { [info exists parms($name)] != 1 } { puts stderr "[format Subdb%03d $i] \ disabled in\ testparams.tcl; skipping." continue } puts -nonewline "Repl: $name: dropping $droppct%, \ $nclients clients " if { $do_del } { puts -nonewline " with delete verification;" } else { puts -nonewline " no delete verification;" } if { $do_sec } { puts -nonewline " with security;" } else { puts -nonewline " no security;" } if { $do_oob } { puts -nonewline " with out-of-order msgs;" } else { puts -nonewline " no out-of-order msgs;" } puts "" eval $name $method $parms($name) $largs if { $__debug_print != 0 } { puts "" } if { $__debug_on != 0 } { debug $__debug_test } flush stdout flush stderr repl_envprocq $i $nclients $do_oob repl_envver0 $i $method $nclients if { $do_del } { repl_verdel $i $method $nclients } repl_envclose $i $envargs set largs $save_largs } } res] if { $stat != 0} { global errorInfo; set fnl [string first "\n" $errorInfo] set theError [string range $errorInfo 0 [expr $fnl - 1]] if {[string first FAIL $errorInfo] == -1} { error "FAIL:[timestamp]\ run_repmethod: $method $i: $theError" } else { error $theError; } } set stat [catch { for { set i $start } { $i <= $stop } {incr i} { if { $numcl == 0 } { set clindex [berkdb random_int 0 $cl_len] set nclients [lindex $client_list $clindex] } else { set nclients $numcl } set drindex [berkdb random_int 0 $drop_len] set droppct [lindex $drop_list $drindex] set do_sec [berkdb random_int 0 1] set do_oob [berkdb random_int 0 1] set do_del [berkdb random_int 0 1] if { $do_sec } { set envargs "-encryptaes $passwd" append largs " -encrypt " } else { set envargs "" } check_handles # # This will set up the master and client envs # and will return us the args to pass to the # test. set largs [repl_envsetup $envargs $largs \ $i $nclients $droppct $do_oob] puts "[timestamp]" set name [format "test%03d" $i] if { [info exists parms($name)] != 1 } { puts stderr "[format Test%03d $i] \ disabled in\ testparams.tcl; skipping." continue } puts -nonewline "Repl: $name: dropping $droppct%, \ $nclients clients " if { $do_del } { puts -nonewline " with delete verification;" } else { puts -nonewline " no delete verification;" } if { $do_sec } { puts -nonewline " with security;" } else { puts -nonewline " no security;" } if { $do_oob } { puts -nonewline " with out-of-order msgs;" } else { puts -nonewline " no out-of-order msgs;" } puts "" eval $name $method $parms($name) $largs if { $__debug_print != 0 } { puts "" } if { $__debug_on != 0 } { debug $__debug_test } flush stdout flush stderr repl_envprocq $i $nclients $do_oob repl_envver0 $i $method $nclients if { $do_del } { repl_verdel $i $method $nclients } repl_envclose $i $envargs set largs $save_largs } } res] if { $stat != 0} { global errorInfo; set fnl [string first "\n" $errorInfo] set theError [string range $errorInfo 0 [expr $fnl - 1]] if {[string first FAIL $errorInfo] == -1} { error "FAIL:[timestamp]\ run_repmethod: $method $i: $theError" } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -