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 # On Windows with VC, in typical configuration gl2ps is built with Release
14 # mode only which will fail in Debug mode; add TODO for that case in order
15 # to handle it once for all tests that can use vexport command
16 if { [regexp {Debug mode} [dversion]] } {
17 puts "TODO ?#23540 windows: Error: export of image.*failed"
18 puts "TODO ?#23540 windows: Error: The file has been exported.*different size \[(\]0 "
21 if { [info exists imagedir] == 0 } {
24 if { [info exists test_image] == 0 } {
28 # Procedure to check equality of two reals with tolerance (relative and absolute)
29 help checkreal {name value expected tol_abs tol_rel}
30 proc checkreal {name value expected tol_abs tol_rel} {
31 if { abs ($value - $expected) > $tol_abs + $tol_rel * abs ($expected) } {
32 puts "Error: $name = $value is not equal to expected $expected"
34 puts "Check of $name OK: value = $value, expected = $expected"
39 # Procedure to check equality of two reals with tolerance (relative and absolute)
40 help checkarea {shape area_expected tol_abs tol_rel}
41 proc checkarea {shape area_expected tol_abs tol_rel} {
42 # compute area with half of the relative tolerance
43 # to be used in comparison; 0.001 is added to avoid zero value
44 set prop [uplevel sprops $shape [expr 0.5 * abs($tol_rel) + 0.001]]
47 if { ! [regexp {Mass\s*:\s*([0-9.e+-]+)} $prop res area] } {
48 puts "Error: cannot get area of the shape $shape"
52 # compare with expected value
53 checkreal "area of $shape" $area $area_expected $tol_abs $tol_rel
56 # Procedure to check if sequence of values in listval follows linear trend
57 # adding the same delta on each step.
59 # The function does statistical estimation of the mean variation of the
60 # values of the sequence, and dispersion, and returns true only if both
61 # dispersion and deviation of the mean from expected delta are within
62 # specified tolerance.
64 # If mean variation differs from expected delta on more than two dispersions,
65 # the check fails and procedure raises error with specified message.
67 # Otherwise the procedure returns false meaning that more iterations are needed.
68 # Note that false is returned in any case if length of listval is less than 3.
70 # See example of use to check memory leaks in bugs/caf/bug23489
72 proc checktrend {listval delta tolerance message} {
73 set nbval [llength $listval]
78 # calculate mean value
80 set prev [lindex $listval 0]
81 foreach val [lrange $listval 1 end] {
82 set mean [expr $mean + ($val - $prev)]
85 set mean [expr $mean / ($nbval - 1)]
87 # calculate dispersion
89 set prev [lindex $listval 0]
90 foreach val [lrange $listval 1 end] {
91 set d [expr ($val - $prev) - $mean]
92 set sigma [expr $sigma + $d * $d]
95 set sigma [expr sqrt ($sigma / ($nbval - 2))]
97 puts "Checking trend: nb = $nbval, mean delta = $mean, sigma = $sigma"
99 # check if deviation is definitely too big
100 if { abs ($mean - $delta) > $tolerance + 2. * $sigma } {
101 puts "Checking trend failed: mean delta per step = $mean, sigma = $sigma, expected delta = $delta"
105 # check if deviation is clearly within a range
106 return [expr abs ($mean - $delta) <= $sigma && $sigma <= $tolerance]
109 # Check if area of triangles is valid
110 proc CheckTriArea {shape {eps 0}} {
111 upvar #0 $shape result
112 set area [triarea result $eps]
113 set t_area [lindex $area 0]
114 set g_area [expr abs([lindex $area 1])]
115 puts "area by triangles: $t_area"
116 puts "area by geometry: $g_area"
117 expr ($t_area - $g_area) / $g_area * 100
120 # Check if list of xdistcs-command is valid
121 proc checkList {List Tolerance D_good Limit_Tol} {
122 set L1 [llength ${List}]
125 set N [expr (${L1} - ${L2})/${L3} + 1]
127 for {set i 1} {${i} <= ${N}} {incr i} {
128 set j1 [expr ${L2} + (${i}-1)*${L3}]
129 set j2 [expr ${j1} + 2]
130 set T [lindex ${List} ${j1}]
131 set D [lindex ${List} ${j2}]
132 #puts "i=${i} j1=${j1} j2=${j2} T=${T} D=${D}"
133 if { [expr abs(${D} - ${D_good})] > ${Tolerance} } {
134 puts "Error : T=${T} D=${D}"
137 if { ${Tolerance} > ${Limit_Tol} } {
138 if { [expr abs(${D} - ${D_good})] > ${Limit_Tol}
139 && [expr abs(${D} - ${D_good})] <= ${Tolerance} } {
140 puts "Attention (critical value of tolerance) : T=${T} D=${D}"
146 # Check expected time
147 proc checktime {value expected tol_rel message} {
148 set t1 [expr ${value} - ${expected}]
149 set t2 [expr ${expected} * abs (${tol_rel})]
151 if { abs (${t1}) <= ${t2} } {
152 puts "OK. ${message}, ${value} seconds, is equal to expected time - ${expected} seconds"
153 } elseif {${t1} > ${t2}} {
154 puts "Error. ${message}, ${value} seconds, is more than expected time - ${expected} seconds"
156 puts "Improvement. ${message}, ${value} seconds, is less than expected time - ${expected} seconds"
160 # Procedure to check result of nbshapes command
161 proc checknbshapes { res nbshapes_expected_s count_locations message} {
164 if { ${count_locations} == 0 } {
165 set nb_info [nbshapes shape]
167 set nb_info [nbshapes shape -t]
170 set EntityList {VERTEX EDGE WIRE FACE SHELL SOLID COMPSOLID COMPOUND SHAPE}
172 foreach Entity ${EntityList} {
173 set expr_string "${Entity} +: +(\[-0-9.+eE\]+)"
174 if { [regexp "${expr_string}" ${nbshapes_expected_s} full nb_entity1] > 0 } {
175 if { [regexp "${expr_string}" ${nb_info} full nb_entity2] > 0 } {
176 if { ${nb_entity2} != ${nb_entity1} } {
177 puts "Error : ${message} is WRONG because number of ${Entity} entities is ${nb_entity2} while ${nb_entity1} is expected"
179 puts "OK : ${message} is GOOD because number of ${Entity} entities is equal to number of expected ${Entity} entities"