2 if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
5 # set env(CSF_DrawPluginQADefaults) $env(CASROOT)/src/DrawResources/.
7 # pload -DrawPluginQA QAcommands
10 # to prevent loops limit to 16 minutes
13 #set script_dir [file dirname [info script]]/script
14 # if { [info exist WorkDirectory] == 0 } {
15 # set WorkDirectory "/tmp"
16 # if { [array get env TEMP] != "" } {
17 # set WorkDirectory "$env(TEMP)"
21 if { [info exists imagedir] == 0 } {
24 if { [info exists test_image] == 0 } {
28 # Procedure to check if sequence of values in listval follows linear trend
29 # adding the same delta on each step.
31 # The function does statistical estimation of the mean variation of the
32 # values of the sequence, and dispersion, and returns true only if both
33 # dispersion and deviation of the mean from expected delta are within
34 # specified tolerance.
36 # If mean variation differs from expected delta on more than two dispersions,
37 # the check fails and procedure raises error with specified message.
39 # Otherwise the procedure returns false meaning that more iterations are needed.
40 # Note that false is returned in any case if length of listval is less than 3.
42 # See example of use to check memory leaks in bugs/caf/bug23489
44 proc checktrend {listval delta tolerance message} {
45 set nbval [llength $listval]
50 # calculate mean value
52 set prev [lindex $listval 0]
53 foreach val [lrange $listval 1 end] {
54 set mean [expr $mean + ($val - $prev)]
57 set mean [expr $mean / $nbval]
59 # calculate dispersion
61 set prev [lindex $listval 0]
62 foreach val [lrange $listval 1 end] {
63 set d [expr ($val - $prev) - $mean]
64 set sigma [expr $sigma + $d * $d]
67 set sigma [expr sqrt ($sigma / ($nbval - 1))]
69 puts "Checking trend: nb = $nbval, mean delta = $mean, sigma = $sigma"
71 # check if deviation is definitely too big
72 if { abs ($mean - $delta) > 2. * $sigma } {
73 puts "Checking trend failed: mean delta per step = $mean, sigma = $sigma, expected delta = $delta"
77 # check if deviation is clearly within a range
78 return [expr abs ($mean - $delta) <= $sigma && $sigma <= $tolerance]